Skip to content

Commit e5b62da

Browse files
authored
Merge pull request #280 from ember-cli/setup-release-plan
Setup release plan
2 parents 503d249 + c6804cb commit e5b62da

5 files changed

Lines changed: 353 additions & 1300 deletions

File tree

.github/workflows/plan-release.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
permissions:
38+
contents: write
39+
pull-requests: write
40+
outputs:
41+
explanation: ${{ steps.explanation.outputs.text }}
42+
# only run on push event if plan wasn't updated (don't create a release plan when we're releasing)
43+
# only run on labeled event if the PR has already been merged
44+
if: (github.event_name == 'push' && needs.check-plan.outputs.command != 'release') || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
# We need to download lots of history so that
49+
# lerna-changelog can discover what's changed since the last release
50+
with:
51+
fetch-depth: 0
52+
- uses: wyvox/action-setup-pnpm@v3
53+
54+
- name: "Generate Explanation and Prep Changelogs"
55+
id: explanation
56+
run: |
57+
set -x
58+
59+
pnpm release-plan prepare
60+
61+
echo 'text<<EOF' >> $GITHUB_OUTPUT
62+
jq .description .release-plan.json -r >> $GITHUB_OUTPUT
63+
echo 'EOF' >> $GITHUB_OUTPUT
64+
env:
65+
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
66+
67+
- uses: peter-evans/create-pull-request@v5
68+
with:
69+
commit-message: "Prepare Release using 'release-plan'"
70+
author: "github-actions[bot] <[email protected]>"
71+
labels: "internal"
72+
branch: release-preview
73+
title: Prepare Release
74+
body: |
75+
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 👍
76+
77+
-----------------------------------------
78+
79+
${{ steps.explanation.outputs.text }}

.github/workflows/publish.yml

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,57 @@
1-
name: Publish
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
26

37
on:
4-
push:
5-
tags:
6-
- 'v*'
7-
# Manual run
88
workflow_dispatch:
9-
inputs:
10-
tag:
11-
required: true
12-
type: string
13-
description: 'Tag to release'
9+
push:
10+
branches:
11+
- main
12+
- master
13+
14+
concurrency:
15+
group: publish-${{ github.head_ref || github.ref }}
16+
cancel-in-progress: true
1417

1518
jobs:
16-
release:
17-
name: release
19+
check-plan:
20+
name: "Check Release Plan"
1821
runs-on: ubuntu-latest
22+
outputs:
23+
command: ${{ steps.check-release.outputs.command }}
1924

2025
steps:
2126
- uses: actions/checkout@v4
2227
with:
23-
ref: ${{ github.event.inputs.tag || github.ref_name }}
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
2435

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
2547
- uses: wyvox/action-setup-pnpm@v3
2648
with:
49+
# This creates an .npmrc that reads the NODE_AUTH_TOKEN environment variable
2750
node-registry-url: 'https://registry.npmjs.org'
28-
args: '--no-frozen-lockfile'
29-
- run: git diff
30-
name: 'Did pnpm cause a diff?'
31-
32-
- run: pnpm publish --no-git-checks
33-
working-directory: './addon/'
51+
52+
- name: npm publish
53+
run: pnpm release-plan publish
54+
3455
env:
35-
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
56+
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
57+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

RELEASE.md

Lines changed: 11 additions & 48 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,44 +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:
32-
33-
```sh
34-
pnpm install
35-
```
21+
* internal - Internal changes or things that don't fit in any other category.
3622

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.
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`
4124

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-
```
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.
25+
## Release
6126

62-
Once the tag has been pushed, the GitHub workflow `publish.yml` will be triggered
63-
to publish the package(s) to npm. This workflow does not wait for tests to pass, so
64-
be sure to only run `release-it` on a passing build.
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-cli/ember-page-title/pulls?q=is%3Apr+is%3Aopen+%22Prepare+Release%22+in%3Atitle) PR

package.json

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
{
2+
"version": "8.2.0",
23
"private": true,
34
"repository": {
45
"type": "git",
56
"url": "[email protected]:ember-cli/ember-page-title.git"
67
},
78
"scripts": {
8-
"prepare": "pnpm build",
99
"build": "pnpm --filter 'ember-page-title' build",
1010
"lint": "pnpm --filter '*' lint",
1111
"lint:fix": "pnpm --filter '*' lint:fix",
12+
"prepare": "pnpm build",
1213
"test": "pnpm --filter '*' test"
1314
},
1415
"devDependencies": {
15-
"@release-it-plugins/lerna-changelog": "^6.0.0",
16-
"@release-it-plugins/workspaces": "^4.0.0",
17-
"release-it": "^16.1.5"
16+
"release-plan": "^0.6.0"
1817
},
1918
"volta": {
2019
"node": "20.10.0",
@@ -23,26 +22,6 @@
2322
"publishConfig": {
2423
"registry": "https://registry.npmjs.org"
2524
},
26-
"release-it": {
27-
"plugins": {
28-
"@release-it-plugins/workspaces": {
29-
"publish": false
30-
},
31-
"@release-it-plugins/lerna-changelog": {
32-
"infile": "CHANGELOG.md",
33-
"launchEditor": true
34-
}
35-
},
36-
"git": {
37-
"tagName": "v${version}"
38-
},
39-
"npm": false,
40-
"github": {
41-
"release": true,
42-
"tokenRef": "GITHUB_AUTH"
43-
}
44-
},
45-
"version": "8.2.0",
4625
"pnpm": {
4726
"patchedDependencies": {
4827

0 commit comments

Comments
 (0)