fix: improve release notes (#16343)
* fix: use version name in release notes * fix: omit previously-released notes * fix: sniff semantic commit types from PR subjects instead of only from commit messages * fix: do not use unrecognized semantic commit types * chore: do not hardcode Release-Notes comment text It used to be '<!-- One-line Change Summary Here-->', it's currently a link to a best-practices page, and it'll probably change again in the future. Let's just match on <!--.*--> instead. * chore: copyedit the help page * chore: use clerk's OMIT_FROM_RELEASE_NOTES_KEYS * chore: tweak comments * chore: rename 'breaks' property as 'breaking'
This commit is contained in:
parent
102d8fe506
commit
2acf9ac72f
3 changed files with 116 additions and 40 deletions
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const { GitProcess } = require('dugite')
|
||||
const minimist = require('minimist')
|
||||
const path = require('path')
|
||||
const semver = require('semver')
|
||||
|
||||
|
@ -120,13 +121,17 @@ const getPreviousPoint = async (point) => {
|
|||
}
|
||||
}
|
||||
|
||||
async function getReleaseNotes (range, explicitLinks) {
|
||||
async function getReleaseNotes (range, newVersion, explicitLinks) {
|
||||
const rangeList = range.split('..') || ['HEAD']
|
||||
const to = rangeList.pop()
|
||||
const from = rangeList.pop() || (await getPreviousPoint(to))
|
||||
console.log(`Generating release notes between ${from} and ${to}`)
|
||||
|
||||
const notes = await notesGenerator.get(from, to)
|
||||
if (!newVersion) {
|
||||
newVersion = to
|
||||
}
|
||||
|
||||
console.log(`Generating release notes between ${from} and ${to} for version ${newVersion}`)
|
||||
const notes = await notesGenerator.get(from, to, newVersion)
|
||||
const ret = {
|
||||
text: notesGenerator.render(notes, explicitLinks)
|
||||
}
|
||||
|
@ -139,15 +144,33 @@ async function getReleaseNotes (range, explicitLinks) {
|
|||
}
|
||||
|
||||
async function main () {
|
||||
// TODO: minimist/commander
|
||||
const explicitLinks = process.argv.slice(2).some(arg => arg === '--explicit-links')
|
||||
if (process.argv.length > 4) {
|
||||
console.log('Use: script/release-notes/index.js [--explicit-links] [tag | tag1..tag2]')
|
||||
return 1
|
||||
const opts = minimist(process.argv.slice(2), {
|
||||
boolean: [ 'explicit-links', 'help' ],
|
||||
string: [ 'version' ]
|
||||
})
|
||||
opts.range = opts._.shift()
|
||||
if (opts.help || !opts.range) {
|
||||
const name = path.basename(process.argv[1])
|
||||
console.log(`
|
||||
easy usage: ${name} version
|
||||
|
||||
full usage: ${name} [begin..]end [--version version] [--explicit-links]
|
||||
|
||||
* 'begin' and 'end' are two git references -- tags, branches, etc --
|
||||
from which the release notes are generated.
|
||||
* if omitted, 'begin' defaults to the previous tag in end's branch.
|
||||
* if omitted, 'version' defaults to 'end'. Specifying a version is
|
||||
useful if you're making notes on a new version that isn't tagged yet.
|
||||
* 'explicit-links' makes every note's issue, commit, or pull an MD link
|
||||
|
||||
For example, these invocations are equivalent:
|
||||
${process.argv[1]} v4.0.1
|
||||
${process.argv[1]} v4.0.0..v4.0.1 --version v4.0.1
|
||||
`)
|
||||
return 0
|
||||
}
|
||||
|
||||
const range = process.argv[2] || 'HEAD'
|
||||
const notes = await getReleaseNotes(range, explicitLinks)
|
||||
const notes = await getReleaseNotes(opts.range, opts.version, opts['explicit-links'])
|
||||
console.log(notes.text)
|
||||
if (notes.warning) {
|
||||
throw new Error(notes.warning)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue