Possibility to set the package version dynamically
Nobody has claimed this yet.
- #14919 by @sunhaitao — closed without merging
- Dominant language
- Rust
- Stars
- 15.5k
- Forks
- 3k
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 51
Description
Maintainer notes
- For one approach to tracking a marketing version, see https://github.com/rust-lang/cargo/issues/6583#issuecomment-1702417194
- Version field is now optional (#12786)
- For a CLI to edit
package.version, see https://github.com/killercup/cargo-edit - For dynamic version design considerations, see https://github.com/rust-lang/cargo/issues/6583#issuecomment-1131619829
Hello
I'm building a rust application using internal teamcity CI job. I want the build number to be part of the version of the binary (so eg. ./app --version knows from which build it came).
The only way I found so far is to let the build first edit the Cargo.toml (sed -i -e 's/^version = .*/version = "%build.version%"/' Cargo.toml), which seems ugly and fragile.
It would be great if I could somehow override the version from Cargo.toml through the command line ‒ either as a parameter or an environment variable.
Would something like that make sense? Are there plans to support it?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the issue's dynamic-version design considerations and the linked pull request #14919, then review how Cargo currently handles the optional version field in Cargo.toml. Compare the proposed command-line and environment-variable approaches, and define the supported override behavior and its effect on package and binary versions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100