|
| 1 | +name: Release Plan Review |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + - master |
| 7 | + pull_request_target: # This workflow has permissions on the repo, do NOT run code from PRs in this workflow. See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ |
| 8 | + types: |
| 9 | + - labeled |
| 10 | + - unlabeled |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: plan-release # only the latest one of these should ever be running |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + check-plan: |
| 18 | + name: "Check Release Plan" |
| 19 | + runs-on: ubuntu-latest |
| 20 | + outputs: |
| 21 | + command: ${{ steps.check-release.outputs.command }} |
| 22 | + |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + fetch-depth: 0 |
| 27 | + ref: 'master' |
| 28 | + # This will only cause the `check-plan` job to have a "command" of `release` |
| 29 | + # when the .release-plan.json file was changed on the last commit. |
| 30 | + - id: check-release |
| 31 | + run: if git diff --name-only HEAD HEAD~1 | grep -w -q ".release-plan.json"; then echo "command=release"; fi >> $GITHUB_OUTPUT |
| 32 | + |
| 33 | + prepare_release_notes: |
| 34 | + name: Prepare Release Notes |
| 35 | + runs-on: ubuntu-latest |
| 36 | + timeout-minutes: 5 |
| 37 | + needs: check-plan |
| 38 | + permissions: |
| 39 | + contents: write |
| 40 | + pull-requests: write |
| 41 | + outputs: |
| 42 | + explanation: ${{ steps.explanation.outputs.text }} |
| 43 | + # only run on push event if plan wasn't updated (don't create a release plan when we're releasing) |
| 44 | + # only run on labeled event if the PR has already been merged |
| 45 | + if: (github.event_name == 'push' && needs.check-plan.outputs.command != 'release') || (github.event_name == 'pull_request_target' && github.event.pull_request.merged == true) |
| 46 | + |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + # We need to download lots of history so that |
| 50 | + # github-changelog can discover what's changed since the last release |
| 51 | + with: |
| 52 | + fetch-depth: 0 |
| 53 | + ref: 'master' |
| 54 | + - uses: actions/setup-node@v4 |
| 55 | + with: |
| 56 | + node-version: 18 |
| 57 | + - uses: pnpm/action-setup@v4 |
| 58 | + - run: pnpm install --frozen-lockfile |
| 59 | + - name: "Generate Explanation and Prep Changelogs" |
| 60 | + id: explanation |
| 61 | + run: | |
| 62 | + set +e |
| 63 | + pnpm release-plan prepare 2> >(tee -a release-plan-stderr.txt >&2) |
| 64 | +
|
| 65 | + if [ $? -ne 0 ]; then |
| 66 | + echo 'text<<EOF' >> $GITHUB_OUTPUT |
| 67 | + cat release-plan-stderr.txt >> $GITHUB_OUTPUT |
| 68 | + echo 'EOF' >> $GITHUB_OUTPUT |
| 69 | + else |
| 70 | + echo 'text<<EOF' >> $GITHUB_OUTPUT |
| 71 | + jq .description .release-plan.json -r >> $GITHUB_OUTPUT |
| 72 | + echo 'EOF' >> $GITHUB_OUTPUT |
| 73 | + rm release-plan-stderr.txt |
| 74 | + fi |
| 75 | + env: |
| 76 | + GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + |
| 78 | + - uses: peter-evans/create-pull-request@v6 |
| 79 | + with: |
| 80 | + commit-message: "Prepare Release using 'release-plan'" |
| 81 | + labels: "internal" |
| 82 | + branch: release-preview |
| 83 | + title: Prepare Release |
| 84 | + body: | |
| 85 | + This PR is a preview of the release that [release-plan](https://github.com/embroider-build/release-plan) has prepared. To release you should just merge this PR 👍 |
| 86 | +
|
| 87 | + ----------------------------------------- |
| 88 | +
|
| 89 | + ${{ steps.explanation.outputs.text }} |
0 commit comments