Skip to content

Commit 67a6607

Browse files
Merge pull request #831 from typed-ember/nvp/release-plan
Setup release-plan for releases
2 parents 0633362 + 778e440 commit 67a6607

File tree

8 files changed

+600
-1585
lines changed

8 files changed

+600
-1585
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: 'main'
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: 'main'
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: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# For every push to the primary branch with .release-plan.json modified,
2+
# runs release-plan.
3+
4+
name: Publish Stable
5+
6+
on:
7+
workflow_dispatch:
8+
push:
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
18+
19+
jobs:
20+
publish:
21+
name: "NPM Publish"
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: write
25+
pull-requests: write
26+
id-token: write
27+
attestations: write
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: pnpm/action-setup@v4
32+
- uses: actions/setup-node@v4
33+
with:
34+
node-version: 18
35+
# This creates an .npmrc that reads the NODE_AUTH_TOKEN environment variable
36+
registry-url: 'https://registry.npmjs.org'
37+
cache: pnpm
38+
- run: pnpm install --frozen-lockfile
39+
- name: Publish to NPM
40+
run: NPM_CONFIG_PROVENANCE=true pnpm release-plan publish
41+
env:
42+
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
43+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.release-it.yml

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

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Changelog

RELEASE.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Release Process
2+
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.
4+
5+
## Preparation
6+
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
13+
guiding principle here is that changelogs are for humans, not machines.
14+
15+
When reviewing merged PR's the labels to be used are:
16+
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.
22+
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`
24+
25+
## Release
26+
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/typed-ember/glint/pulls?q=is%3Apr+is%3Aopen+%22Prepare+Release%22+in%3Atitle) PR

package.json

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "glint",
3-
"repository": "https://github.com/typed-ember/glint",
3+
"version": "1.4.0",
44
"private": true,
5+
"repository": "https://github.com/typed-ember/glint",
56
"workspaces": {
67
"packages": [
78
"packages/*",
@@ -14,27 +15,34 @@
1415
]
1516
},
1617
"scripts": {
17-
"reset": "git clean -Xfd; git clean -fd; pnpm i && pnpm build > /dev/null 2>&1; pnpm i -f; pnpm build; pnpm sync",
18+
"build": "tsc --build",
19+
"build:watch": "tsc --build --watch",
20+
"format": "prettier --write .",
1821
"lint": "pnpm lint:scripts && pnpm lint:formatting",
1922
"lint:fix": "pnpm lint:scripts --fix && pnpm format",
20-
"format": "prettier --write .",
21-
"lint:scripts": "pnpm eslint --cache .",
2223
"lint:formatting": "pnpm prettier --check .",
23-
"test": "pnpm --filter '*' run test",
24-
"test:typecheck": "pnpm --filter '*' run test:typecheck",
25-
"build": "tsc --build",
26-
"build:watch": "tsc --build --watch",
24+
"lint:scripts": "pnpm eslint --cache .",
25+
"reset": "git clean -Xfd; git clean -fd; pnpm i && pnpm build > /dev/null 2>&1; pnpm i -f; pnpm build; pnpm sync",
2726
"sync": "echo 'Syncing injected peer dependencies (via built in pnpm behavior defined in .npmrc)'",
28-
"release-it": "echo \"Running release-it via pnpm breaks publishing! Use npx or a Volta global installation.\""
27+
"test": "pnpm --filter '*' run test",
28+
"test:typecheck": "pnpm --filter '*' run test:typecheck"
2929
},
30+
"devDependencies": {
31+
"@glimmer/component": "^2.0.0",
32+
"@glint/tsserver-plugin": "workspace:*",
33+
"@typescript-eslint/eslint-plugin": "^5.42.1",
34+
"@typescript-eslint/parser": "^5.42.1",
35+
"eslint": "^8.27.0",
36+
"glint-monorepo-test-utils": "workspace:*",
37+
"prettier": "^3.3.2",
38+
"release-plan": "^0.16.0",
39+
"typescript": ">=5.6.0"
40+
},
41+
"packageManager": "[email protected]",
3042
"volta": {
3143
"node": "18.20.3",
3244
"pnpm": "10.6.2"
3345
},
34-
"packageManager": "[email protected]",
35-
"devDependencies:notes": {
36-
"typescript": "bumped version because volar caused error TS2694, TS1383"
37-
},
3846
"pnpm": {
3947
"peerDependencyRules": {
4048
"ignoreMissing": [
@@ -45,23 +53,12 @@
4553
]
4654
}
4755
},
48-
"devDependencies": {
49-
"@release-it-plugins/lerna-changelog": "^5.0.0",
50-
"@release-it-plugins/workspaces": "^3.2.0",
51-
"@glimmer/component": "^2.0.0",
52-
"@glint/tsserver-plugin": "workspace:*",
53-
"glint-monorepo-test-utils": "workspace:*",
54-
"@typescript-eslint/eslint-plugin": "^5.42.1",
55-
"@typescript-eslint/parser": "^5.42.1",
56-
"eslint": "^8.27.0",
57-
"prettier": "^3.3.2",
58-
"release-it": "^15.5.0",
59-
"typescript": ">=5.6.0"
56+
"devDependencies:notes": {
57+
"typescript": "bumped version because volar caused error TS2694, TS1383"
6058
},
6159
"resolutions:notes": {
6260
"@glimmer/validator": "Newer versions of @glimmer/* are ESM-only, and Glint is compiled to CJS, so newer versions of @glimmer/* are not compatible",
6361
"@types/yargs": "Locking temporarily to avoid an issue with the ESM types in 17.0.14; see DT#63373",
6462
"@types/node": "Locking to avoid conflicts between the declared version in packages/core and floating '*' versions when we run in CI without the lockfile"
65-
},
66-
"version": "1.4.0"
63+
}
6764
}

packages/vscode/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
"engines": {
4242
"vscode": "^1.68.1"
4343
},
44+
"release-plan": {
45+
"skipNpmPublish": true
46+
},
4447
"activationEvents": [],
4548
"contributes": {
4649
"languages": [

0 commit comments

Comments
 (0)