{"record":{"id":"7370ed2f8af8d37a","repo":"cross-rs/cross","slug":"git-tag-does-not-match-package-version","errorCode":null,"errorMessage":"git tag does not match package version.","messagePattern":"git tag does not match package version\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/src/build_docker_image.rs","lineNumber":409,"sourceCode":"    })\n}\n\npub fn determine_image_name(\n    target: &ImageTarget,\n    repository: &str,\n    ref_type: &str,\n    ref_name: &str,\n    is_latest: bool,\n    version: &str,\n) -> cross::Result<Vec<String>> {\n    let mut tags = vec![];\n    match (ref_type, ref_name) {\n        (\"tag\", ref_name) if ref_name.starts_with('v') => {\n            let tag_version = ref_name\n                .strip_prefix('v')\n                .expect(\"tag name should start with v\");\n            if version != tag_version {\n                eyre::bail!(\"git tag does not match package version.\")\n            }\n            tags.push(target.image_name(repository, version));\n            // Check for unstable releases, tag stable releases as `latest`\n            if is_latest {\n                tags.push(target.image_name(repository, \"latest\"))\n            }\n        }\n        (\"branch\", ref_name) => {\n            if let Some(gh_queue) = ref_name.strip_prefix(\"gh-readonly-queue/\") {\n                let (_, source) = gh_queue\n                    .split_once('/')\n                    .ok_or_else(|| eyre::eyre!(\"invalid gh-readonly-queue branch name\"))?;\n                tags.push(target.image_name(repository, source));\n            } else {\n                tags.push(target.image_name(repository, ref_name));\n            }\n\n            if [\"staging\", \"trying\"]","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/cross-rs/cross/blob/8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27/xtask/src/build_docker_image.rs#L391-L427","documentation":"determine_image_name computes the docker image tags for a release build. When the build is triggered from a git tag starting with 'v', it strips the prefix and requires the tag version to exactly equal the package version; on mismatch it bails. This guards against publishing an image whose tag and embedded version disagree.","triggerScenarios":"A git ref of type 'tag' named `v<something>` is present, and `<something>` (after stripping 'v') is not string-equal to the crate's package version.","commonSituations":"Tagging v1.2.3 while Cargo.toml still says 1.2.2 (or vice versa) after a version bump was forgotten; tagging with a suffix like v1.2.3-rc1 not reflected in the version; re-running the release workflow against an old tag after bumping the version.","solutions":["Align the git tag and package version: update Cargo.toml to match the tag (or retag to match the version) before building","Retag the release: e.g. `git tag -f v0.5.0 && git push -f origin v0.5.0` after fixing the version file","If this is not a versioned release, build from a non-v-prefixed branch/commit so the tag check is skipped"],"exampleFix":"// before\ngit tag v1.2.3   # but Cargo.toml: version = \"1.2.2\"\n// after\n# Cargo.toml: version = \"1.2.3\"  (commit)\ngit tag v1.2.3 && git push origin v1.2.3","handlingStrategy":"validation","validationCode":"// in CI, before the docker build job\nVERSION=$(grep -m1 '^version' Cargo.toml | sed 's/.*\"\\(.*\\)\"/\\1/')\nTAG=${GITHUB_REF_NAME#v}\nif [[ \"$GITHUB_REF_TYPE\" == \"tag\" && \"$GITHUB_REF_NAME\" == v* && \"$VERSION\" != \"$TAG\" ]]; then\n  echo \"git tag v$TAG does not match package version $VERSION\"; exit 1;\nfi","typeGuard":null,"tryCatchPattern":"match build_docker_image(...) {\n    Ok(name) => push(name),\n    Err(e) if e.to_string().contains(\"git tag does not match package version\") => {\n        eprintln!(\"Release aborted: align Cargo.toml version with the v-prefixed git tag, then re-tag\");\n        std::process::exit(1);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Automate version bumps: update Cargo.toml and create the v-tag in one release script","Gate release workflows with a pre-flight check that Cargo.toml version == tag version minus 'v'","Avoid manual tags; use a release tool (cargo-release) that keeps tag and version in sync","For pre-releases, keep the exact same suffix in both the tag and the package version"],"tags":["release","docker","versioning","git"],"backgroundTag":"checksum-mismatch","analyzedSha":"8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27","analyzedAt":"2026-09-13T15:10:43.988Z","contentChangedAt":"2026-09-13T15:10:43.988Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}