Skip to content

Commit b383e3e

Browse files
ci: serialize release creation so the upload matrix never races
Splits the tag release path in go.yml into two stages: - create-release: a single job (needs build) that ensures the GitHub release for the tag exists before any assets are uploaded, so exactly one job owns release creation. - upload-assets: the existing 5-way build matrix (needs create-release) that builds each binary plus its .sha256 and only adds files to the already existing release. This removes the concurrent-create race where all five matrix jobs tried to create the same release. It worked on action-gh-release@v2 only by luck and failed on @V3 with "already_exists (tag_name)". With creation serialized, v3 is safe to adopt. Preserves the same 5 platform targets, asset names, 10 total assets (5 binaries plus 5 .sha256), checksum generation, GITHUB_TOKEN usage, and contents: write only on the release stages. Still on @v2 in this commit; the @V3 bump lands separately after validation. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 2c5e980 commit b383e3e

1 file changed

Lines changed: 26 additions & 10 deletions

File tree

‎.github/workflows/go.yml‎

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,27 @@ jobs:
4545
with:
4646
version: latest
4747

48-
release:
48+
# Single job that owns release creation. It runs once (not a matrix), so
49+
# exactly one job ever creates the release for the tag. The upload-assets
50+
# matrix below then only adds files to this already-existing release and can
51+
# never race to create it (the race that made action-gh-release v3 fail with
52+
# "already_exists (tag_name)").
53+
create-release:
4954
needs: build
5055
if: startsWith(github.ref, 'refs/tags/v')
56+
runs-on: ubuntu-latest
57+
permissions:
58+
contents: write
59+
60+
steps:
61+
- name: Ensure release exists for tag
62+
uses: softprops/action-gh-release@v2
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
66+
upload-assets:
67+
needs: create-release
68+
if: startsWith(github.ref, 'refs/tags/v')
5169
permissions:
5270
contents: write
5371

@@ -113,20 +131,18 @@ jobs:
113131
cp ${{ matrix.artifact_name }} ${{ matrix.asset_name }}
114132
fi
115133
116-
- name: Upload binaries to release
117-
uses: softprops/action-gh-release@v2
118-
with:
119-
files: ${{ matrix.asset_name }}
120-
env:
121-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
122-
123134
- name: Generate checksum
124135
shell: bash
125136
run: sha256sum ${{ matrix.asset_name }} > ${{ matrix.asset_name }}.sha256
126137

127-
- name: Upload checksum to release
138+
# The release already exists (created by create-release), so each matrix leg
139+
# only adds its binary and checksum. No matrix job creates the release, which
140+
# avoids the concurrent-create race entirely.
141+
- name: Upload assets to release
128142
uses: softprops/action-gh-release@v2
129143
with:
130-
files: ${{ matrix.asset_name }}.sha256
144+
files: |
145+
${{ matrix.asset_name }}
146+
${{ matrix.asset_name }}.sha256
131147
env:
132148
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)