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