Skip to content

Commit 87e039b

Browse files
committed
setup release-plan
1 parent 827308d commit 87e039b

6 files changed

Lines changed: 1578 additions & 2078 deletions

File tree

.github/workflows/plan-release.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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: 'master'
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+
- run: npm ci
54+
55+
- name: "Generate Explanation and Prep Changelogs"
56+
id: explanation
57+
run: |
58+
set -x
59+
60+
npx release-plan prepare --single-pacakge=ember-angle-brackets-codemod
61+
62+
echo 'text<<EOF' >> $GITHUB_OUTPUT
63+
jq .description .release-plan.json -r >> $GITHUB_OUTPUT
64+
echo 'EOF' >> $GITHUB_OUTPUT
65+
env:
66+
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
67+
68+
- uses: peter-evans/create-pull-request@v5
69+
with:
70+
commit-message: "Prepare Release using 'release-plan'"
71+
author: "github-actions[bot] <[email protected]>"
72+
labels: "internal"
73+
branch: release-preview
74+
title: Prepare Release
75+
body: |
76+
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 👍
77+
78+
-----------------------------------------
79+
80+
${{ steps.explanation.outputs.text }}

.github/workflows/publish.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
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+
- run: npm ci
51+
- name: npm publish
52+
run: npx release-plan publish
53+
54+
env:
55+
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
56+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Changelog
2+
13
Version 9 of Highlight.js has reached EOL and is no longer supported.
24
Please upgrade or ask whatever dependency you are using to upgrade.
35
https://github.com/highlightjs/highlight.js/issues/2877

RELEASE.md

Lines changed: 11 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
# Release
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/).
1+
# Release Process
62

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.
74

85
## Preparation
96

10-
Since the majority of the actual release process is automated, the primary
11-
remaining task prior to releasing is confirming that all pull requests that
12-
have been merged since the last release have been labeled with the appropriate
13-
`lerna-changelog` labels and the titles have been updated to ensure they
14-
represent something that would make sense to our users. Some great information
15-
on why this is important can be found at
16-
[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
1713
guiding principle here is that changelogs are for humans, not machines.
1814

1915
When reviewing merged PR's the labels to be used are:
@@ -22,46 +18,10 @@ When reviewing merged PR's the labels to be used are:
2218
* enhancement - Used when the PR adds a new feature or enhancement.
2319
* bug - Used when the PR fixes a bug included in a previous release.
2420
* documentation - Used when the PR adds or updates documentation.
25-
* internal - Used for internal changes that still require a mention in the
26-
changelog/release notes.
21+
* internal - Internal changes or things that don't fit in any other category.
2722

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`
2824

2925
## Release
3026

31-
Once the prep work is completed, the actual release is straight forward:
32-
33-
* First ensure that you have `release-it` installed globally, generally done by
34-
using one of the following commands:
35-
36-
```
37-
# using https://volta.sh
38-
volta install release-it
39-
40-
# using Yarn
41-
yarn global add release-it
42-
43-
# using npm
44-
npm install --global release-it
45-
```
46-
47-
* Second, ensure that you have installed your projects dependencies:
48-
49-
```
50-
yarn install
51-
```
52-
53-
* And last (but not least 😁) do your release. It requires a
54-
[GitHub personal access token](https://github.com/settings/tokens) as
55-
`$GITHUB_AUTH` environment variable. Only "repo" access is needed; no "admin"
56-
or other scopes are required.
57-
58-
```
59-
export GITHUB_AUTH="f941e0..."
60-
release-it
61-
```
62-
63-
[release-it](https://github.com/release-it/release-it/) manages the actual
64-
release process. It will prompt you to to choose the version number after which
65-
you will have the chance to hand tweak the changelog to be used (for the
66-
`CHANGELOG.md` and GitHub release), then `release-it` continues on to tagging,
67-
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-angle-brackets-codemod/pulls?q=is%3Apr+is%3Aopen+%22Prepare+Release%22+in%3Atitle) PR

package.json

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"debug:integration": "node --inspect-brk ./test/run-test.js",
2525
"debug:test": "node --inspect-brk ./node_modules/.bin/jest -i -t ",
2626
"lint": "eslint . --cache",
27-
"release": "release-it",
2827
"test": "codemod-cli test --coverage",
2928
"test:integration": "node ./test/run-test.js",
3029
"test:notelemetry": " node ./test/run-test-without-telemetry.js"
@@ -49,28 +48,12 @@
4948
"execa": "^5.0.0",
5049
"jest": "^28.1.3",
5150
"prettier": "^2.7.1",
52-
"release-it": "^15.3.0",
53-
"release-it-lerna-changelog": "^5.0.0"
51+
"release-plan": "^0.4.1"
5452
},
5553
"engines": {
5654
"node": "16.* || 18.* || >=20.*"
5755
},
5856
"publishConfig": {
5957
"registry": "https://registry.npmjs.org"
60-
},
61-
"release-it": {
62-
"plugins": {
63-
"release-it-lerna-changelog": {
64-
"infile": "CHANGELOG.md",
65-
"launchEditor": true
66-
}
67-
},
68-
"git": {
69-
"tagName": "v${version}"
70-
},
71-
"github": {
72-
"release": true,
73-
"tokenRef": "GITHUB_AUTH"
74-
}
7558
}
7659
}

0 commit comments

Comments
 (0)