{"id":16162367,"url":"https://github.com/sunsided/dotnet-gitversion-rs","last_synced_at":"2025-03-18T22:31:06.391Z","repository":{"id":57621603,"uuid":"378506969","full_name":"sunsided/dotnet-gitversion-rs","owner":"sunsided","description":"dotnet-gitversion for Rust builds","archived":false,"fork":false,"pushed_at":"2024-02-28T09:51:02.000Z","size":33,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-28T12:32:33.411Z","etag":null,"topics":["dotnet","gitversion","rust","semver"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/dotnet-gitversion-build","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sunsided.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-19T21:24:09.000Z","updated_at":"2024-02-28T09:51:05.000Z","dependencies_parsed_at":"2024-10-27T19:17:03.184Z","dependency_job_id":"9edc1a60-9339-4bdd-857d-5bac8eed6c88","html_url":"https://github.com/sunsided/dotnet-gitversion-rs","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"97fa89a320b59208e94f8fae48e567e1d13938b8"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fdotnet-gitversion-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fdotnet-gitversion-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fdotnet-gitversion-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fdotnet-gitversion-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sunsided","download_url":"https://codeload.github.com/sunsided/dotnet-gitversion-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243950927,"owners_count":20373664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotnet","gitversion","rust","semver"],"created_at":"2024-10-10T02:29:53.641Z","updated_at":"2025-03-18T22:31:06.153Z","avatar_url":"https://github.com/sunsided.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dotnet-gitversion for Rust builds\n\nThis project provides a build-time wrapper to [GitTools/GitVersion]\nthat embeds [Semantic Version] information obtained\nfrom the current repository state.\n\n## Prerequisites\n\nThis library requires both the [.NET runtime] (e.g. .NET 5)\nand the [GitVersion.Tool] package to be installed globally, e.g.\n\n```console\n$ dotnet tool install --global GitVersion.Tool --version 5.6.10\n```\n\nYou can verify the installation by calling either\n\n```console\n$ dotnet gitversion\n$ dotnet-gitversion\n```\n\n**Note that a `GitVersion.yml` configuration file might be required in your repo.**\nSee the [GitVersion.yml](GitVersion.yml) of this project for an example.\n\n## Usage\n\nAdd `dotnet-gitversion` to your build dependencies:\n\n```toml\n[build-dependencies]\ndotnet-gitversion-build = \"0.3.0\"\n```\n\nCreate or update your `build.rs` to call `dotnet_gitversion_build::build()`.\nThis method populates various `GITVERSION_` environment variables to be used with the `env!` macro,\ncreates the `gitversion.rs` file in the `OUT_DIR` directory \nand additionally returns the intermediate representation:\n\n```rust\nfn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let _gv = dotnet_gitversion_build::build()?;\n    Ok(())\n}\n```\n\nThe `GITVERSION_...` environment variables can be used immediately:\n\n```rust\nfn main() {\n    // Use the build-generated environment variables.\n    println!(\"Info version: {}\", env!(\"GITVERSION_INFORMATIONAL_VERSION\"));\n    println!(\"Full SemVer:  {}\", env!(\"GITVERSION_FULL_SEMVER\"));\n}\n```\n\nExample output of the above code:\n\n```text\nInfo version: 0.2.0+Branch.main.Sha.645a21e7b6358e9b72978a1b46cbd6c55a85a9af\nFull SemVer:  0.2.0\n```\n\nAfter including the generated `gitversion.rs` file you will additionally have access\nto the static `GIT_VERSION` constant and the `GitVersion` struct:\n\n```rust\ninclude!(concat!(env!(\"OUT_DIR\"), \"/gitversion.rs\"));\n\nfn main() {\n    // Use the \"global\" constant.\n    println!(\"Display:      {}\", GIT_VERSION);\n    println!(\"Debug:        {:?}\", GIT_VERSION);\n    println!(\"SHA:          {}\", GIT_VERSION.sha);\n    println!(\"Commit:       {}\", GIT_VERSION.commit_date);\n\n    // The GitVersion::new() function allows you to obtain\n    // the struct as a constant.\n    const GV: GitVersion = GitVersion::new();\n    println!(\"Branch name:  {}\", GV.branch_name);\n\n    // Alternatively you can use the Default trait to obtain a new instance.\n    let gv = GitVersion::default();\n    println!(\"Short commit: {}\", gv.short_sha);\n}\n```\n\nExample output of the above code:\n\n```text\nDisplay:      0.2.0\nDebug:        0.2.0+Branch.main.Sha.2e3c96c6dbd30a0ca25e51d2fb10982042670a46\nSHA:          2e3c96c6dbd30a0ca25e51d2fb10982042670a46\nCommit:       2021-06-20\nBranch name:  main\nShort commit: 2e3c96c\n```\n\nThe imported `GitVersion` struct itself is defined as shown below. Please\nsee [GitTools/GitVersion](https://github.com/GitTools/GitVersion) for\ndocumentation on the field values or run `dotnet gitversion`.\nThe environment variables names are generated with a `GITVERSION_` prefix followed\nby the filed names, e.g. `GITVERSION_MAJOR_MINOR_PATCH`.\n\n```rust\npub struct GitVersion {\n    pub major: u32,\n    pub minor: u32,\n    pub patch: u32,\n    pub pre_release_tag: \u0026'static str,\n    pub pre_release_tag_with_dash: \u0026'static str,\n    pub pre_release_label: \u0026'static str,\n    pub pre_release_label_with_dash: \u0026'static str,\n    pub pre_release_number: Option\u003cu32\u003e,\n    pub weighted_pre_release_number: u32,\n    pub build_meta_data: Option\u003cu32\u003e,\n    pub build_meta_data_padded: \u0026'static str,\n    pub full_build_meta_data: \u0026'static str,\n    pub major_minor_patch: \u0026'static str,\n    pub semver: \u0026'static str,\n    #[deprecated]\n    pub legacy_semver: \u0026'static str,\n    #[deprecated]\n    pub legacy_semver_padded: \u0026'static str,\n    pub assembly_semver: \u0026'static str,\n    pub assembly_sem_file_version: \u0026'static str,\n    pub informational_version: \u0026'static str,\n    pub branch_name: \u0026'static str,\n    pub escaped_branch_name: \u0026'static str,\n    pub sha: \u0026'static str,\n    pub short_sha: \u0026'static str,\n    #[deprecated]\n    pub nuget_version_v2: \u0026'static str,\n    #[deprecated]\n    pub nuget_version: \u0026'static str,\n    #[deprecated]\n    pub nuget_prerelease_tag_v2: \u0026'static str,\n    #[deprecated]\n    pub nuget_prerelease_tag: \u0026'static str,\n    pub version_source_sha: \u0026'static str,\n    pub commits_since_version_source: u32,\n    pub commits_since_version_source_padded: \u0026'static str,\n    pub uncommitted_changes: u32,\n    pub commit_date: \u0026'static str,\n}\n```\n\n[GitTools/GitVersion]: https://github.com/GitTools/GitVersion\n[Semantic Version]: http://semver.org/\n[GitVersion.Tool]: https://www.nuget.org/packages/GitVersion.Tool/\n[.NET runtime]: https://dot.net/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunsided%2Fdotnet-gitversion-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunsided%2Fdotnet-gitversion-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunsided%2Fdotnet-gitversion-rs/lists"}