Skip to content

Commit c970315

Browse files
committed
feat: use release please manifest configuration
1 parent e5d3d0e commit c970315

20 files changed

+333
-171
lines changed

.github/matchers/tap.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@
2929
]
3030
}
3131
]
32-
}
32+
}

.github/workflows/release-please.yml

+40-9
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,50 @@ on:
88
- main
99
- latest
1010

11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
1115
jobs:
1216
release-please:
1317
runs-on: ubuntu-latest
18+
outputs:
19+
prs: ${{ steps.release.outputs.prs }}
1420
steps:
1521
- uses: google-github-actions/release-please-action@v3
1622
id: release
1723
with:
18-
release-type: node
19-
changelog-types: >
20-
[
21-
{"type":"feat","section":"Features","hidden":false},
22-
{"type":"fix","section":"Bug Fixes","hidden":false},
23-
{"type":"docs","section":"Documentation","hidden":false},
24-
{"type":"deps","section":"Dependencies","hidden":false},
25-
{"type":"chore","hidden":true}
26-
]
24+
command: manifest
25+
26+
update-prs:
27+
needs: release-please
28+
if: needs.release-please.outputs.prs
29+
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
pr: ${{ fromJSON(needs.release-please.outputs.prs) }}
33+
steps:
34+
- uses: actions/checkout@v3
35+
- name: Setup git user
36+
run: |
37+
git config --global user.email "[email protected]"
38+
git config --global user.name "npm CLI robot"
39+
- uses: actions/setup-node@v3
40+
with:
41+
node-version: 16.x
42+
- name: Update npm to latest
43+
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
44+
- run: npm -v
45+
- name: Update PR ${{ matrix.pr.number }} dependencies and commit
46+
if: steps.release.outputs.pr
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
run: |
50+
gh pr checkout ${{ matrix.pr.number }}
51+
npm run resetdeps
52+
title="${{ matrix.pr.title }}"
53+
# get the dependency spec from the pr title
54+
# get everything after ': release ' + replace space with @
55+
dep_spec=$(echo "${title##*: release }" | tr ' ' @)
56+
git commit -am "deps: $dep_spec"
57+
git push

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
!/.github/
2020
!/.gitignore
2121
!/.npmrc
22+
!/.release-please-manifest.json
2223
!/CODE_OF_CONDUCT.md
2324
!/SECURITY.md
2425
!/bin/
2526
!/lib/
2627
!/package.json
28+
!/release-please-config.json

.release-please-manifest.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "3.6.0"
3+
}

lib/content/index.js

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
const { name: NAME, version: LATEST_VERSION } = require('../../package.json')
22

3+
const releasePlease = (ws = false) => ({
4+
5+
'.release-please-manifest.json': {
6+
file: 'release-please-manifest.json',
7+
filter: (o) => !o.pkg.private,
8+
parser: (p) => class NoCommentJson extends p.JsonMerge {
9+
comment = null
10+
},
11+
},
12+
'release-please-config.json': {
13+
file: 'release-please-config.json',
14+
filter: (o) => !o.pkg.private,
15+
parser: (p) => class NoCommentJson extends p.JsonMerge {
16+
comment = null
17+
},
18+
},
19+
})
20+
321
// Changes applied to the root of the repo
422
const rootRepo = {
523
add: {
@@ -18,6 +36,7 @@ const rootRepo = {
1836
file: 'release-please.yml',
1937
filter: (o) => !o.pkg.private,
2038
},
39+
...releasePlease(),
2140
},
2241
}
2342

@@ -43,10 +62,7 @@ const rootModule = {
4362
// Changes for each workspace but applied to the root of the repo
4463
const workspaceRepo = {
4564
add: {
46-
'.github/workflows/release-please-{{pkgNameFs}}.yml': {
47-
file: 'release-please.yml',
48-
filter: (o) => !o.pkg.private,
49-
},
65+
...releasePlease(true),
5066
'.github/workflows/ci-{{pkgNameFs}}.yml': 'ci.yml',
5167
},
5268
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"separate-pull-requests": true,
3+
"changelog-sections": [
4+
{"type":"feat","section":"Features","hidden":false},
5+
{"type":"fix","section":"Bug Fixes","hidden":false},
6+
{"type":"docs","section":"Documentation","hidden":false},
7+
{"type":"deps","section":"Dependencies","hidden":false},
8+
{"type":"chore","hidden":true}
9+
],
10+
"packages": {
11+
"{{#unless pkgRelPath}}.{{/unless}}{{pkgRelPath}}": {}
12+
}
13+
}
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"{{#unless pkgRelPath}}.{{/unless}}{{pkgRelPath}}": "{{pkg.version}}"
3+
}

lib/content/release-please.yml

+20-29
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,47 @@
1-
name: Release Please {{~#if isWorkspace}} - {{pkgName}}{{/if}}
1+
name: Release Please
22

33
on:
44
push:
5-
{{#if pkgRelPath}}
6-
paths:
7-
- {{pkgRelPath}}/**
8-
{{/if}}
95
branches:
106
{{#each branches}}
117
- {{.}}
128
{{/each}}
139

14-
{{#if isWorkspace}}
1510
permissions:
1611
contents: write
1712
pull-requests: write
18-
{{/if}}
1913

2014
jobs:
2115
release-please:
2216
runs-on: ubuntu-latest
17+
outputs:
18+
prs: $\{{ steps.release.outputs.prs }}
2319
steps:
2420
- uses: google-github-actions/release-please-action@v3
2521
id: release
2622
with:
27-
release-type: node
28-
{{#if pkgRelPath}}
29-
monorepo-tags: true
30-
path: {{pkgRelPath}}
31-
# name can be removed after this is merged
32-
# https://github.com/google-github-actions/release-please-action/pull/459
33-
package-name: "{{pkgName}}"
34-
{{/if}}
35-
changelog-types: >
36-
[
37-
{{#each changelogTypes}}
38-
{{{json .}}}{{#unless @last}},{{/unless}}
39-
{{/each}}
40-
]
41-
{{#if isWorkspace}}
23+
command: manifest
24+
25+
update-prs:
26+
needs: release-please
27+
if: needs.release-please.outputs.prs
28+
runs-on: ubuntu-latest
29+
strategy:
30+
matrix:
31+
pr: $\{{ fromJSON(needs.release-please.outputs.prs) }}
32+
steps:
4233
{{> setupGit}}
4334
{{> setupNode}}
44-
- name: Update package-lock.json and commit
35+
- name: Update PR $\{{ matrix.pr.number }} dependencies and commit
4536
if: steps.release.outputs.pr
4637
env:
4738
GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }}
4839
run: |
49-
gh pr checkout $\{{ fromJSON(steps.release.outputs.pr).number }}
40+
gh pr checkout $\{{ matrix.pr.number }}
5041
npm run resetdeps
51-
title="$\{{ fromJSON(steps.release.outputs.pr).title }}"
52-
# get the version from the pr title
53-
# get everything after the last space
54-
git commit -am "deps: {{pkgName}}@${title##* }"
42+
title="$\{{ matrix.pr.title }}"
43+
# get the dependency spec from the pr title
44+
# get everything after ': release ' + replace space with @
45+
dep_spec=$(echo "${title##*: release }" | tr ' ' @)
46+
git commit -am "deps: $dep_spec"
5547
git push
56-
{{/if}}

lib/util/parser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class Json extends Base {
198198
comment = (c) => ({ [`//${this.options.config.__NAME__}`]: c })
199199

200200
toString (s) {
201-
return JSON.stringify(s, (_, v) => v === this.DELETE ? undefined : v, 2)
201+
return JSON.stringify(s, (_, v) => v === this.DELETE ? undefined : v, 2).trim() + '\n'
202202
}
203203

204204
parse (s) {

release-please-config.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"separate-pull-requests": true,
3+
"changelog-sections": [
4+
{
5+
"type": "feat",
6+
"section": "Features",
7+
"hidden": false
8+
},
9+
{
10+
"type": "fix",
11+
"section": "Bug Fixes",
12+
"hidden": false
13+
},
14+
{
15+
"type": "docs",
16+
"section": "Documentation",
17+
"hidden": false
18+
},
19+
{
20+
"type": "deps",
21+
"section": "Dependencies",
22+
"hidden": false
23+
},
24+
{
25+
"type": "chore",
26+
"hidden": true
27+
}
28+
],
29+
"packages": {
30+
".": {}
31+
}
32+
}

0 commit comments

Comments
 (0)