Repository navigation
feat: add Tag release workflow wrapping the releaser #31321
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
Closed
+485
−46
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
00bbd26
feat: add Tag release workflow wrapping the releaser
f0ssel cabfcd8
feat: run Tag release only from release/X.Y and document it
f0ssel 313c184
docs: format release overrides table
f0ssel f47ec0c
fix(scripts/releaser): fail closed on GitHub query errors in non-inte…
f0ssel ee0095c
fix(scripts/releaser): fail when release note metadata is unavailable…
f0ssel 619644b
fix(scripts/releaser): fail when the docs PR cannot be created in non…
f0ssel 578fae2
feat: attribute Tag release dispatches to the requesting user
f0ssel 1a8e66a
ci: drop requested_by from the release run title
f0ssel 5e5001a
ci: always mint the release App token in check-perms
f0ssel fbf95d3
chore: move release.yaml and release docs changes to a follow-up PR
f0ssel 04dc407
Merge remote-tracking branch 'origin/main' into f0ssel/releaser-tag-r…
f0ssel 17d7bf1
ci: bump harden-runner pin in tag-release.yaml
f0ssel 7b27ca0
ci: accept Tag release dispatches from the release App in release.yaml
f0ssel 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
Some comments aren't visible on the classic Files Changed page.
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,160 @@ | ||
| # Runs the release wizard (scripts/releaser) unattended on the release/X.Y | ||
| # branch selected in "Use workflow from". It accepts the default answer to | ||
| # every prompt, tags the release, pushes the tag, triggers release.yaml, and | ||
| # opens the release docs PR. | ||
| # | ||
| # Release candidates are tagged on main, which this workflow does not run on. | ||
| # Use ./scripts/release.sh locally for those. | ||
| # | ||
| # Safety checks that default to "no" (open PRs, downgrades, breaking changes | ||
| # in a patch release, and so on) fail the run. To release anyway with open | ||
| # PRs against the release branch or breaking changes in a patch release, | ||
| # re-run with allow_open_prs or allow_breaking_changes enabled. For any other | ||
| # check, run ./scripts/release.sh locally. | ||
| name: Tag release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| dry_run: | ||
| description: Print the tag, push, and workflow trigger instead of running them. | ||
| type: boolean | ||
| required: true | ||
| default: true | ||
| allow_open_prs: | ||
| description: Continue when open PRs target the release branch. | ||
| type: boolean | ||
| required: true | ||
| default: false | ||
| allow_breaking_changes: | ||
| description: Continue when a patch release contains breaking changes. | ||
| type: boolean | ||
| required: true | ||
| default: false | ||
|
|
||
| permissions: {} | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| # Only allow maintainers/admins to release. | ||
| check-perms: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Allow only maintainers/admins | ||
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const {data} = await github.rest.repos.getCollaboratorPermissionLevel({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| username: context.actor | ||
| }); | ||
| const role = data.role_name || data.user?.role_name || data.permission; | ||
| const perms = data.user?.permissions || {}; | ||
| core.info(`Actor ${context.actor} permission=${data.permission}, role_name=${role}`); | ||
|
|
||
| const allowed = | ||
| role === 'admin' || | ||
| role === 'maintain' || | ||
| perms.admin === true || | ||
| perms.maintain === true; | ||
|
|
||
| if (!allowed) core.setFailed('Denied: requires maintain or admin'); | ||
|
|
||
| tag-release: | ||
| name: Tag and trigger release | ||
| needs: [check-perms] | ||
| runs-on: ubuntu-latest | ||
| # The release App token performs every write, so the job token stays | ||
| # read-only. | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Harden Runner | ||
| uses: step-security/harden-runner@dc2769abcc0fcfbadfc1df54081c1608579ef6b2 # v2.22.2 | ||
| with: | ||
| egress-policy: audit | ||
|
|
||
| - name: Require a release branch | ||
| env: | ||
| REF: ${{ github.ref }} | ||
| run: | | ||
| set -euo pipefail | ||
| if [[ ! "$REF" =~ ^refs/heads/release/[0-9]+\.[0-9]+$ ]]; then | ||
| echo "::error::Select a release/X.Y branch in \"Use workflow from\", got: $REF" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Checkout | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| # The releaser needs every tag to pick the next version and the full | ||
| # history to generate release notes. | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up mise tools | ||
| uses: ./.github/actions/setup-mise | ||
| with: | ||
| install-args: "go" | ||
|
|
||
| # The release App bypasses the tag create protection ruleset, which | ||
| # GITHUB_TOKEN cannot. It needs contents: write to push the tag and the | ||
| # docs branch, actions: write to dispatch release.yaml, and | ||
| # pull-requests: write to open the docs PR. | ||
| - name: Generate release App token | ||
| id: release_app_token | ||
| uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 | ||
| with: | ||
| app-id: ${{ secrets.RELEASE_APP_ID }} | ||
| private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} | ||
|
|
||
| - name: Run releaser | ||
| env: | ||
| GH_TOKEN: ${{ steps.release_app_token.outputs.token }} | ||
| APP_SLUG: ${{ steps.release_app_token.outputs.app-slug }} | ||
| DRY_RUN: ${{ inputs.dry_run }} | ||
| ALLOW_OPEN_PRS: ${{ inputs.allow_open_prs }} | ||
| ALLOW_BREAKING_CHANGES: ${{ inputs.allow_breaking_changes }} | ||
| # A bot pushes the tag, so record the human who started this run in | ||
| # the tag message. | ||
| REQUESTED_BY: ${{ github.actor }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | ||
| bot_login="${APP_SLUG}[bot]" | ||
| bot_id="$(gh api "/users/${bot_login}" --jq .id)" | ||
| git config user.name "$bot_login" | ||
| git config user.email "${bot_id}+${bot_login}@users.noreply.github.com" | ||
|
|
||
| args=( | ||
| --non-interactive | ||
| --requested-by "$REQUESTED_BY" | ||
| --requested-by-run-url "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | ||
| ) | ||
| if [[ "$DRY_RUN" == "true" ]]; then | ||
| args+=(--dry-run) | ||
| fi | ||
| if [[ "$ALLOW_OPEN_PRS" == "true" ]]; then | ||
| args+=(--allow-open-prs) | ||
| fi | ||
| if [[ "$ALLOW_BREAKING_CHANGES" == "true" ]]; then | ||
| args+=(--allow-breaking-changes) | ||
| fi | ||
| go run ./scripts/releaser "${args[@]}" | ||
|
f0ssel marked this conversation as resolved.
Resolved
|
||
|
|
||
| - name: Upload release notes | ||
| if: ${{ !cancelled() }} | ||
| uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 | ||
| with: | ||
| name: release-notes | ||
| path: build/RELEASE-*.md | ||
| if-no-files-found: ignore | ||
| retention-days: 7 | ||
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@f0ssel what do you think about taking the release branch as a
workflow_dispatchinput instead, so the workflow always runs from main? That way, we don't have to keep all branches in sync (which has bitten us before), at least when it comes to the tooling responsible for the release process.We could use a
worktreeto interact with the release branch, or we could simply tag origin/release/X.Y directly after a full fetch. Thoughts?