-
Notifications
You must be signed in to change notification settings - Fork 0
fix: use draft releases to support immutable release policy #429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0a99467
fix: use draft releases to support immutable release policy
Aureliolo b2697e8
fix: address 8 review findings from zizmor, Greptile, CodeRabbit, Gemini
Aureliolo f4ab916
ci: suppress zizmor dangerous-triggers for finalize-release
Aureliolo ab632ff
fix: critical workflow fixes from round 2 review
Aureliolo 1b691fd
fix: harden finalize-release security guards (CodeRabbit round 3)
Aureliolo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| name: Finalize Release | ||
|
|
||
| # Publish draft releases once both CLI and Docker workflows succeed. | ||
| # Release Please creates draft releases (immutable once published), | ||
| # then CLI (GoReleaser) and Docker (GHCR) attach assets to the draft. | ||
| # This workflow fires on each completion and publishes when both are done. | ||
|
|
||
| on: | ||
| # zizmor: ignore[dangerous-triggers] — safe: no checkout, no untrusted code | ||
| # execution; only queries workflow status via gh CLI and publishes a draft | ||
| # release. Guarded by event != 'pull_request' and startsWith(head_branch, 'v'). | ||
| workflow_run: | ||
| workflows: [Docker, CLI] | ||
| types: [completed] | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| publish: | ||
| name: Publish Draft Release | ||
| # Only process tag-triggered release builds, not PR-triggered runs. | ||
| # The event != 'pull_request' guard prevents a PR that modifies the | ||
| # Docker/CLI workflows from reaching this privileged publish step. | ||
| if: >- | ||
| github.event.workflow_run.event == 'push' | ||
| && github.event.workflow_run.head_repository.full_name == github.repository | ||
| && startsWith(github.event.workflow_run.head_branch, 'v') | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| actions: read | ||
| contents: write | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| steps: | ||
| - name: Check both workflows and publish draft | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| TAG: ${{ github.event.workflow_run.head_branch }} | ||
| HEAD_SHA: ${{ github.event.workflow_run.head_sha }} | ||
| WORKFLOW_NAME: ${{ github.event.workflow_run.name }} | ||
| WORKFLOW_CONCLUSION: ${{ github.event.workflow_run.conclusion }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| echo "Triggered by: $WORKFLOW_NAME" | ||
| echo "Tag: $TAG" | ||
| echo "Triggering run conclusion: $WORKFLOW_CONCLUSION" | ||
|
|
||
| # If the triggering workflow failed, no point checking the other | ||
| if [ "$WORKFLOW_CONCLUSION" != "success" ]; then | ||
| echo "Triggering workflow failed — skipping." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Check status of both workflows for this tag. | ||
| # gh run list --branch works for both branches and tags. | ||
| # --status completed filters out in-progress re-triggered runs. | ||
| CLI_CONCLUSION=$(gh run list --repo "$GITHUB_REPOSITORY" \ | ||
| --workflow cli.yml --branch "$TAG" --event push --commit "$HEAD_SHA" \ | ||
| --limit 1 --status completed \ | ||
| --json conclusion --jq '.[0].conclusion // "pending"') | ||
|
|
||
| DOCKER_CONCLUSION=$(gh run list --repo "$GITHUB_REPOSITORY" \ | ||
| --workflow docker.yml --branch "$TAG" --event push --commit "$HEAD_SHA" \ | ||
| --limit 1 --status completed \ | ||
| --json conclusion --jq '.[0].conclusion // "pending"') | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
|
|
||
| echo "CLI: $CLI_CONCLUSION" | ||
| echo "Docker: $DOCKER_CONCLUSION" | ||
|
|
||
| if [ "$CLI_CONCLUSION" != "success" ] || [ "$DOCKER_CONCLUSION" != "success" ]; then | ||
| echo "Not all workflows succeeded yet (CLI=$CLI_CONCLUSION, Docker=$DOCKER_CONCLUSION)." | ||
| echo "The other workflow's completion will trigger another attempt." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Both succeeded — check if release exists and is still a draft | ||
| if ! IS_DRAFT=$(gh release view "$TAG" --repo "$GITHUB_REPOSITORY" \ | ||
| --json isDraft --jq '.isDraft' 2>/dev/null); then | ||
| echo "Release $TAG not found — nothing to publish." | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [ "$IS_DRAFT" != "true" ]; then | ||
| echo "Release $TAG is not a draft (isDraft=$IS_DRAFT). Already published." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Publish the draft release (makes it immutable). | ||
| # Handle TOCTOU race: if a concurrent run published first, the second | ||
| # call may fail with 422 (immutable). Re-check and exit cleanly. | ||
| if gh release edit "$TAG" --repo "$GITHUB_REPOSITORY" --draft=false; then | ||
| echo "Release $TAG published successfully." | ||
| else | ||
| IS_DRAFT_NOW=$(gh release view "$TAG" --repo "$GITHUB_REPOSITORY" \ | ||
| --json isDraft --jq '.isDraft' 2>/dev/null || echo "unknown") | ||
| if [ "$IS_DRAFT_NOW" = "false" ]; then | ||
| echo "Release $TAG was already published by a concurrent run — OK." | ||
| else | ||
| echo "::error::Failed to publish release $TAG (isDraft=$IS_DRAFT_NOW)" | ||
| exit 1 | ||
| fi | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.