Skip to content

Commit 368c09f

Browse files
committed
fix: prevent race conditions in release workflow
- Add concurrency control to prevent multiple simultaneous release runs - Move tag creation AFTER commit to ensure tags point to correct commits - Reorder steps: bump version → commit → tag → push (correct order) This prevents the critical race condition where tags pointed to commits with the wrong version (e.g., tag v0.1.4 pointing to commit with v0.1.3).
1 parent a3e0fc7 commit 368c09f

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

.github/workflows/release.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ permissions:
99

1010
jobs:
1111
release:
12+
concurrency:
13+
group: release
14+
cancel-in-progress: false
15+
1216
runs-on: ubuntu-latest
1317
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip release]')"
1418

@@ -76,15 +80,24 @@ jobs:
7680
7781
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
7882
79-
- name: Create annotated tag (atomic operation)
80-
id: create_tag
83+
- name: Commit version bump
84+
id: commit
8185
run: |
82-
TAG="v${{ steps.bump_version.outputs.new_version }}"
83-
84-
# Create an annotated tag with the bump type and new version
8586
git config user.name "github-actions[bot]"
8687
git config user.email "github-actions[bot]@users.noreply.github.com"
8788
89+
git add pyproject.toml
90+
git commit -m "chore: bump version to ${{ steps.bump_version.outputs.new_version }} [skip ci]"
91+
92+
# Get the commit SHA for tagging
93+
COMMIT_SHA=$(git rev-parse HEAD)
94+
echo "commit_sha=$COMMIT_SHA" >> $GITHUB_OUTPUT
95+
96+
- name: Create annotated tag
97+
id: create_tag
98+
run: |
99+
TAG="v${{ steps.bump_version.outputs.new_version }}"
100+
88101
git tag -a "$TAG" \
89102
-m "Release $TAG" \
90103
-m "Bump type: ${{ steps.bump_type.outputs.bump_type }}" \
@@ -95,12 +108,7 @@ jobs:
95108
96109
- name: Push version bump and tag
97110
run: |
98-
# Push the updated pyproject.toml file
99-
git add pyproject.toml
100-
git commit --allow-empty -m "chore: bump version to ${{ steps.bump_version.outputs.new_version }} [skip ci]"
101111
git push
102-
103-
# Push the tag (this triggers publish-pypi.yml)
104112
git push origin "${{ steps.create_tag.outputs.tag }}"
105113
106114
- name: Create GitHub Release

0 commit comments

Comments
 (0)