Skip to content

Commit 1dd8da1

Browse files
authored
Merge pull request #2 from ember-learn/release-plan
start using release-plan
2 parents d634931 + 4cbfef2 commit 1dd8da1

File tree

6 files changed

+1763
-7
lines changed

6 files changed

+1763
-7
lines changed

.github/workflows/plan-release.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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: pnpm/action-setup@v4
56+
- uses: actions/setup-node@v4
57+
with:
58+
node-version: 18
59+
cache: pnpm
60+
- run: pnpm install --frozen-lockfile
61+
- name: 'Generate Explanation and Prep Changelogs'
62+
id: explanation
63+
run: |
64+
set +e
65+
pnpm release-plan prepare 2> >(tee -a release-plan-stderr.txt >&2)
66+
67+
if [ $? -ne 0 ]; then
68+
echo 'text<<EOF' >> $GITHUB_OUTPUT
69+
cat release-plan-stderr.txt >> $GITHUB_OUTPUT
70+
echo 'EOF' >> $GITHUB_OUTPUT
71+
else
72+
echo 'text<<EOF' >> $GITHUB_OUTPUT
73+
jq .description .release-plan.json -r >> $GITHUB_OUTPUT
74+
echo 'EOF' >> $GITHUB_OUTPUT
75+
rm release-plan-stderr.txt
76+
fi
77+
env:
78+
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
79+
80+
- uses: peter-evans/create-pull-request@v7
81+
with:
82+
commit-message: "Prepare Release using 'release-plan'"
83+
labels: 'internal'
84+
branch: release-preview
85+
title: Prepare Release
86+
body: |
87+
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 👍
88+
89+
-----------------------------------------
90+
91+
${{ steps.explanation.outputs.text }}

.github/workflows/publish.yml

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

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

package.json

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22
"name": "ember-learn-release-tool",
33
"version": "0.0.0",
44
"description": "A tool to help the Ember Core Learning Team manage releases",
5-
"bin": "cli.js",
5+
"keywords": [],
6+
"repository": {
7+
"type": "git",
8+
"url": "[email protected]:ember-learn/ember-learn-release-tool.git"
9+
},
10+
"license": "MIT",
11+
"author": "",
612
"type": "module",
13+
"bin": "cli.js",
714
"scripts": {
815
"lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\" --prefixColors auto",
916
"lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\" --prefixColors auto",
@@ -13,22 +20,20 @@
1320
"lint:prettier:fix": "prettier --write .",
1421
"test": "echo \"Error: no test specified\" && exit 1"
1522
},
16-
"keywords": [],
17-
"author": "",
18-
"license": "MIT",
1923
"dependencies": {
2024
"commander": "^12.1.0",
2125
"enquirer": "^2.4.1",
2226
"execa": "^9.5.2",
2327
"semver": "^7.6.3",
2428
"yaml": "^2.6.1"
2529
},
26-
"packageManager": "[email protected]+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c",
2730
"devDependencies": {
2831
"@eslint/js": "^9.16.0",
2932
"concurrently": "^9.1.0",
3033
"eslint": "^9.16.0",
3134
"globals": "^15.13.0",
32-
"prettier": "^3.4.2"
33-
}
35+
"prettier": "^3.4.2",
36+
"release-plan": "^0.11.0"
37+
},
38+
"packageManager": "[email protected]+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c"
3439
}

0 commit comments

Comments
 (0)