Skip to content

Commit da12d8f

Browse files
authored
Add release-plan (#73)
1 parent f2275f3 commit da12d8f

File tree

5 files changed

+1191
-5
lines changed

5 files changed

+1191
-5
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: 'master'
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: 'master'
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: '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
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 }}

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

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
{
22
"private": true,
3+
"repository": {
4+
"type": "git",
5+
"url": "https://github.com/Addepar/ember-json-viewer.git"
6+
},
37
"scripts": {
48
"preinstall": "npx only-allow pnpm"
59
},
10+
"devDependencies": {
11+
"release-plan": "^0.11.0"
12+
},
13+
"packageManager": "[email protected]+sha512.b8fef5494bd3fe4cbd4edabd0745df2ee5be3e4b0b8b08fa643aa3e4c6702ccc0f00d68fa8a8c9858a735a0032485a44990ed2810526c875e416f001b17df12b",
614
"volta": {
715
"node": "22.13.0"
8-
},
9-
"packageManager": "[email protected]+sha512.b8fef5494bd3fe4cbd4edabd0745df2ee5be3e4b0b8b08fa643aa3e4c6702ccc0f00d68fa8a8c9858a735a0032485a44990ed2810526c875e416f001b17df12b"
16+
}
1017
}

0 commit comments

Comments
 (0)