Skip to content

Commit 7f8d90a

Browse files
committed
fix: 3-stage release workflow to eliminate race condition
1 parent f839caf commit 7f8d90a

1 file changed

Lines changed: 24 additions & 16 deletions

File tree

.github/workflows/release.yml

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,15 @@ permissions:
99
contents: write
1010

1111
jobs:
12-
# ── Stage 1: create the GitHub Release once ──────────────────────────────
1312
create-release:
1413
name: Create GitHub Release
1514
runs-on: ubuntu-latest
16-
outputs:
17-
upload_url: ${{ steps.create.outputs.upload_url }}
1815
steps:
1916
- name: Create release
20-
id: create
2117
uses: softprops/action-gh-release@v2
2218
with:
23-
generate_release_notes: true
24-
draft: false
19+
generate_release_notes: false
2520

26-
# ── Stage 2: build each platform and upload its asset ────────────────────
2721
build:
2822
name: Build ${{ matrix.suffix }}
2923
needs: create-release
@@ -63,27 +57,41 @@ jobs:
6357
GOARCH: ${{ matrix.goarch }}
6458
CGO_ENABLED: "0"
6559
run: |
66-
VERSION="${GITHUB_REF_NAME}"
6760
go build \
68-
-ldflags="-s -w -X main.version=${VERSION}" \
61+
-ldflags="-s -w -X main.version=${GITHUB_REF_NAME}" \
6962
-o "termf1${{ matrix.ext }}" .
7063
7164
- name: Package archive
7265
id: archive
7366
run: |
74-
VERSION="${GITHUB_REF_NAME}"
75-
BINARY="termf1${{ matrix.ext }}"
76-
ARCHIVE="termf1-${VERSION}-${{ matrix.suffix }}"
67+
ARCHIVE="termf1-${GITHUB_REF_NAME}-${{ matrix.suffix }}"
7768
if [ "${{ matrix.goos }}" = "windows" ]; then
78-
zip "${ARCHIVE}.zip" "${BINARY}" README.md .env.example
69+
zip "${ARCHIVE}.zip" "termf1${{ matrix.ext }}" README.md .env.example
7970
echo "asset=${ARCHIVE}.zip" >> "$GITHUB_OUTPUT"
8071
else
81-
tar czf "${ARCHIVE}.tar.gz" "${BINARY}" README.md .env.example
72+
tar czf "${ARCHIVE}.tar.gz" "termf1${{ matrix.ext }}" README.md .env.example
8273
echo "asset=${ARCHIVE}.tar.gz" >> "$GITHUB_OUTPUT"
8374
fi
8475
85-
- name: Upload asset
76+
- name: Store artifact
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: ${{ steps.archive.outputs.asset }}
80+
path: ${{ steps.archive.outputs.asset }}
81+
82+
upload:
83+
name: Upload release assets
84+
needs: build
85+
runs-on: ubuntu-latest
86+
steps:
87+
- name: Download all artifacts
88+
uses: actions/download-artifact@v4
89+
with:
90+
path: dist
91+
merge-multiple: true
92+
93+
- name: Upload all assets
8694
uses: softprops/action-gh-release@v2
8795
with:
88-
files: ${{ steps.archive.outputs.asset }}
96+
files: dist/*
8997
generate_release_notes: false

0 commit comments

Comments
 (0)