|
| 1 | +name: Release-plz |
| 2 | + |
| 3 | +permissions: |
| 4 | + pull-requests: write |
| 5 | + contents: write |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main # create/update release PR on every push to main |
| 11 | + pull_request: |
| 12 | + types: [closed] # tag/release only when a release PR is merged |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +jobs: |
| 16 | + release-pr: |
| 17 | + name: Release PR |
| 18 | + runs-on: ubuntu-latest |
| 19 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 20 | + env: |
| 21 | + BOT_APP_ID: ${{ secrets.BOT_APP_ID }} |
| 22 | + BOT_PRIVATE_KEY: ${{ secrets.BOT_PRIVATE_KEY }} |
| 23 | + steps: |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v6 |
| 26 | + with: |
| 27 | + fetch-depth: 0 |
| 28 | + |
| 29 | + - name: Create GitHub App token |
| 30 | + id: app-token |
| 31 | + if: ${{ env.BOT_APP_ID != '' && env.BOT_PRIVATE_KEY != '' }} |
| 32 | + uses: actions/create-github-app-token@v2 |
| 33 | + with: |
| 34 | + app-id: ${{ env.BOT_APP_ID }} |
| 35 | + private-key: ${{ env.BOT_PRIVATE_KEY }} |
| 36 | + |
| 37 | + - name: Install release-plz |
| 38 | + uses: taiki-e/install-action@v2 |
| 39 | + with: |
| 40 | + tool: release-plz@0.3.149 |
| 41 | + |
| 42 | + - name: Run release-plz release-pr |
| 43 | + env: |
| 44 | + GITHUB_TOKEN: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }} |
| 45 | + run: | |
| 46 | + set -euo pipefail |
| 47 | + release-plz release-pr \ |
| 48 | + --git-token "${GITHUB_TOKEN}" \ |
| 49 | + --repo-url "https://github.com/${GITHUB_REPOSITORY}" \ |
| 50 | + --config .release-plz.toml \ |
| 51 | + -o json |
| 52 | +
|
| 53 | + release-tag: |
| 54 | + name: Tag and GitHub release |
| 55 | + runs-on: ubuntu-latest |
| 56 | + needs: [] |
| 57 | + # Run when a PR (with label 'release') is merged, or via manual dispatch |
| 58 | + if: | |
| 59 | + github.event_name == 'workflow_dispatch' || |
| 60 | + (github.event_name == 'pull_request' && |
| 61 | + github.event.pull_request.merged == true && |
| 62 | + contains(join(fromJson(toJson(github.event.pull_request.labels)).*.name, ','), 'release')) |
| 63 | + env: |
| 64 | + BOT_APP_ID: ${{ secrets.BOT_APP_ID }} |
| 65 | + BOT_PRIVATE_KEY: ${{ secrets.BOT_PRIVATE_KEY }} |
| 66 | + steps: |
| 67 | + - name: Checkout repository |
| 68 | + uses: actions/checkout@v6 |
| 69 | + with: |
| 70 | + fetch-depth: 0 |
| 71 | + |
| 72 | + - name: Create GitHub App token |
| 73 | + id: app-token |
| 74 | + if: ${{ env.BOT_APP_ID != '' && env.BOT_PRIVATE_KEY != '' }} |
| 75 | + uses: actions/create-github-app-token@v2 |
| 76 | + with: |
| 77 | + app-id: ${{ env.BOT_APP_ID }} |
| 78 | + private-key: ${{ env.BOT_PRIVATE_KEY }} |
| 79 | + |
| 80 | + - name: Install release-plz |
| 81 | + uses: taiki-e/install-action@v2 |
| 82 | + with: |
| 83 | + tool: release-plz@0.3.149 |
| 84 | + |
| 85 | + - name: Run release-plz release (tags only; GitHub release handled by binaries workflow) |
| 86 | + env: |
| 87 | + GITHUB_TOKEN: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }} |
| 88 | + run: | |
| 89 | + set -euo pipefail |
| 90 | + release-plz release \ |
| 91 | + --git-token "${GITHUB_TOKEN}" \ |
| 92 | + --repo-url "https://github.com/${GITHUB_REPOSITORY}" \ |
| 93 | + --config .release-plz.toml \ |
| 94 | + -o json |
0 commit comments