Skip to content

Commit af47e0b

Browse files
fix: address PR #32 review comments
- Use github.event.before SHA instead of HEAD~1 for reliable version diff across multi-commit pushes and merges. - Use fetch-depth: 0 to ensure full history is available. - Check remote tags via git ls-remote before creating, and handle concurrent tag creation gracefully. - Fix misleading comment about cargo check updating Cargo.lock. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e171514 commit af47e0b

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

.claude/commands/release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Once confirmed:
2828

2929
1. Fetch origin and create a branch: `release/vX.Y.Z` from `origin/main`.
3030
2. Bump version in `Cargo.toml` (the `version = "..."` field under `[package]`).
31-
3. Run `cargo check` to update `Cargo.lock`.
31+
3. Run `cargo check` to ensure the project builds successfully after the version bump.
3232
4. Update `CHANGELOG.md`:
3333
- Move everything under `## [Unreleased]` into a new `## [X.Y.Z] - YYYY-MM-DD` section (use today's date).
3434
- Leave `## [Unreleased]` empty (with just the heading).

.github/workflows/auto-tag.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v4
1414
with:
15-
fetch-depth: 2
15+
fetch-depth: 0
1616
- name: Check for version bump
1717
id: version
1818
run: |
1919
CURRENT=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
20-
PREVIOUS=$(git show HEAD~1:Cargo.toml | grep '^version' | head -1 | sed 's/.*"\(.*\)"/\1/')
20+
PREVIOUS=$(git show ${{ github.event.before }}:Cargo.toml | grep '^version' | head -1 | sed 's/.*"\(.*\)"/\1/')
2121
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
2222
echo "previous=$PREVIOUS" >> "$GITHUB_OUTPUT"
2323
if [ "$CURRENT" != "$PREVIOUS" ]; then
@@ -30,11 +30,22 @@ jobs:
3030
run: |
3131
VERSION="${{ steps.version.outputs.current }}"
3232
TAG="v${VERSION}"
33+
if git ls-remote --tags origin "refs/tags/$TAG" | grep -q .; then
34+
echo "Tag $TAG already exists on origin, skipping"
35+
exit 0
36+
fi
3337
if git rev-parse "$TAG" >/dev/null 2>&1; then
34-
echo "Tag $TAG already exists, skipping"
38+
echo "Tag $TAG already exists locally, skipping"
3539
exit 0
3640
fi
3741
git tag "$TAG"
38-
git push origin "$TAG"
42+
if ! git push origin "$TAG"; then
43+
if git ls-remote --tags origin "refs/tags/$TAG" | grep -q .; then
44+
echo "Tag $TAG was created concurrently on origin, skipping"
45+
exit 0
46+
fi
47+
echo "Failed to push tag $TAG"
48+
exit 1
49+
fi
3950
env:
4051
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)