|
| 1 | +# Triggers when release-please PR is merged to release/candidate. |
| 2 | +# Creates the final release/v{version} branch and deletes the candidate branch. |
| 3 | +name: "Release: Finalize" |
| 4 | + |
| 5 | +on: |
| 6 | + pull_request: |
| 7 | + types: [closed] |
| 8 | + branches: |
| 9 | + - release/candidate |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + pull-requests: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + finalize: |
| 17 | + if: github.event.pull_request.merged == true |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - name: Check for release-please PR |
| 21 | + id: check |
| 22 | + env: |
| 23 | + LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }} |
| 24 | + run: | |
| 25 | + if echo "$LABELS" | grep -q "autorelease: pending"; then |
| 26 | + echo "is_release_pr=true" >> $GITHUB_OUTPUT |
| 27 | + else |
| 28 | + echo "Not a release-please PR, skipping" |
| 29 | + echo "is_release_pr=false" >> $GITHUB_OUTPUT |
| 30 | + fi |
| 31 | +
|
| 32 | + - uses: actions/checkout@v4 |
| 33 | + if: steps.check.outputs.is_release_pr == 'true' |
| 34 | + with: |
| 35 | + ref: release/candidate |
| 36 | + |
| 37 | + - name: Extract version from manifest |
| 38 | + if: steps.check.outputs.is_release_pr == 'true' |
| 39 | + id: version |
| 40 | + run: | |
| 41 | + VERSION=$(jq -r '.["."]' .github/.release-please-manifest.json) |
| 42 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 43 | + echo "Extracted version: $VERSION" |
| 44 | +
|
| 45 | + - name: Create release branch |
| 46 | + if: steps.check.outputs.is_release_pr == 'true' |
| 47 | + run: | |
| 48 | + git checkout -b "release/v${{ steps.version.outputs.version }}" |
| 49 | + git push origin "release/v${{ steps.version.outputs.version }}" |
| 50 | + echo "Created branch: release/v${{ steps.version.outputs.version }}" |
| 51 | +
|
| 52 | + - name: Delete release/candidate branch |
| 53 | + if: steps.check.outputs.is_release_pr == 'true' |
| 54 | + run: | |
| 55 | + git push origin --delete release/candidate |
| 56 | + echo "Deleted branch: release/candidate" |
| 57 | +
|
| 58 | + - name: Update PR label to tagged |
| 59 | + if: steps.check.outputs.is_release_pr == 'true' |
| 60 | + env: |
| 61 | + GH_TOKEN: ${{ github.token }} |
| 62 | + run: | |
| 63 | + gh pr edit ${{ github.event.pull_request.number }} \ |
| 64 | + --remove-label "autorelease: pending" \ |
| 65 | + --add-label "autorelease: tagged" |
| 66 | + echo "Updated PR label to autorelease: tagged" |
0 commit comments