Skip to content

Commit 3fb639d

Browse files
Merge pull request #281 from ember-tooling/release-plan
Setup release-plan
2 parents 3baaba2 + 7b81bff commit 3fb639d

File tree

8 files changed

+527
-2159
lines changed

8 files changed

+527
-2159
lines changed

.github/workflows/plan-release.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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: actions/setup-node@v4
56+
with:
57+
node-version: 18
58+
- uses: pnpm/action-setup@v4
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+
echo 'text<<EOF' >> $GITHUB_OUTPUT
68+
cat release-plan-stderr.txt >> $GITHUB_OUTPUT
69+
echo 'EOF' >> $GITHUB_OUTPUT
70+
else
71+
echo 'text<<EOF' >> $GITHUB_OUTPUT
72+
jq .description .release-plan.json -r >> $GITHUB_OUTPUT
73+
echo 'EOF' >> $GITHUB_OUTPUT
74+
rm release-plan-stderr.txt
75+
fi
76+
env:
77+
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
78+
79+
- uses: peter-evans/create-pull-request@v6
80+
with:
81+
commit-message: "Prepare Release using 'release-plan'"
82+
labels: "internal"
83+
branch: release-preview
84+
title: Prepare Release
85+
body: |
86+
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 👍
87+
88+
-----------------------------------------
89+
90+
${{ steps.explanation.outputs.text }}

.github/workflows/publish.yml

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

.github/workflows/release.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ dist-ssr
3232
*.njsproj
3333
*.sln
3434
*.sw?
35+
*.yml
36+
*.yaml
37+
*.md

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

RELEASE.md

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +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 remaining task prior to releasing is confirming that all pull requests that have been merged since the last release:
7+
Since the majority of the actual release process is automated, the remaining tasks before releasing are:
108

11-
- [ ] have been labeled with the appropriate `lerna-changelog` labels (see below) and
12-
- [ ] have titles that represent something that would make sense to our users.
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
1311

14-
Some great information on why this is important can be found at [keepachangelog.com](https://keepachangelog.com/en/1.0.0/), but the overall guiding principle here is that changelogs are for humans, not machines.
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.
1514

1615
When reviewing merged PR's the labels to be used are:
1716

18-
- breaking - Used when the PR is considered a breaking change.
19-
- enhancement - Used when the PR adds a new feature or enhancement.
20-
- bug - Used when the PR fixes a bug included in a previous release.
21-
- documentation - Used when the PR adds or updates documentation.
22-
- internal - Used for internal changes that still require a mention in the changelog/release notes.
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.
2322

24-
## Release
25-
26-
### CI
27-
28-
Click "Run workflow" [here](https://github.com/gitKrystan/prettier-plugin-ember-template-tag/actions/workflows/release.yml).
29-
30-
NOTE: This is only set up for minor version bumps currently.
31-
32-
### Manual
33-
34-
- First, ensure that you have obtained a [GitHub personal access token][generate-token] with the `repo` scope (no other permissions are needed). Make sure the token is available as the `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`
3524

36-
For instance:
37-
38-
```bash
39-
export GITHUB_AUTH=abc123def456
40-
```
41-
42-
[generate-token]: https://github.com/settings/tokens/new?scopes=repo&description=GITHUB_AUTH+env+variable
43-
44-
- Then do your release. If you're nervous, try `pnpm release:debug` first.
45-
46-
```bash
47-
pnpm release
48-
```
25+
## Release
4926

50-
[release-it](https://github.com/release-it/release-it/) manages the actual release process. It will prompt you to to choose the version number after which you will have the chance to hand tweak the changelog to be used (for the `CHANGELOG.md` and GitHub release), then `release-it` continues on to tagging, pushing the tag and commits, deploying the docs, 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-tooling/prettier-plugin-ember-template-tag/pulls?q=is%3Apr+is%3Aopen+%22Prepare+Release%22+in%3Atitle) PR

package.json

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,37 @@
1010
"prettier",
1111
"template tag"
1212
],
13-
"author": {
14-
"email": "[email protected]",
15-
"name": "Krystan HuffMenne"
13+
"homepage": "https://github.com/ember-tooling/prettier-plugin-ember-template-tag",
14+
"bugs": {
15+
"url": "https://github.com/ember-tooling/prettier-plugin-ember-template-tag/issues"
1616
},
17-
"type": "module",
18-
"main": "dist/prettier-plugin-ember-template-tag.js",
19-
"license": "MIT",
2017
"repository": {
2118
"type": "git",
2219
"url": "[email protected]:ember-tooling/prettier-plugin-ember-template-tag.git"
2320
},
24-
"homepage": "https://github.com/ember-tooling/prettier-plugin-ember-template-tag",
25-
"bugs": {
26-
"url": "https://github.com/ember-tooling/prettier-plugin-ember-template-tag/issues"
27-
},
28-
"publishConfig": {
29-
"registry": "https://registry.npmjs.org"
21+
"license": "MIT",
22+
"author": {
23+
"name": "Krystan HuffMenne",
24+
"email": "[email protected]"
3025
},
26+
"type": "module",
27+
"main": "dist/prettier-plugin-ember-template-tag.js",
3128
"scripts": {
3229
"build": "tsc && vite build",
3330
"preexample": "vite build",
3431
"example": "pnpm preexample && cd examples && pnpm example",
3532
"lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\" --prefix-colors auto",
36-
"lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\" --prefix-colors auto",
3733
"lint:eslint": "eslint . --cache",
3834
"lint:eslint:fix": "eslint . --fix",
35+
"lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\" --prefix-colors auto",
3936
"lint:prettier": "prettier --check .",
4037
"lint:prettier:fix": "prettier --write .",
4138
"lint:ts": "tsc --project tsconfig.lint.json",
42-
"changelog": "release-it --changelog",
43-
"release": "release-it",
44-
"release:ci": "release-it --ci",
45-
"release:debug": "release-it --verbose --dry-run",
46-
"test:all": "concurrently \"pnpm:test:run\" \"pnpm:test:example\" --prefix-colors auto",
4739
"test": "vitest",
40+
"test:all": "concurrently \"pnpm:test:run\" \"pnpm:test:example\" --prefix-colors auto",
4841
"test:example": "pnpm preexample && cd examples && pnpm test",
49-
"test:ui": "vitest --ui",
50-
"test:run": "vitest run"
42+
"test:run": "vitest run",
43+
"test:ui": "vitest --ui"
5144
},
5245
"dependencies": {
5346
"@babel/core": "^7.23.6",
@@ -56,7 +49,6 @@
5649
},
5750
"devDependencies": {
5851
"@babel/types": "^7.23.6",
59-
"@release-it-plugins/lerna-changelog": "^6.0.0",
6052
"@tsconfig/node18": "^18.2.2",
6153
"@tsconfig/strictest": "^2.0.2",
6254
"@types/babel__core": "^7.20.5",
@@ -75,21 +67,25 @@
7567
"eslint-plugin-unicorn": "^50.0.1",
7668
"eslint-plugin-vitest": "^0.3.20",
7769
"prettier-plugin-jsdoc": "^1.3.0",
78-
"release-it": "^16.3.0",
70+
"release-plan": "^0.10.0",
7971
"typescript": "^5.3.3",
8072
"vite": "^5.0.10",
8173
"vitest": "^1.1.0"
8274
},
8375
"peerDependencies": {
8476
"prettier": ">= 3.0.0"
8577
},
78+
"packageManager": "[email protected]",
8679
"engines": {
8780
"node": "18.* || >= 20"
8881
},
8982
"volta": {
9083
"node": "18.19.0",
9184
"pnpm": "8.13.1"
9285
},
86+
"publishConfig": {
87+
"registry": "https://registry.npmjs.org"
88+
},
9389
"changelog": {
9490
"labels": {
9591
"breaking": ":boom: Breaking Change",
@@ -99,6 +95,5 @@
9995
"internal": ":house: Internal",
10096
"dependencies": ":robot: Dependencies"
10197
}
102-
},
103-
"packageManager": "[email protected]"
98+
}
10499
}

0 commit comments

Comments
 (0)