Skip to content

Commit

Permalink
automate release notes from github actions (#4893)
Browse files Browse the repository at this point in the history
  • Loading branch information
rochdev authored Nov 18, 2024
1 parent f0df061 commit 9de411a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/release-4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ jobs:
permissions:
id-token: write
contents: write
pull-requests: read
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- uses: actions/checkout@v4
Expand All @@ -31,3 +33,4 @@ jobs:
- run: |
git tag v${{ fromJson(steps.pkg.outputs.json).version }}
git push origin v${{ fromJson(steps.pkg.outputs.json).version }}
- run: node scripts/release/notes
3 changes: 3 additions & 0 deletions .github/workflows/release-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ jobs:
permissions:
id-token: write
contents: write
pull-requests: read
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
outputs:
pkgjson: ${{ steps.pkg.outputs.json }}
Expand All @@ -33,6 +35,7 @@ jobs:
- run: |
git tag v${{ fromJson(steps.pkg.outputs.json).version }}
git push origin v${{ fromJson(steps.pkg.outputs.json).version }}
- run: node scripts/release/notes --latest

docs:
runs-on: ubuntu-latest
Expand Down
31 changes: 31 additions & 0 deletions scripts/release/notes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict'

const fs = require('fs')
const os = require('os')
const path = require('path')
const { capture, success, run } = require('./helpers/terminal')
const pkg = require('../../package.json')

const version = pkg.version
const tag = `v${version}`
const major = version.split('.')[0]
const body = capture(`gh pr view ${tag}-proposal --json body --jq '.body'`)
const args = process.argv.slice(2)
const flags = []
const folder = path.join(os.tmpdir(), 'release_notes')
const file = path.join(folder, `${tag}.md`)

if (args.includes('--latest')) {
flags.push('--latest')
}

if (version.includes('-')) {
flags.push('--prerelease')
}

fs.mkdirSync(folder, { recursive: true })
fs.writeFileSync(file, body)

run(`gh release create ${tag} --target v${major}.x --title ${version} -F ${file} ${flags.join(' ')}`)

success(`Release notes published for ${version}.`)

0 comments on commit 9de411a

Please sign in to comment.