buildinfy 0.1.2

Easy access to GitLab CI/CD variables for automatic versioning
Documentation

// 'mac', 'win', 'linux'
pub fn build_target() -> &'static str {
    if cfg!(target_os = "linux") {
        "linux"
    } else if cfg!(target_os = "freebsd") {
        "freebsd"
    } else if cfg!(target_os = "macos") {
        "mac"
    } else if cfg!(target_os = "windows") {
        "win"
    } else if cfg!(unix) {
        "unix"
    } else {
        "other"
    }
}
// 'master', ... (git branches or tags)
pub fn build_reference() -> Option<&'static str> {
    option_env!("CI_COMMIT_REF_NAME")
}
// '123', ... (GitLab CI pipeline id)
pub fn build_pipeline_id() -> Option<&'static str> {
    option_env!("CI_PIPELINE_ID")
}
// '123', ... (GitLab CI pipeline id per project)
pub fn build_pipeline_id_per_project() -> Option<&'static str> {
    option_env!("CI_PIPELINE_IID")
}
// '123', ... (GitLab CI job id)
pub fn build_job_id() -> Option<&'static str> {
    option_env!("CI_JOB_ID")
}
// git revision if available
pub fn build_revision() -> Option<&'static str> {
    option_env!("CI_COMMIT_SHA")
}
// sentry error reporting DSN
pub fn build_sentry_dsn() -> Option<&'static str> {
    option_env!("SENTRY_DSN")
}

#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        println!("{}", crate::build_target());
        assert!(true);
    }
}