Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use release please manifest configuration #164

Merged
merged 1 commit into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/matchers/tap.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
]
}
]
}
}
49 changes: 40 additions & 9 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,50 @@ on:
- main
- latest

permissions:
contents: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
outputs:
prs: ${{ steps.release.outputs.prs }}
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
changelog-types: >
[
{"type":"feat","section":"Features","hidden":false},
{"type":"fix","section":"Bug Fixes","hidden":false},
{"type":"docs","section":"Documentation","hidden":false},
{"type":"deps","section":"Dependencies","hidden":false},
{"type":"chore","hidden":true}
]
command: manifest

update-prs:
needs: release-please
if: needs.release-please.outputs.prs
runs-on: ubuntu-latest
strategy:
matrix:
pr: ${{ fromJSON(needs.release-please.outputs.prs) }}
steps:
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "[email protected]"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Update npm to latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- run: npm -v
- name: Update PR ${{ matrix.pr.number }} dependencies and commit
if: steps.release.outputs.pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr checkout ${{ matrix.pr.number }}
npm run resetdeps
title="${{ matrix.pr.title }}"
# get the dependency spec from the pr title
# get everything after ': release ' + replace space with @
dep_spec=$(echo "${title##*: release }" | tr ' ' @)
git commit -am "deps: $dep_spec"
git push
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
!/.github/
!/.gitignore
!/.npmrc
!/.release-please-manifest.json
!/CODE_OF_CONDUCT.md
!/SECURITY.md
!/bin/
!/lib/
!/package.json
!/release-please-config.json
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "3.6.0"
}
31 changes: 23 additions & 8 deletions lib/content/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
const { name: NAME, version: LATEST_VERSION } = require('../../package.json')

const releasePlease = () => ({
'.github/workflows/release-please.yml': {
file: 'release-please.yml',
filter: (o) => !o.pkg.private,
},
'.release-please-manifest.json': {
file: 'release-please-manifest.json',
filter: (o) => !o.pkg.private,
parser: (p) => class NoCommentJson extends p.JsonMerge {
comment = null
},
},
'release-please-config.json': {
file: 'release-please-config.json',
filter: (o) => !o.pkg.private,
parser: (p) => class NoCommentJson extends p.JsonMerge {
comment = null
},
},
})

// Changes applied to the root of the repo
const rootRepo = {
add: {
Expand All @@ -14,10 +35,7 @@ const rootRepo = {
'.github/workflows/codeql-analysis.yml': 'codeql-analysis.yml',
'.github/workflows/post-dependabot.yml': 'post-dependabot.yml',
'.github/workflows/pull-request.yml': 'pull-request.yml',
'.github/workflows/release-please.yml': {
file: 'release-please.yml',
filter: (o) => !o.pkg.private,
},
...releasePlease(),
},
}

Expand All @@ -43,10 +61,7 @@ const rootModule = {
// Changes for each workspace but applied to the root of the repo
const workspaceRepo = {
add: {
'.github/workflows/release-please-{{pkgNameFs}}.yml': {
file: 'release-please.yml',
filter: (o) => !o.pkg.private,
},
...releasePlease(true),
'.github/workflows/ci-{{pkgNameFs}}.yml': 'ci.yml',
},
}
Expand Down
13 changes: 13 additions & 0 deletions lib/content/release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"separate-pull-requests": true,
"changelog-sections": [
{"type":"feat","section":"Features","hidden":false},
{"type":"fix","section":"Bug Fixes","hidden":false},
{"type":"docs","section":"Documentation","hidden":false},
{"type":"deps","section":"Dependencies","hidden":false},
{"type":"chore","hidden":true}
],
"packages": {
"{{#unless pkgRelPath}}.{{/unless}}{{pkgRelPath}}": {}
}
}
3 changes: 3 additions & 0 deletions lib/content/release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"{{#unless pkgRelPath}}.{{/unless}}{{pkgRelPath}}": "{{pkg.version}}"
}
49 changes: 20 additions & 29 deletions lib/content/release-please.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,47 @@
name: Release Please {{~#if isWorkspace}} - {{pkgName}}{{/if}}
name: Release Please

on:
push:
{{#if pkgRelPath}}
paths:
- {{pkgRelPath}}/**
{{/if}}
branches:
{{#each branches}}
- {{.}}
{{/each}}

{{#if isWorkspace}}
permissions:
contents: write
pull-requests: write
{{/if}}

jobs:
release-please:
runs-on: ubuntu-latest
outputs:
prs: $\{{ steps.release.outputs.prs }}
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
{{#if pkgRelPath}}
monorepo-tags: true
path: {{pkgRelPath}}
# name can be removed after this is merged
# https://github.com/google-github-actions/release-please-action/pull/459
package-name: "{{pkgName}}"
{{/if}}
changelog-types: >
[
{{#each changelogTypes}}
{{{json .}}}{{#unless @last}},{{/unless}}
{{/each}}
]
{{#if isWorkspace}}
command: manifest

update-prs:
needs: release-please
if: needs.release-please.outputs.prs
runs-on: ubuntu-latest
strategy:
matrix:
pr: $\{{ fromJSON(needs.release-please.outputs.prs) }}
steps:
{{> setupGit}}
{{> setupNode}}
- name: Update package-lock.json and commit
- name: Update PR $\{{ matrix.pr.number }} dependencies and commit
if: steps.release.outputs.pr
env:
GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }}
run: |
gh pr checkout $\{{ fromJSON(steps.release.outputs.pr).number }}
gh pr checkout $\{{ matrix.pr.number }}
npm run resetdeps
title="$\{{ fromJSON(steps.release.outputs.pr).title }}"
# get the version from the pr title
# get everything after the last space
git commit -am "deps: {{pkgName}}@${title##* }"
title="$\{{ matrix.pr.title }}"
# get the dependency spec from the pr title
# get everything after ': release ' + replace space with @
dep_spec=$(echo "${title##*: release }" | tr ' ' @)
git commit -am "deps: $dep_spec"
git push
{{/if}}
2 changes: 1 addition & 1 deletion lib/util/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class Json extends Base {
comment = (c) => ({ [`//${this.options.config.__NAME__}`]: c })

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

parse (s) {
Expand Down
32 changes: 32 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"separate-pull-requests": true,
"changelog-sections": [
{
"type": "feat",
"section": "Features",
"hidden": false
},
{
"type": "fix",
"section": "Bug Fixes",
"hidden": false
},
{
"type": "docs",
"section": "Documentation",
"hidden": false
},
{
"type": "deps",
"section": "Dependencies",
"hidden": false
},
{
"type": "chore",
"hidden": true
}
],
"packages": {
".": {}
}
}
Loading