release: v0.99.0 #5
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
| name: Release Please | |
| # TEST BRANCH ONLY (test/repro-release-422): trimmed to reproduce the release/v* | |
| # branch-creation 422 (SLK-130224). The Tag release, label removal and release-please | |
| # jobs are stripped so no v* tag is created (which would trigger release.yaml/mkdocs). | |
| # Do not merge this workflow variant. | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - 'release/v*' | |
| - 'test/repro-release-422' | |
| jobs: | |
| release-tag: | |
| runs-on: ubuntu-latest | |
| # Skip the branch-creation push (created == true) to avoid re-running on the duplicate tag. | |
| if: ${{ startsWith(github.event.head_commit.message, 'release:') && !github.event.created }} | |
| steps: | |
| - name: Extract version from commit message | |
| id: extract_info | |
| shell: bash | |
| env: | |
| COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | |
| run: | | |
| # Take only the first line to avoid git trailers (e.g. Co-authored-by) breaking $GITHUB_OUTPUT | |
| FIRST_LINE=${COMMIT_MESSAGE%%$'\n'*} | |
| echo "version=$( echo "$FIRST_LINE" | sed 's/^release: v\([0-9]\+\.[0-9]\+\.[0-9]\+\).*$/\1/' )" >> $GITHUB_OUTPUT | |
| echo "release_branch=release/v$( echo "$FIRST_LINE" | sed 's/^release: v\([0-9]\+\.[0-9]\+\).*$/\1/' )" >> $GITHUB_OUTPUT | |
| - name: Generate token | |
| id: app-token | |
| if: ${{ steps.extract_info.outputs.version }} | |
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | |
| with: | |
| client-id: ${{ secrets.REPO_TRIVY_WRITE_GH_APP_CLIENT_ID }} | |
| private-key: ${{ secrets.REPO_TRIVY_WRITE_GH_APP_PRIVATE_KEY }} | |
| permission-contents: write | |
| # When v0.50.0 is released, a release branch "release/v0.50" is created. | |
| - name: Create release branch for patch versions | |
| if: ${{ endsWith(steps.extract_info.outputs.version, '.0') }} | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| env: | |
| RELEASE_BRANCH: ${{ steps.extract_info.outputs.release_branch }} | |
| with: | |
| # GITHUB_TOKEN cannot be a ruleset bypass actor; use the App token to bypass the merge queue rule. | |
| github-token: ${{ steps.app-token.outputs.token }} | |
| script: | | |
| const releaseBranch = process.env.RELEASE_BRANCH; | |
| await github.rest.git.createRef({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| ref: `refs/heads/${releaseBranch}`, | |
| sha: context.sha | |
| }); |