Skip to content

Commit 5fe6301

Browse files
authored
Merge pull request #1270 from ember-cli/release-plan
swap to release-plan
2 parents 9132ba0 + 1ac463f commit 5fe6301

File tree

6 files changed

+672
-1834
lines changed

6 files changed

+672
-1834
lines changed

.github/workflows/plan-release.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Plan Release
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
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/
9+
types:
10+
- labeled
11+
- unlabeled
12+
13+
concurrency:
14+
group: plan-release # only the latest one of these should ever be running
15+
cancel-in-progress: true
16+
17+
jobs:
18+
is-this-a-release:
19+
name: 'Is this a release?'
20+
runs-on: ubuntu-latest
21+
outputs:
22+
command: ${{ steps.check-release.outputs.command }}
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 2
28+
ref: 'master'
29+
# This will only cause the `is-this-a-release` job to have a "command" of `release`
30+
# when the .release-plan.json file was changed on the last commit.
31+
- id: check-release
32+
run: if git diff --name-only HEAD HEAD~1 | grep -w -q ".release-plan.json"; then echo "command=release"; fi >> $GITHUB_OUTPUT
33+
34+
create-prepare-release-pr:
35+
name: Create Prepare Release PR
36+
runs-on: ubuntu-latest
37+
timeout-minutes: 5
38+
needs: is-this-a-release
39+
permissions:
40+
contents: write
41+
issues: read
42+
pull-requests: write
43+
# only run on push event or workflow dispatch 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' || github.event_name == 'workflow_dispatch') && needs.is-this-a-release.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: pnpm/action-setup@v4
55+
- uses: actions/setup-node@v4
56+
with:
57+
node-version: 18
58+
cache: pnpm
59+
- run: pnpm install --frozen-lockfile
60+
- name: 'Generate Explanation and Prep Changelogs'
61+
id: explanation
62+
run: |
63+
set +e
64+
pnpm release-plan prepare 2> >(tee -a release-plan-stderr.txt >&2)
65+
66+
if [ $? -ne 0 ]; then
67+
release_plan_output=$(cat release-plan-stderr.txt)
68+
else
69+
release_plan_output=$(jq .description .release-plan.json -r)
70+
rm release-plan-stderr.txt
71+
72+
if [ $(jq '.solution | length' .release-plan.json) -eq 1 ]; then
73+
new_version=$(jq -r '.solution[].newVersion' .release-plan.json)
74+
echo "new_version=v$new_version" >> $GITHUB_OUTPUT
75+
fi
76+
fi
77+
echo 'text<<EOF' >> $GITHUB_OUTPUT
78+
echo "$release_plan_output" >> $GITHUB_OUTPUT
79+
echo 'EOF' >> $GITHUB_OUTPUT
80+
env:
81+
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
82+
83+
- uses: peter-evans/create-pull-request@v7
84+
with:
85+
commit-message: "Prepare Release ${{ steps.explanation.outputs.new_version}} using 'release-plan'"
86+
labels: 'internal'
87+
branch: release-preview
88+
title: Prepare Release ${{ steps.explanation.outputs.new_version }}
89+
body: |
90+
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 👍
91+
92+
-----------------------------------------
93+
94+
${{ steps.explanation.outputs.text }}

.github/workflows/publish.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,43 @@
1-
name: Publish
1+
# For every push to the primary branch with .release-plan.json modified,
2+
# runs release-plan.
3+
4+
name: Publish Stable
25

36
on:
7+
workflow_dispatch:
48
push:
5-
tags: v[0-9]+.[0-9]+.[0-9]+
9+
branches:
10+
- main
11+
- master
12+
paths:
13+
- '.release-plan.json'
14+
15+
concurrency:
16+
group: publish-${{ github.head_ref || github.ref }}
17+
cancel-in-progress: true
618

719
jobs:
8-
build:
20+
publish:
21+
name: 'NPM Publish'
922
runs-on: ubuntu-latest
23+
permissions:
24+
contents: write
25+
pull-requests: write
26+
id-token: write
27+
attestations: write
1028

1129
steps:
1230
- uses: actions/checkout@v4
31+
- uses: pnpm/action-setup@v4
1332
- uses: actions/setup-node@v4
1433
with:
1534
node-version: 20
35+
# This creates an .npmrc that reads the NODE_AUTH_TOKEN environment variable
1636
registry-url: 'https://registry.npmjs.org'
17-
18-
- run: npm publish
37+
cache: pnpm
38+
- run: pnpm install --frozen-lockfile
39+
- name: Publish to NPM
40+
run: NPM_CONFIG_PROVENANCE=true pnpm release-plan publish
1941
env:
42+
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
2043
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

24

35
## v2.0.1 (2023-09-28)

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

package.json

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
},
5353
"devDependencies": {
5454
"@kellyselden/node-template": "3.0.0",
55-
"@release-it-plugins/lerna-changelog": "^5.0.0",
5655
"chai": "^4.3.6",
5756
"chai-as-promised": "^7.1.1",
5857
"chai-fs": "^2.0.0",
@@ -68,33 +67,15 @@
6867
"mocha": "^10.0.0",
6968
"mocha-helpers": "^6.2.1",
7069
"prettier": "^3.6.2",
71-
"release-it": "^15.5.0",
70+
"release-plan": "^0.17.2",
7271
"renovate-config-standard": "2.1.2",
7372
"sinon": "^14.0.0",
7473
"sinon-chai": "^3.7.0",
7574
"standard-node-template": "3.0.0",
7675
"yargs-help-output": "^2.0.0"
7776
},
77+
"packageManager": "[email protected]+sha512.34e538c329b5553014ca8e8f4535997f96180a1d0f614339357449935350d924e22f8614682191264ec33d1462ac21561aff97f6bb18065351c162c7e8f6de67",
7878
"engines": {
7979
"node": ">=20"
80-
},
81-
"release-it": {
82-
"plugins": {
83-
"@release-it-plugins/lerna-changelog": {
84-
"infile": "CHANGELOG.md",
85-
"launchEditor": true
86-
}
87-
},
88-
"git": {
89-
"tagName": "v${version}"
90-
},
91-
"github": {
92-
"release": true,
93-
"tokenRef": "GITHUB_AUTH"
94-
},
95-
"npm": {
96-
"publish": false
97-
}
98-
},
99-
"packageManager": "[email protected]+sha512.34e538c329b5553014ca8e8f4535997f96180a1d0f614339357449935350d924e22f8614682191264ec33d1462ac21561aff97f6bb18065351c162c7e8f6de67"
80+
}
10081
}

0 commit comments

Comments
 (0)