ci: derive release version from the tag and fail loudly on mismatch - #46
Merged
Merged
Conversation
The `Get version` step read the crate version with `cut -d'\"' -f2`. YAML passes that through as a literal backslash-quote, so `cut` rejected the two-character delimiter and exited non-zero. Because the failure happened inside a command substitution, `echo` still exited 0 and the step stayed green while writing an empty `crate_version`. Every release since 0.3.1 therefore published to the tag "v" rather than "vX.Y.Z", with assets named `scim_v2_v.tar.gz` / `scim_v2_v.zip`. The v0.4.2 run reproduced it today. The version now comes from `GITHUB_REF_NAME`, which is authoritative on a tag-triggered run, and is cross-checked against Cargo.toml so a tag that disagrees with the manifest fails the job instead of silently producing a malformed release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The release workflow has been publishing malformed releases since 0.3.1, while reporting success on every run.
release.yml'sGet versionstep read the crate version with:In a YAML plain scalar,
\"is passed through literally, socutreceives a two-character delimiter and rejects it:The failure occurs inside a command substitution, so
echostill exits 0. The step goes green having written an emptycrate_version.Impact
Every tag push since 0.3.1 produced a release at
tag_name: vwith assets namedscim_v2_v.tar.gzandscim_v2_v.zip, instead of a release at the intended tag.That release object is still present. It is titled
v0.3.1, points at a tag literally namedv, and is currently flagged Latest. The v0.4.2 run reproduced the behaviour today, overwriting its assets again. Cleanup of that stale object is deliberately not in this PR.crates.io was never affected.
publish.ymlrunscargo publish, which takes its version fromCargo.tomldirectly, so 0.4.1 and 0.4.2 published correctly.Change
The version now comes from
GITHUB_REF_NAME, which is authoritative given the workflow only triggers onv*.*.*tags, and is cross-checked againstCargo.toml:set -euo pipefailplus the explicit guard means the class of bug that caused this, a silent empty value, now fails the job rather than shipping a broken release.Verification
Cargo.toml:cut: bad delimiter, exit 1.GITHUB_REF_NAME=v0.4.2againstversion = "0.4.2"yieldscrate_version=0.4.2, exit 0.GITHUB_REF_NAME=v9.9.9emits the error annotation and exits 1.No version bump, per the intent to let the next release pick this up.