Skip to content

Commit ad27237

Browse files
committed
Add release-plan
1 parent 8ae9751 commit ad27237

File tree

6 files changed

+635
-73
lines changed

6 files changed

+635
-73
lines changed

.github/workflows/plan-release.yml

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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: "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
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+
issues: read
41+
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)
45+
# 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+
48+
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
52+
with:
53+
fetch-depth: 0
54+
ref: "main"
55+
- uses: pnpm/action-setup@v4
56+
with:
57+
version: 9
58+
- uses: actions/setup-node@v4
59+
with:
60+
node-version: 18
61+
cache: pnpm
62+
- run: pnpm install --frozen-lockfile
63+
- name: "Generate Explanation and Prep Changelogs"
64+
id: explanation
65+
run: |
66+
set +e
67+
pnpm release-plan prepare 2> >(tee -a release-plan-stderr.txt >&2)
68+
69+
if [ $? -ne 0 ]; then
70+
echo 'text<<EOF' >> $GITHUB_OUTPUT
71+
cat release-plan-stderr.txt >> $GITHUB_OUTPUT
72+
echo 'EOF' >> $GITHUB_OUTPUT
73+
else
74+
echo 'text<<EOF' >> $GITHUB_OUTPUT
75+
jq .description .release-plan.json -r >> $GITHUB_OUTPUT
76+
echo 'EOF' >> $GITHUB_OUTPUT
77+
rm release-plan-stderr.txt
78+
fi
79+
env:
80+
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
81+
82+
- uses: peter-evans/create-pull-request@v7
83+
with:
84+
commit-message: "Prepare Release using 'release-plan'"
85+
labels: "internal"
86+
branch: release-preview
87+
title: Prepare Release
88+
body: |
89+
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 👍
90+
91+
-----------------------------------------
92+
93+
${{ steps.explanation.outputs.text }}

.github/workflows/publish.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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: "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+
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+
id-token: write
45+
attestations: write
46+
47+
steps:
48+
- uses: actions/checkout@v4
49+
- uses: pnpm/action-setup@v4
50+
with:
51+
version: 9
52+
- uses: actions/setup-node@v4
53+
with:
54+
node-version: 18
55+
# This creates an .npmrc that reads the NODE_AUTH_TOKEN environment variable
56+
registry-url: "https://registry.npmjs.org"
57+
cache: pnpm
58+
- run: pnpm install --frozen-lockfile
59+
- name: npm publish
60+
run: NPM_CONFIG_PROVENANCE=true pnpm release-plan publish
61+
env:
62+
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
63+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

CHANGELOG.md

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Changelog
2+
13
## v2.0.0-beta.1 (2022-05-12)
24

35
### Changes
@@ -15,7 +17,6 @@ for an example.
1517

1618
Introduce deprecation warning for some GA behaviour (https://github.com/adopted-ember-addons/ember-metrics/pull/444)
1719

18-
1920
## v1.5.1 (2022-05-12)
2021

2122
### Changes
@@ -38,8 +39,6 @@ Many thanks to our contributors:
3839
- @VincentHardouin
3940
- @GabrielCousin
4041

41-
42-
4342
## v1.4.1 (2021-11-22)
4443

4544
#### Changes
@@ -50,7 +49,6 @@ Many thanks to our contributors:
5049

5150
Thank you to @gilest for catching this bug. D'oh!
5251

53-
5452
## v1.4.0 (2021-11-21)
5553

5654
This will be the last release in the v1 series. See below for notes on the
@@ -75,15 +73,13 @@ forthcoming v2 release.
7573

7674
A hearty thank you to all contributors. The following people contributed to this release:
7775

78-
* @GreatWizard
79-
* @jfdnc
80-
* @Windvis
81-
76+
- @GreatWizard
77+
- @jfdnc
78+
- @Windvis
8279

8380
## v1.3.1 (2021-09-26)
8481

85-
* Resolves duplicate GTM script injection (#291, #292)
86-
82+
- Resolves duplicate GTM script injection (#291, #292)
8783

8884
## v1.3.0 (2021-09-14)
8985

RELEASE.md

+15-48
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,27 @@
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
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
7+
Since the majority of the actual release process is automated, the remaining tasks before releasing are:
288

29-
Once the prep work is completed, the actual release is straight forward:
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
3011

31-
* First, ensure that you have installed your projects dependencies:
32-
33-
```sh
34-
yarn 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:
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
13+
guiding principle here is that changelogs are for humans, not machines.
4314

44-
```bash
45-
export GITHUB_AUTH=abc123def456
46-
```
15+
When reviewing merged PR's the labels to be used are:
4716

48-
[generate-token]: https://github.com/settings/tokens/new?scopes=repo&description=GITHUB_AUTH+env+variable
17+
- breaking - Used when the PR is considered a breaking change.
18+
- enhancement - Used when the PR adds a new feature or enhancement.
19+
- bug - Used when the PR fixes a bug included in a previous release.
20+
- documentation - Used when the PR adds or updates documentation.
21+
- internal - Internal changes or things that don't fit in any other category.
4922

50-
* And last (but not least 😁) do your release.
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`
5124

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/adopted-ember-addons/ember-metrics/pulls?q=is%3Apr+is%3Aopen+%22Prepare+Release%22+in%3Atitle) PR

package.json

+16-15
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
},
3030
"scripts": {
3131
"build": "ember build --environment=production",
32+
"contributors": "npx contributor-faces -e \"(*-bot|*\\[bot\\]|*-tomster|homu|bors)\"",
3233
"doc": "typedoc",
3334
"lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"",
3435
"lint:css": "stylelint \"**/*.css\"",
@@ -37,15 +38,17 @@
3738
"lint:hbs:fix": "ember-template-lint . --fix",
3839
"lint:js": "eslint . --cache",
3940
"lint:js:fix": "eslint . --fix",
41+
"prepack": "ember ts:precompile",
42+
"postpack": "ember ts:clean",
43+
"prepare": "husky install",
4044
"start": "ember serve",
4145
"test": "concurrently \"npm:lint\" \"npm:test:*\" --names \"lint,test:\"",
42-
"test:ember": "ember test",
43-
"test:ember-compatibility": "ember try:each",
4446
"test:all": "ember try:each",
45-
"contributors": "npx contributor-faces -e \"(*-bot|*\\[bot\\]|*-tomster|homu|bors)\"",
46-
"prepack": "ember ts:precompile",
47-
"postpack": "ember ts:clean",
48-
"prepare": "husky install"
47+
"test:ember": "ember test",
48+
"test:ember-compatibility": "ember try:each"
49+
},
50+
"lint-staged": {
51+
"*.js": "eslint --cache --fix"
4952
},
5053
"dependencies": {
5154
"broccoli-funnel": "^3.0.2",
@@ -116,6 +119,7 @@
116119
"qunit-sinon-assertions": "^1.0.0",
117120
"release-it": "^15.4.1",
118121
"release-it-lerna-changelog": "^5.0.0",
122+
"release-plan": "^0.13.1",
119123
"stylelint": "^15.4.0",
120124
"stylelint-config-standard": "^32.0.0",
121125
"stylelint-prettier": "^3.0.0",
@@ -127,18 +131,18 @@
127131
"@ember/string": ">= 3.0.0",
128132
"ember-source": ">= 3.28.0"
129133
},
130-
"pnpm": {
131-
"overrides": {
132-
"@babel/plugin-transform-modules-amd": "7.16.5",
133-
"@ember/string": "^4.0.0"
134-
}
135-
},
136134
"engines": {
137135
"node": "18.* || 20.* || >= 22"
138136
},
139137
"publishConfig": {
140138
"registry": "https://registry.npmjs.org"
141139
},
140+
"pnpm": {
141+
"overrides": {
142+
"@babel/plugin-transform-modules-amd": "7.16.5",
143+
"@ember/string": "^4.0.0"
144+
}
145+
},
142146
"ember": {
143147
"edition": "octane"
144148
},
@@ -159,8 +163,5 @@
159163
"release": true,
160164
"tokenRef": "GITHUB_AUTH"
161165
}
162-
},
163-
"lint-staged": {
164-
"*.js": "eslint --cache --fix"
165166
}
166167
}

0 commit comments

Comments
 (0)