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