Skip to content

ci: fix release tagging on protected main#9

Merged
nikuscs merged 8 commits into
mainfrom
feat/grouped-modes-dot-notation
Mar 3, 2026
Merged

ci: fix release tagging on protected main#9
nikuscs merged 8 commits into
mainfrom
feat/grouped-modes-dot-notation

Conversation

@nikuscs

@nikuscs nikuscs commented Mar 3, 2026

Copy link
Copy Markdown
Owner

Fix release workflow to derive next version from latest git tag and fail early if target tag already exists. Also keeps tag-only push (no direct push to protected main).


Open with Devin

@nikuscs nikuscs merged commit dc3680b into main Mar 3, 2026
@nikuscs nikuscs deleted the feat/grouped-modes-dot-notation branch March 3, 2026 17:50

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 7 additional findings in Devin Review.

Open in Devin Review

Comment on lines +109 to +116
- name: Create tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Cargo.toml
git commit -m "chore: bump version to ${{ steps.bump.outputs.version }}"
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
if git ls-remote --tags origin "refs/tags/${{ steps.bump.outputs.tag }}" | grep -q "${{ steps.bump.outputs.tag }}"; then
echo "::error::Tag ${{ steps.bump.outputs.tag }} already exists on origin"
exit 1
fi
git tag -a "${{ steps.bump.outputs.tag }}" -m "Release ${{ steps.bump.outputs.tag }}"
git push origin main --follow-tags
git push origin "${{ steps.bump.outputs.tag }}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Release workflow no longer updates Cargo.toml version, causing built binaries to always report stale version

The PR removes the "Update Cargo.toml" and "Commit and tag" steps from the release workflow (release.yml:106-116 old lines), but the binary's version string is derived from Cargo.toml at compile time via #[command(version)] in src/main.rs:14. Since Cargo.toml permanently stays at version = "0.1.1", every future release binary will report 0.1.1 when users run code-scan --version, regardless of the actual git tag (e.g. v0.2.0, v1.0.0).

Root Cause

The old workflow updated Cargo.toml before building:

# OLD (removed)
- name: Update Cargo.toml
  run: sed -i 's/^version = ".*"/version = "${{ steps.bump.outputs.version }}"/' Cargo.toml
- name: Commit and tag
  run: |
    git commit ...
    git push origin main --follow-tags

The new workflow only creates and pushes a tag on the existing HEAD — Cargo.toml is never modified. The build job checks out ref: ${{ needs.create-tag.outputs.tag }} which points to the same commit where Cargo.toml still says version = "0.1.1". Clap's #[command(version)] at src/main.rs:14 reads CARGO_PKG_VERSION which is set at compile time from Cargo.toml.

Impact: Every released binary will display code-scan 0.1.1 regardless of the actual release version. Users and tooling relying on --version output will get incorrect information.

Prompt for agents
In .github/workflows/release.yml, the build job (around line 150) needs to set the correct version before running cargo build. Since you cannot push to protected main, you can override the version at build time using an environment variable. Add a step before the Build step in the build job that updates Cargo.toml in the checked-out working copy (without committing):

In the build job, before the 'Build' step (around line 151), add:

- name: Set version
  run: sed -i 's/^version = ".*"/version = "${{ needs.create-tag.outputs.version }}"/' Cargo.toml

Note: on macOS (macos-latest), sed -i requires a different syntax. Use:
  run: sed -i'' -e 's/^version = ".*"/version = "${{ needs.create-tag.outputs.version }}"/' Cargo.toml

Or use a cross-platform approach. This ensures the binary reports the correct version without needing to push changes to the protected main branch.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant