Skip to content

Commit 15fad81

Browse files
chore(release): add release-plan (#126)
1 parent 5e9848b commit 15fad81

File tree

6 files changed

+1918
-8
lines changed

6 files changed

+1918
-8
lines changed

.github/workflows/plan-release.yml

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

.github/workflows/publish.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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
4+
5+
name: Publish Stable
6+
7+
on:
8+
workflow_dispatch:
9+
push:
10+
branches:
11+
- master
12+
13+
env:
14+
NODE_VERSION: 20
15+
16+
concurrency:
17+
group: publish-${{ github.head_ref || github.ref }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
check-plan:
22+
name: "Check Release Plan"
23+
runs-on: ubuntu-latest
24+
outputs:
25+
command: ${{ steps.check-release.outputs.command }}
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
ref: 'master'
32+
# This will only cause the `check-plan` job to have a result of `success`
33+
# when the .release-plan.json file was changed on the last commit. This
34+
# plus the fact that this action only runs on main will be enough of a guard
35+
- id: check-release
36+
run: if git diff --name-only HEAD HEAD~1 | grep -w -q ".release-plan.json"; then echo "command=release"; fi >> $GITHUB_OUTPUT
37+
38+
publish:
39+
name: "NPM Publish"
40+
runs-on: ubuntu-latest
41+
needs: check-plan
42+
if: needs.check-plan.outputs.command == 'release'
43+
permissions:
44+
contents: write
45+
pull-requests: write
46+
47+
steps:
48+
- uses: actions/checkout@v4
49+
- uses: wyvox/action-setup-pnpm@v3
50+
with:
51+
node-version: ${{ env.NODE_VERSION }}
52+
- run: pnpm install --frozen-lockfile
53+
- name: Set publishing config
54+
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
55+
env:
56+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
57+
- name: npm publish
58+
run: pnpm release-plan publish
59+
env:
60+
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
61+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/release.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
name: Release
22

33
on:
4-
push:
5-
tags:
6-
- 'v*'
7-
8-
env:
9-
VOLTA_FEATURE_PNPM: 1
4+
workflow_dispatch:
105

116
jobs:
127
release:

RELEASE.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Release Process
2+
3+
Releases are mostly automated using
4+
[release-it](https://github.com/release-it/release-it/) and
5+
[lerna-changelog](https://github.com/lerna/lerna-changelog/).
6+
7+
## Preparation
8+
9+
Since the majority of the actual release process is automated, the primary
10+
remaining task prior to releasing is confirming that all pull requests that
11+
have been merged since the last release have been labeled with the appropriate
12+
`lerna-changelog` labels and the titles have been updated to ensure they
13+
represent something that would make sense to our users. Some great information
14+
on why this is important can be found at
15+
[keepachangelog.com](https://keepachangelog.com/en/1.0.0/), but the overall
16+
guiding principle here is that changelogs are for humans, not machines.
17+
18+
When reviewing merged PR's the labels to be used are:
19+
20+
* breaking - Used when the PR is considered a breaking change.
21+
* enhancement - Used when the PR adds a new feature or enhancement.
22+
* bug - Used when the PR fixes a bug included in a previous release.
23+
* documentation - Used when the PR adds or updates documentation.
24+
* internal - Used for internal changes that still require a mention in the
25+
changelog/release notes.
26+
27+
## Release
28+
29+
Once the prep work is completed, the actual release is straight forward:
30+
31+
* First, ensure that you have installed your projects dependencies:
32+
33+
```sh
34+
pnpm install
35+
```
36+
37+
* Second, ensure that you have obtained a
38+
[GitHub personal access token][generate-token] with the `repo` scope (no
39+
other permissions are needed). Make sure the token is available as the
40+
`GITHUB_AUTH` environment variable.
41+
42+
For instance:
43+
44+
```bash
45+
export GITHUB_AUTH=abc123def456
46+
```
47+
48+
[generate-token]: https://github.com/settings/tokens/new?scopes=repo&description=GITHUB_AUTH+env+variable
49+
50+
* And last (but not least 😁) do your release.
51+
52+
```sh
53+
pnpm release
54+
```
55+
56+
[release-it](https://github.com/release-it/release-it/) manages the actual
57+
release process. It will prompt you to to choose the version number after which
58+
you will have the chance to hand tweak the changelog to be used (for the
59+
`CHANGELOG.md` and GitHub release), then `release-it` continues on to tagging,
60+
pushing the tag and commits, etc.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
"node": ">=16"
1818
},
1919
"devDependencies": {
20-
"playwright": "^1.53.0"
20+
"playwright": "^1.53.0",
21+
"lerna-changelog": "2.2.0",
22+
"release-it": "18.1.2",
23+
"release-plan": "0.11.0",
24+
"@release-it-plugins/lerna-changelog": "7.0.0"
2125
},
2226
"packageManager": "[email protected]"
2327
}

0 commit comments

Comments
 (0)