Skip to content

Commit 4dcffa9

Browse files
authored
Merge pull request #546 from ember-codemods/release-plan
start using release-plan
2 parents 776295f + 3f6371e commit 4dcffa9

File tree

6 files changed

+436
-2103
lines changed

6 files changed

+436
-2103
lines changed

.github/workflows/plan-release.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Release Plan Review
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- master
7+
pull_request:
8+
types:
9+
- labeled
10+
11+
concurrency:
12+
group: plan-release # only the latest one of these should ever be running
13+
cancel-in-progress: true
14+
15+
jobs:
16+
check-plan:
17+
name: 'Check Release Plan'
18+
runs-on: ubuntu-latest
19+
outputs:
20+
command: ${{ steps.check-release.outputs.command }}
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
ref: 'main'
27+
# This will only cause the `check-plan` job to have a "command" of `release`
28+
# when the .release-plan.json file was changed on the last commit.
29+
- id: check-release
30+
run: if git diff --name-only HEAD HEAD~1 | grep -w -q ".release-plan.json"; then echo "command=release"; fi >> $GITHUB_OUTPUT
31+
32+
prepare_release_notes:
33+
name: Prepare Release Notes
34+
runs-on: ubuntu-latest
35+
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)
40+
# 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)
42+
43+
steps:
44+
- uses: actions/checkout@v4
45+
# We need to download lots of history so that
46+
# lerna-changelog can discover what's changed since the last release
47+
with:
48+
fetch-depth: 0
49+
- uses: actions/setup-node@v4
50+
with:
51+
node-version: 18
52+
53+
- uses: pnpm/action-setup@v2
54+
with:
55+
version: 8
56+
- run: pnpm install --frozen-lockfile
57+
58+
- name: 'Generate Explanation and Prep Changelogs'
59+
id: explanation
60+
run: |
61+
set -x
62+
63+
pnpm release-plan prepare
64+
65+
echo 'text<<EOF' >> $GITHUB_OUTPUT
66+
jq .description .release-plan.json -r >> $GITHUB_OUTPUT
67+
echo 'EOF' >> $GITHUB_OUTPUT
68+
env:
69+
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
70+
71+
- uses: peter-evans/create-pull-request@v5
72+
with:
73+
commit-message: "Prepare Release using 'release-plan'"
74+
author: 'github-actions[bot] <github-actions-bot@users.noreply.github.com>'
75+
labels: 'internal'
76+
branch: release-preview
77+
title: Prepare Release
78+
body: |
79+
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+
81+
-----------------------------------------
82+
83+
${{ steps.explanation.outputs.text }}

.github/workflows/publish.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
42+
steps:
43+
- uses: actions/checkout@v4
44+
- uses: actions/setup-node@v4
45+
with:
46+
node-version: 18
47+
# This creates an .npmrc that reads the NODE_AUTH_TOKEN environment variable
48+
registry-url: 'https://registry.npmjs.org'
49+
50+
- uses: pnpm/action-setup@v2
51+
with:
52+
version: 8
53+
- run: pnpm install --frozen-lockfile
54+
- name: npm publish
55+
run: pnpm release-plan publish
56+
57+
env:
58+
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
59+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

RELEASE.md

Lines changed: 11 additions & 44 deletions
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 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-
pnpm 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/ember-codemods/ember-native-class-codemod/pulls?q=is%3Apr+is%3Aopen+%22Prepare+Release%22+in%3Atitle) PR

package.json

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
"/transforms/ember-object/index.js"
3131
],
3232
"scripts": {
33-
"release": "release-it",
34-
"prepublishOnly": "pnpm build",
35-
"postpublish": "pnpm clean",
3633
"build": "tsc",
3734
"clean": "tsc --build --clean && git checkout test/fixtures",
3835
"lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"",
@@ -42,6 +39,8 @@
4239
"lint:prettier": "prettier --check .",
4340
"lint:prettier:fix": "prettier --write .",
4441
"lint:ts": "tsc --noEmit",
42+
"prepublishOnly": "pnpm build",
43+
"postpublish": "pnpm clean",
4544
"test": "pnpm build && codemod-cli test && node ./test/run-test.js && pnpm clean",
4645
"update-docs": "codemod-cli update-docs"
4746
},
@@ -62,7 +61,6 @@
6261
"@babel/eslint-parser": "^7.21.3",
6362
"@babel/preset-env": "^7.21.4",
6463
"@jest/globals": "^29.5.0",
65-
"@release-it-plugins/lerna-changelog": "^5.0.0",
6664
"@tsconfig/node12": "^1.0.11",
6765
"@types/babel__core": "^7.20.5",
6866
"@types/glob": "^8.1.0",
@@ -81,7 +79,7 @@
8179
"glob": "^8.1.0",
8280
"jest": "^29.5.0",
8381
"prettier": "^2.8.8",
84-
"release-it": "^15.10.1",
82+
"release-plan": "^0.5.0",
8583
"ts-jest": "^29.1.0",
8684
"typescript": "^5.0.4"
8785
},
@@ -90,23 +88,5 @@
9088
},
9189
"publishConfig": {
9290
"registry": "https://registry.npmjs.org"
93-
},
94-
"release-it": {
95-
"hooks": {
96-
"after:bump": "pnpm update-docs"
97-
},
98-
"plugins": {
99-
"@release-it-plugins/lerna-changelog": {
100-
"infile": "CHANGELOG.md",
101-
"launchEditor": true
102-
}
103-
},
104-
"git": {
105-
"tagName": "v${version}"
106-
},
107-
"github": {
108-
"release": true,
109-
"tokenRef": "GITHUB_AUTH"
110-
}
11191
}
11292
}

0 commit comments

Comments
 (0)