Skip to content

Commit 406cdd6

Browse files
committed
fix(ci): keep release assets immutable
Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
1 parent 39285eb commit 406cdd6

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ jobs:
285285
path: ${{ steps.artifact.outputs.filename }}
286286
retention-days: 30
287287

288-
- name: Create GitHub release
288+
- name: Create immutable GitHub release
289+
id: release
289290
if: github.event_name == 'push' || inputs.publish
290291
env:
291292
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -296,7 +297,7 @@ jobs:
296297
set -euo pipefail
297298
298299
if gh release view "$TAG" >/dev/null 2>&1; then
299-
gh release upload "$TAG" "$FILE" --clobber
300+
echo "Release $TAG already exists; reusing its immutable asset."
300301
elif [ "$IS_PRERELEASE" = "true" ]; then
301302
gh release create "$TAG" "$FILE" \
302303
--target "${{ steps.version.outputs.commit_sha }}" \
@@ -310,6 +311,11 @@ jobs:
310311
--generate-notes
311312
fi
312313
314+
rm -f "$FILE"
315+
gh release download "$TAG" --pattern "$FILE" --dir .
316+
PUBLISHED_SHA256=$(shasum -a 256 "$FILE" | awk '{print $1}')
317+
echo "sha256=$PUBLISHED_SHA256" >> "$GITHUB_OUTPUT"
318+
313319
- name: Checkout Homebrew tap
314320
if: (github.event_name == 'push' || inputs.publish) && steps.version.outputs.prerelease != 'true'
315321
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
@@ -323,7 +329,7 @@ jobs:
323329
if: (github.event_name == 'push' || inputs.publish) && steps.version.outputs.prerelease != 'true'
324330
env:
325331
VERSION: ${{ steps.version.outputs.version }}
326-
SHA256: ${{ steps.artifact.outputs.sha256 }}
332+
SHA256: ${{ steps.release.outputs.sha256 }}
327333
TAG: ${{ steps.artifact.outputs.tag }}
328334
run: |
329335
set -euo pipefail

0 commit comments

Comments
 (0)