|
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 | + 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 | 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 |
37 | | - outputs: |
38 | | - explanation: ${{ steps.explanation.outputs.text }} |
39 | | - # only run on push event if plan wasn't updated (don't create a release plan when we're releasing) |
| 38 | + needs: is-this-a-release |
| 39 | + permissions: |
| 40 | + contents: write |
| 41 | + issues: read |
| 42 | + pull-requests: write |
| 43 | + # only run on push event or workflow dispatch if plan wasn't updated (don't create a release plan when we're releasing) |
40 | 44 | # only run on labeled event if the PR has already been merged |
41 | | - 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) |
42 | 46 |
|
43 | 47 | steps: |
44 | 48 | - uses: actions/checkout@v4 |
45 | 49 | # We need to download lots of history so that |
46 | | - # lerna-changelog can discover what's changed since the last release |
| 50 | + # github-changelog can discover what's changed since the last release |
47 | 51 | with: |
48 | 52 | fetch-depth: 0 |
| 53 | + ref: 'main' |
| 54 | + - uses: pnpm/action-setup@v4 |
49 | 55 | - uses: actions/setup-node@v4 |
50 | 56 | with: |
51 | 57 | node-version: 18 |
52 | | - |
53 | | - - uses: pnpm/action-setup@v2 |
54 | | - with: |
55 | | - version: 8 |
| 58 | + cache: pnpm |
56 | 59 | - run: pnpm install --frozen-lockfile |
57 | | - |
58 | 60 | - name: "Generate Explanation and Prep Changelogs" |
59 | 61 | id: explanation |
60 | 62 | run: | |
61 | | - set -x |
| 63 | + set +e |
| 64 | + pnpm release-plan prepare 2> >(tee -a release-plan-stderr.txt >&2) |
62 | 65 |
|
63 | | - pnpm release-plan prepare --singlePackage=ember-inspector |
| 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 |
64 | 71 |
|
65 | | - echo 'text<<EOF' >> $GITHUB_OUTPUT |
66 | | - jq .description .release-plan.json -r >> $GITHUB_OUTPUT |
67 | | - echo 'EOF' >> $GITHUB_OUTPUT |
| 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 |
68 | 80 | env: |
69 | 81 | GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }} |
70 | 82 |
|
71 | | - - uses: peter-evans/create-pull-request@v5 |
| 83 | + - uses: peter-evans/create-pull-request@v7 |
72 | 84 | with: |
73 | | - commit-message: "Prepare Release using 'release-plan'" |
74 | | - author: "github-actions[bot] <[email protected]>" |
| 85 | + commit-message: "Prepare Release ${{ steps.explanation.outputs.new_version}} using 'release-plan'" |
75 | 86 | labels: "internal" |
76 | 87 | branch: release-preview |
77 | | - title: Prepare Release |
| 88 | + title: Prepare Release ${{ steps.explanation.outputs.new_version }} |
78 | 89 | body: | |
79 | 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 👍 |
80 | 91 |
|
|
0 commit comments