Skip to content

Commit 7d0ea54

Browse files
authored
Merge pull request #443 from NullVoxPopuli/release-plan
npx create-release-plan-setup@latest --update
2 parents 16a5a0e + e64d371 commit 7d0ea54

File tree

6 files changed

+1561
-50
lines changed

6 files changed

+1561
-50
lines changed

.github/workflows/plan-release.yml

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

.github/workflows/publish.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
- main
12+
- master
13+
14+
concurrency:
15+
group: publish-${{ github.head_ref || github.ref }}
16+
cancel-in-progress: true
17+
18+
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: 'master'
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+
36+
publish:
37+
name: "NPM Publish"
38+
runs-on: ubuntu-latest
39+
needs: check-plan
40+
if: needs.check-plan.outputs.command == 'release'
41+
permissions:
42+
contents: write
43+
pull-requests: write
44+
45+
steps:
46+
- uses: actions/checkout@v4
47+
- uses: actions/setup-node@v4
48+
with:
49+
node-version: 18
50+
# This creates an .npmrc that reads the NODE_AUTH_TOKEN environment variable
51+
registry-url: 'https://registry.npmjs.org'
52+
53+
- uses: pnpm/action-setup@v3
54+
with:
55+
version: 8
56+
- run: pnpm install --frozen-lockfile
57+
- name: npm publish
58+
run: pnpm release-plan publish
59+
60+
env:
61+
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
62+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Changelog
2+
13

24

35

RELEASE.md

+11-44
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
# Release Process
22

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/).
3+
Releases in this repo are mostly automated using [release-plan](https://github.com/embroider-build/release-plan/). Once you label all your PRs correctly (see below) you will have an automatically generated PR that updates your CHANGELOG.md file and a `.release-plan.json` that is used to prepare the release once the PR is merged.
64

75
## Preparation
86

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
7+
Since the majority of the actual release process is automated, the remaining tasks before releasing are:
8+
9+
- correctly labeling **all** pull requests that have been merged since the last release
10+
- updating pull request titles so they make sense to our users
11+
12+
Some great information on why this is important can be found at [keepachangelog.com](https://keepachangelog.com/en/1.1.0/), but the overall
1613
guiding principle here is that changelogs are for humans, not machines.
1714

1815
When reviewing merged PR's the labels to be used are:
@@ -21,40 +18,10 @@ When reviewing merged PR's the labels to be used are:
2118
* enhancement - Used when the PR adds a new feature or enhancement.
2219
* bug - Used when the PR fixes a bug included in a previous release.
2320
* 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:
21+
* internal - Internal changes or things that don't fit in any other category.
3222

33-
```sh
34-
yarn install
35-
```
23+
**Note:** `release-plan` requires that **all** PRs are labeled. If a PR doesn't fit in a category it's fine to label it as `internal`
3624

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-
npx release-it
54-
```
25+
## Release
5526

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.
27+
Once the prep work is completed, the actual release is straight forward: you just need to merge the open [Plan Release](https://github.com/emberjs/ember-string/pulls?q=is%3Apr+is%3Aopen+%22Prepare+Release%22+in%3Atitle) PR

package.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"name": "@ember/string",
33
"version": "3.1.1",
44
"description": "A set of utilities to transform strings",
5-
"type": "module",
65
"repository": "https://github.com/emberjs/ember-string",
76
"license": "MIT",
87
"author": "",
8+
"type": "module",
99
"exports": {
1010
".": {
1111
"types": "./declarations/index.d.ts",
@@ -32,10 +32,10 @@
3232
"lint:js:fix": "eslint . --fix",
3333
"lint:package": "publint",
3434
"lint:published-types": "pnpm pack; attw; rm *.tgz",
35+
"prepack": "pnpm build",
3536
"start": "vite build --watch",
3637
"test": "cd tests && pnpm test",
37-
"test:types": "tsc --noEmit --emitDeclarationOnly false",
38-
"prepack": "pnpm build"
38+
"test:types": "tsc --noEmit --emitDeclarationOnly false"
3939
},
4040
"devDependencies": {
4141
"@arethetypeswrong/cli": "^0.15.0",
@@ -53,15 +53,16 @@
5353
"expect-type": "^0.18.0",
5454
"prettier": "^3.1.1",
5555
"publint": "^0.2.7",
56+
"release-plan": "^0.9.0",
5657
"typescript": "^5.3.3",
5758
"vite": "^5.3.2",
5859
"vite-plugin-dts": "^3.9.1"
5960
},
60-
"publishConfig": {
61-
"registry": "https://registry.npmjs.org"
62-
},
6361
"volta": {
6462
"node": "20.11.1",
6563
"pnpm": "9.4.0"
64+
},
65+
"publishConfig": {
66+
"registry": "https://registry.npmjs.org"
6667
}
6768
}

0 commit comments

Comments
 (0)