|
| 1 | +name: Release Drafter |
| 2 | + |
| 3 | +# Drafts the next release on push to main and updates CHANGELOG.md before the |
| 4 | +# release is cut; autolabels PRs so the draft is categorized. |
| 5 | +# |
| 6 | +# DISABLED until the org GitHub App is configured: every job is gated on |
| 7 | +# `vars.APP_CLIENT_ID`, so until that variable is set the job is skipped (no |
| 8 | +# runs, no failures). Once APP_CLIENT_ID (variable) and APP_PRIVATE_KEY |
| 9 | +# (secret) are set for the org/repo, it self-enables — no edit required. |
| 10 | +# |
| 11 | +# The App token is used to push the CHANGELOG commit back to main. That commit |
| 12 | +# touches only CHANGELOG.md (path-ignored by ci-go/ci-image) and carries |
| 13 | +# [skip ci], so it never triggers the image build or re-triggers this workflow. |
| 14 | + |
| 15 | +on: |
| 16 | + push: |
| 17 | + branches: [main] |
| 18 | + pull_request: |
| 19 | + types: [opened, reopened, synchronize] |
| 20 | + workflow_dispatch: |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: read |
| 24 | + |
| 25 | +concurrency: |
| 26 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 27 | + cancel-in-progress: false |
| 28 | + |
| 29 | +jobs: |
| 30 | + draft: |
| 31 | + name: Draft release and update changelog |
| 32 | + # Inert until the GitHub App is configured (see header). |
| 33 | + if: ${{ vars.APP_CLIENT_ID != '' }} |
| 34 | + runs-on: ubuntu-latest |
| 35 | + permissions: |
| 36 | + contents: write # update releases + push the changelog commit |
| 37 | + pull-requests: write # autolabeler |
| 38 | + steps: |
| 39 | + - name: Create GitHub App token |
| 40 | + id: app-token |
| 41 | + uses: actions/create-github-app-token@v3.1.1 |
| 42 | + with: |
| 43 | + client-id: ${{ vars.APP_CLIENT_ID }} |
| 44 | + private-key: ${{ secrets.APP_PRIVATE_KEY }} |
| 45 | + |
| 46 | + - name: Checkout |
| 47 | + uses: actions/checkout@v4 |
| 48 | + with: |
| 49 | + token: ${{ steps.app-token.outputs.token }} |
| 50 | + fetch-depth: 0 |
| 51 | + |
| 52 | + - name: Release Drafter |
| 53 | + id: drafter |
| 54 | + uses: release-drafter/release-drafter@v6 |
| 55 | + env: |
| 56 | + GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} |
| 57 | + |
| 58 | + - name: Update CHANGELOG |
| 59 | + if: github.event_name != 'pull_request' |
| 60 | + uses: Bugs5382/changelog-updater-action@v0.3.2 |
| 61 | + env: |
| 62 | + LOG_LEVEL: debug |
| 63 | + LOG_FORMAT: text |
| 64 | + RELEASE_NOTES: >- |
| 65 | + ${{ steps.drafter.outputs.body }} |
| 66 | + RELEASE_VERSION: v${{ steps.drafter.outputs.resolved_version }} |
| 67 | + with: |
| 68 | + tag: ${{ env.RELEASE_VERSION }} |
| 69 | + notes: ${{ env.RELEASE_NOTES }} |
| 70 | + diff: "true" |
| 71 | + |
| 72 | + - name: Commit changelog |
| 73 | + if: github.event_name != 'pull_request' |
| 74 | + uses: stefanzweifel/git-auto-commit-action@v4 |
| 75 | + with: |
| 76 | + commit_message: "chore(pre-release): v${{ steps.drafter.outputs.resolved_version }} [skip ci]" |
| 77 | + file_pattern: CHANGELOG.md |
0 commit comments