Skip to content

Commit 9de411a

Browse files
authored
automate release notes from github actions (#4893)
1 parent f0df061 commit 9de411a

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

.github/workflows/release-4.yml

+3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ jobs:
1616
permissions:
1717
id-token: write
1818
contents: write
19+
pull-requests: read
1920
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2022
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2123
steps:
2224
- uses: actions/checkout@v4
@@ -31,3 +33,4 @@ jobs:
3133
- run: |
3234
git tag v${{ fromJson(steps.pkg.outputs.json).version }}
3335
git push origin v${{ fromJson(steps.pkg.outputs.json).version }}
36+
- run: node scripts/release/notes

.github/workflows/release-latest.yml

+3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ jobs:
1616
permissions:
1717
id-token: write
1818
contents: write
19+
pull-requests: read
1920
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2022
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2123
outputs:
2224
pkgjson: ${{ steps.pkg.outputs.json }}
@@ -33,6 +35,7 @@ jobs:
3335
- run: |
3436
git tag v${{ fromJson(steps.pkg.outputs.json).version }}
3537
git push origin v${{ fromJson(steps.pkg.outputs.json).version }}
38+
- run: node scripts/release/notes --latest
3639

3740
docs:
3841
runs-on: ubuntu-latest

scripts/release/notes.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict'
2+
3+
const fs = require('fs')
4+
const os = require('os')
5+
const path = require('path')
6+
const { capture, success, run } = require('./helpers/terminal')
7+
const pkg = require('../../package.json')
8+
9+
const version = pkg.version
10+
const tag = `v${version}`
11+
const major = version.split('.')[0]
12+
const body = capture(`gh pr view ${tag}-proposal --json body --jq '.body'`)
13+
const args = process.argv.slice(2)
14+
const flags = []
15+
const folder = path.join(os.tmpdir(), 'release_notes')
16+
const file = path.join(folder, `${tag}.md`)
17+
18+
if (args.includes('--latest')) {
19+
flags.push('--latest')
20+
}
21+
22+
if (version.includes('-')) {
23+
flags.push('--prerelease')
24+
}
25+
26+
fs.mkdirSync(folder, { recursive: true })
27+
fs.writeFileSync(file, body)
28+
29+
run(`gh release create ${tag} --target v${major}.x --title ${version} -F ${file} ${flags.join(' ')}`)
30+
31+
success(`Release notes published for ${version}.`)

0 commit comments

Comments
 (0)