Skip to content

Commit e5c1fed

Browse files
authored
Merge pull request #416 from ember-codemods/release-plan
setup release-plan
2 parents 8ea74f7 + 4b7d49a commit e5c1fed

File tree

6 files changed

+765
-1614
lines changed

6 files changed

+765
-1614
lines changed

.github/workflows/plan-release.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Release Plan Review
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- master
7+
pull_request:
8+
types:
9+
- labeled
10+
11+
concurrency:
12+
group: plan-release # only the latest one of these should ever be running
13+
cancel-in-progress: true
14+
15+
jobs:
16+
check-plan:
17+
name: "Check Release Plan"
18+
runs-on: ubuntu-latest
19+
outputs:
20+
command: ${{ steps.check-release.outputs.command }}
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
ref: 'main'
27+
# This will only cause the `check-plan` job to have a "command" of `release`
28+
# when the .release-plan.json file was changed on the last commit.
29+
- id: check-release
30+
run: if git diff --name-only HEAD HEAD~1 | grep -w -q ".release-plan.json"; then echo "command=release"; fi >> $GITHUB_OUTPUT
31+
32+
prepare_release_notes:
33+
name: Prepare Release Notes
34+
runs-on: ubuntu-latest
35+
timeout-minutes: 5
36+
needs: check-plan
37+
permissions:
38+
contents: write
39+
pull-requests: write
40+
outputs:
41+
explanation: ${{ steps.explanation.outputs.text }}
42+
# only run on push event if plan wasn't updated (don't create a release plan when we're releasing)
43+
# only run on labeled event if the PR has already been merged
44+
if: (github.event_name == 'push' && needs.check-plan.outputs.command != 'release') || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
# We need to download lots of history so that
49+
# lerna-changelog can discover what's changed since the last release
50+
with:
51+
fetch-depth: 0
52+
- uses: actions/setup-node@v4
53+
with:
54+
node-version: 18
55+
56+
- uses: pnpm/action-setup@v2
57+
with:
58+
version: 8
59+
- run: pnpm install --frozen-lockfile
60+
61+
- name: "Update Docs"
62+
run: pnpm update-docs
63+
64+
- name: "Generate Explanation and Prep Changelogs"
65+
id: explanation
66+
run: |
67+
set -x
68+
69+
pnpm release-plan prepare
70+
71+
echo 'text<<EOF' >> $GITHUB_OUTPUT
72+
jq .description .release-plan.json -r >> $GITHUB_OUTPUT
73+
echo 'EOF' >> $GITHUB_OUTPUT
74+
env:
75+
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
76+
77+
- uses: peter-evans/create-pull-request@v5
78+
with:
79+
commit-message: "Prepare Release using 'release-plan'"
80+
author: "github-actions[bot] <[email protected]>"
81+
labels: "internal"
82+
branch: release-preview
83+
title: Prepare Release
84+
body: |
85+
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 👍
86+
87+
-----------------------------------------
88+
89+
${{ steps.explanation.outputs.text }}

.github/workflows/publish.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
53+
- uses: pnpm/action-setup@v2
54+
with:
55+
version: 8
56+
- run: pnpm install --frozen-lockfile
57+
- name: npm publish
58+
run: pnpm release-plan publish
59+
60+
env:
61+
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
62+
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
## v2.1.0 (2022-01-11)
24

35
#### :rocket: Enhancement

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 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-codemods/ember-no-implicit-this-codemod/pulls?q=is%3Apr+is%3Aopen+%22Prepare+Release%22+in%3Atitle) PR

package.json

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,39 @@
22
"name": "ember-no-implicit-this-codemod",
33
"version": "2.1.0",
44
"description": "Codemods for transforming variable usage to be prefixed with `this`, when appropriate",
5-
"license": "MIT",
5+
"keywords": [
6+
"codemod-cli"
7+
],
8+
"homepage": "https://github.com/ember-codemods/ember-no-implicit-this-codemod#readme",
9+
"bugs": {
10+
"url": "https://github.com/ember-codemods/ember-no-implicit-this-codemod"
11+
},
612
"repository": {
713
"type": "git",
814
"url": "git+https://github.com/ember-codemods/ember-no-implicit-this-codemod"
915
},
10-
"bugs": {
11-
"url": "https://github.com/ember-codemods/ember-no-implicit-this-codemod"
12-
},
13-
"homepage": "https://github.com/ember-codemods/ember-no-implicit-this-codemod#readme",
16+
"license": "MIT",
1417
"author": "",
18+
"bin": {
19+
"ember-no-implicit-this-codemod": "./bin/cli.js"
20+
},
1521
"scripts": {
16-
"release": "release-it",
17-
"test": "jest",
18-
"test:integration": "ts-node ./test/run-test.ts",
19-
"update-docs": "codemod-cli update-docs",
22+
"codemod": "jscodeshift -t ./transforms/no-implicit-this/index.js --extensions js,ts,hbs --run-in-band",
2023
"coveralls": "cat ./coverage/lcov.info | node node_modules/.bin/coveralls",
21-
"lint:js": "eslint .",
22-
"debug:telemetry": "node --inspect-brk ./bin/telemetry.js",
24+
"debug:codemod": "node --inspect-brk node_modules/jscodeshift/bin/jscodeshift.js -t ./transforms/no-implicit-this/index.js --run-in-band --extensions js,ts,hbs ",
2325
"debug:codemod:not-working": "node --inspect-brk ./bin/cli",
24-
"codemod": "jscodeshift -t ./transforms/no-implicit-this/index.js --extensions js,ts,hbs --run-in-band",
25-
"debug:codemod": "node --inspect-brk node_modules/jscodeshift/bin/jscodeshift.js -t ./transforms/no-implicit-this/index.js --run-in-band --extensions js,ts,hbs "
26+
"debug:telemetry": "node --inspect-brk ./bin/telemetry.js",
27+
"lint:js": "eslint .",
28+
"test": "jest",
29+
"test:integration": "ts-node ./test/run-test.ts",
30+
"update-docs": "codemod-cli update-docs"
2631
},
27-
"bin": {
28-
"ember-no-implicit-this-codemod": "./bin/cli.js"
32+
"jest": {
33+
"testEnvironment": "node",
34+
"testMatch": [
35+
"<rootDir>/transforms/**/test.js"
36+
]
2937
},
30-
"keywords": [
31-
"codemod-cli"
32-
],
3338
"dependencies": {
3439
"codemod-cli": "^2.1.0",
3540
"debug": "^4.1.1",
@@ -52,37 +57,11 @@
5257
"execa": "^3.4.0",
5358
"jest": "^26.6.3",
5459
"prettier": "^1.19.1",
55-
"release-it": "^14.6.2",
56-
"release-it-lerna-changelog": "^3.1.0",
60+
"release-plan": "^0.6.0",
5761
"ts-node": "^8.10.2",
5862
"typescript": "~3.9.7"
5963
},
6064
"engines": {
6165
"node": "16.* || 18.* || >= 20"
62-
},
63-
"jest": {
64-
"testEnvironment": "node",
65-
"testMatch": [
66-
"<rootDir>/transforms/**/test.js"
67-
]
68-
},
69-
"publishConfig": {
70-
"registry": "https://registry.npmjs.org"
71-
},
72-
"release-it": {
73-
"hooks": {
74-
"before:release": "yarn update-docs"
75-
},
76-
"plugins": {
77-
"release-it-lerna-changelog": {
78-
"infile": "CHANGELOG.md"
79-
}
80-
},
81-
"git": {
82-
"tagName": "v${version}"
83-
},
84-
"github": {
85-
"release": true
86-
}
8766
}
8867
}

0 commit comments

Comments
 (0)