Skip to content

Commit 698b970

Browse files
committed
Update release-plan workflows. Use
kategengler/create-release-plan#kg-reusable-actions (PR'd to create-release-plan)
1 parent e0d196e commit 698b970

File tree

4 files changed

+195
-288
lines changed

4 files changed

+195
-288
lines changed

.github/workflows/plan-release.yml

Lines changed: 22 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
name: Release Plan Review
1+
name: Plan Release
22
on:
3+
workflow_dispatch:
34
push:
45
branches:
56
- main
@@ -14,75 +15,49 @@ concurrency:
1415
cancel-in-progress: true
1516

1617
jobs:
17-
check-plan:
18-
name: 'Check Release Plan'
18+
is-this-a-release:
19+
name: 'Is this a release?'
1920
runs-on: ubuntu-latest
2021
outputs:
21-
command: ${{ steps.check-release.outputs.command }}
22-
22+
is-release: ${{ steps.check-release.outputs.is-release }}
2323
steps:
24-
- uses: actions/checkout@v4
24+
- uses: kategengler/actions/release-plan/[email protected]
2525
with:
26-
fetch-depth: 0
2726
ref: 'main'
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
27+
id: check-release
3228

33-
prepare-release-notes:
34-
name: Prepare Release Notes
29+
create-prepare-release-pr:
30+
name: Create Prepare Release PR
3531
runs-on: ubuntu-latest
3632
timeout-minutes: 5
37-
needs: check-plan
33+
needs: is-this-a-release
3834
permissions:
3935
contents: write
4036
issues: read
4137
pull-requests: write
42-
outputs:
43-
explanation: ${{ steps.explanation.outputs.text }}
44-
# only run on push event if plan wasn't updated (don't create a release plan when we're releasing)
38+
# only run on push event or workflow dispatch if plan wasn't updated (don't create a release plan when we're releasing)
4539
# only run on labeled event if the PR has already been merged
46-
if: (github.event_name == 'push' && needs.check-plan.outputs.command != 'release') || (github.event_name == 'pull_request_target' && github.event.pull_request.merged == true)
47-
40+
if: >
41+
needs.is-this-a-release.outputs.is-release != 'release' &&
42+
(
43+
github.event_name == 'push' ||
44+
github.event_name == 'workflow_dispatch' ||
45+
(github.event_name == 'pull_request_target' && github.event.pull_request.merged == true)
46+
)
4847
steps:
49-
- uses: actions/checkout@v4
50-
# We need to download lots of history so that
51-
# github-changelog can discover what's changed since the last release
48+
- uses: kategengler/actions/release-plan/[email protected]
5249
with:
53-
fetch-depth: 0
5450
ref: 'main'
55-
- uses: pnpm/action-setup@v4
56-
- uses: actions/setup-node@v4
57-
with:
58-
node-version: 18
59-
cache: pnpm
60-
- run: pnpm install --frozen-lockfile
61-
- name: 'Generate Explanation and Prep Changelogs'
62-
id: explanation
63-
run: |
64-
set +e
65-
pnpm release-plan prepare 2> >(tee -a release-plan-stderr.txt >&2)
66-
67-
if [ $? -ne 0 ]; then
68-
echo 'text<<EOF' >> $GITHUB_OUTPUT
69-
cat release-plan-stderr.txt >> $GITHUB_OUTPUT
70-
echo 'EOF' >> $GITHUB_OUTPUT
71-
else
72-
echo 'text<<EOF' >> $GITHUB_OUTPUT
73-
jq .description .release-plan.json -r >> $GITHUB_OUTPUT
74-
echo 'EOF' >> $GITHUB_OUTPUT
75-
rm release-plan-stderr.txt
76-
fi
7751
env:
7852
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
53+
id: explanation
7954

8055
- uses: peter-evans/create-pull-request@v7
8156
with:
82-
commit-message: "Prepare Release using 'release-plan'"
57+
commit-message: "Prepare Release ${{ steps.explanation.outputs.new_version}} using 'release-plan'"
8358
labels: 'internal'
8459
branch: release-preview
85-
title: Prepare Release
60+
title: Prepare Release ${{ steps.explanation.outputs.new_version }}
8661
body: |
8762
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 👍
8863

.github/workflows/publish.yml

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# For every push to the master branch, this checks if the release-plan was
2-
# updated and if it was it will publish stable npm packages based on the
3-
# release plan
1+
# For every push to the primary branch with .release-plan.json modified,
2+
# runs release-plan.
43

54
name: Publish Stable
65

@@ -10,34 +9,17 @@ on:
109
branches:
1110
- main
1211
- master
12+
paths:
13+
- '.release-plan.json'
1314

1415
concurrency:
1516
group: publish-${{ github.head_ref || github.ref }}
1617
cancel-in-progress: true
1718

1819
jobs:
19-
check-plan:
20-
name: 'Check Release Plan'
21-
runs-on: ubuntu-latest
22-
outputs:
23-
command: ${{ steps.check-release.outputs.command }}
24-
25-
steps:
26-
- uses: actions/checkout@v4
27-
with:
28-
fetch-depth: 0
29-
ref: 'main'
30-
# This will only cause the `check-plan` job to have a result of `success`
31-
# when the .release-plan.json file was changed on the last commit. This
32-
# plus the fact that this action only runs on main will be enough of a guard
33-
- id: check-release
34-
run: if git diff --name-only HEAD HEAD~1 | grep -w -q ".release-plan.json"; then echo "command=release"; fi >> $GITHUB_OUTPUT
35-
3620
publish:
3721
name: 'NPM Publish'
3822
runs-on: ubuntu-latest
39-
needs: check-plan
40-
if: needs.check-plan.outputs.command == 'release'
4123
permissions:
4224
contents: write
4325
pull-requests: write
@@ -54,7 +36,7 @@ jobs:
5436
registry-url: 'https://registry.npmjs.org'
5537
cache: pnpm
5638
- run: pnpm install --frozen-lockfile
57-
- name: npm publish
39+
- name: Publish to NPM
5840
run: NPM_CONFIG_PROVENANCE=true pnpm release-plan publish
5941
env:
6042
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"mocha": "^11.0.1",
6262
"nyc": "^17.1.0",
6363
"prettier": "^3.4.2",
64-
"release-plan": "^0.11.0",
64+
"release-plan": "^0.13.1",
6565
"sinon": "^19.0.2",
6666
"tmp-sync": "^1.1.0"
6767
},

0 commit comments

Comments
 (0)