Skip to content

Commit

Permalink
better release notes (#15169)
Browse files Browse the repository at this point in the history
* fix: use PR 'Notes' comment in release notes

* fix: follow links in roller-bot PRs

* refactor: better reference point version selection

* if we're a stable release, use the current brnach's previous stable
* if we're a beta release, use the current branch's previous beta
* if no match found, use the newest stable that precedes this branch

* refactor: dedup the caching functions' code

* refactor: partially rewrite release note generator

* parse release notes comments from PRs
* do not display no-notes PRs
* handle roller-bot commits by following cross-repo commits/PRs
* minor tweaks to note rendering, e.g. capitalization

* fix: fix lint:js script typo

* fix: copy originalPr value to rollerbot PR chains

* fix: handle more cases in release notes generator

* handle force-pushes where no PR
* better type guessing on pre-semantic commits

* fix: handle more edge cases in the note generator

* better removal of commits that landed before the reference point
* ensure '<!-- One-line Change Summary Here-->' is removed from notes
* handle more legacy commit body notes e.g. "Chore(docs)"
* check for fix markdown in PR body e.g. a link to the issue page

* chore: tweak code comments

* refactor: easier note generator command-line args

* refactor: group related notes together

* feat: query commits locally for gyp and gn deps

* chore: slightly better filtering of old commits

* feat: omit submodule commits for .0.0 releases

More specifically, only include them if generating release
notes relative to another release on the same branch.

Before that first release, there's just too much churn.

* refactor: make release-notes usable as a module

Calling it from the command line and from require()() now
do pretty much the same thing.

* refactor: passing command-line args means use HEAD

* chore: plug in the release note generator

* feat: support multiline 'Notes:' messages.

xref: electron/trop#56
xref: electron/clerk#16

* remove accidental change in package.json

* simplify an overcomplicated require() call

* Don't use PascalCase on releaseNotesGenerator()

* Remove code duplication in release notes warnings

* remove commented-out code.

* don't use single-character variable names.

For example, use 'tag' instead of 't'. The latter was being
used for map/filter arrow function args.

* Look for 'backport' rather than 'ackport'.

* Wrap all block statements in curly braces.

* fix tyop

* fix oops

* Check semver validity before calling semver.sort()
  • Loading branch information
ckerr authored and John Kleinschmidt committed Nov 6, 2018
1 parent 649f04b commit 1672c95
Show file tree
Hide file tree
Showing 3 changed files with 711 additions and 483 deletions.
69 changes: 7 additions & 62 deletions script/prepare-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const { GitProcess } = require('dugite')
const GitHub = require('github')
const pass = '\u2713'.green
const path = require('path')
const pkg = require('../package.json')
const readline = require('readline')
const releaseNotesGenerator = require('./release-notes/index.js')
const versionType = args._[0]
const targetRepo = versionType === 'nightly' ? 'nightlies' : 'electron'

Expand Down Expand Up @@ -75,65 +75,10 @@ async function getReleaseNotes (currentBranch) {
return 'Nightlies do not get release notes, please compare tags for info'
}
console.log(`Generating release notes for ${currentBranch}.`)
const githubOpts = {
owner: 'electron',
repo: targetRepo,
base: `v${pkg.version}`,
head: currentBranch
}
let releaseNotes
if (args.automaticRelease) {
releaseNotes = '## Bug Fixes/Changes \n\n'
} else {
releaseNotes = '(placeholder)\n'
}
console.log(`Checking for commits from ${pkg.version} to ${currentBranch}`)
const commitComparison = await github.repos.compareCommits(githubOpts)
.catch(err => {
console.log(`${fail} Error checking for commits from ${pkg.version} to ` +
`${currentBranch}`, err)
process.exit(1)
})

if (commitComparison.data.commits.length === 0) {
console.log(`${pass} There are no commits from ${pkg.version} to ` +
`${currentBranch}, skipping release.`)
process.exit(0)
const releaseNotes = await releaseNotesGenerator(currentBranch)
if (releaseNotes.warning) {
console.warn(releaseNotes.warning)
}

let prCount = 0
const mergeRE = /Merge pull request #(\d+) from .*\n/
const newlineRE = /(.*)\n*.*/
const prRE = /(.* )\(#(\d+)\)(?:.*)/
commitComparison.data.commits.forEach(commitEntry => {
let commitMessage = commitEntry.commit.message
if (commitMessage.indexOf('#') > -1) {
let prMatch = commitMessage.match(mergeRE)
let prNumber
if (prMatch) {
commitMessage = commitMessage.replace(mergeRE, '').replace('\n', '')
const newlineMatch = commitMessage.match(newlineRE)
if (newlineMatch) {
commitMessage = newlineMatch[1]
}
prNumber = prMatch[1]
} else {
prMatch = commitMessage.match(prRE)
if (prMatch) {
commitMessage = prMatch[1].trim()
prNumber = prMatch[2]
}
}
if (prMatch) {
if (commitMessage.substr(commitMessage.length - 1, commitMessage.length) !== '.') {
commitMessage += '.'
}
releaseNotes += `* ${commitMessage} #${prNumber} \n\n`
prCount++
}
}
})
console.log(`${pass} Done generating release notes for ${currentBranch}. Found ${prCount} PRs.`)
return releaseNotes
}

Expand Down Expand Up @@ -165,12 +110,12 @@ async function createRelease (branchToTarget, isBeta) {
githubOpts.body = `Note: This is a nightly release. Please file new issues ` +
`for any bugs you find in it.\n \n This release is published to npm ` +
`under the nightly tag and can be installed via npm install electron@nightly, ` +
`or npm i electron@${newVersion.substr(1)}.\n \n ${releaseNotes}`
`or npm i electron@${newVersion.substr(1)}.\n \n ${releaseNotes.text}`
} else {
githubOpts.body = `Note: This is a beta release. Please file new issues ` +
`for any bugs you find in it.\n \n This release is published to npm ` +
`under the beta tag and can be installed via npm install electron@beta, ` +
`or npm i electron@${newVersion.substr(1)}.\n \n ${releaseNotes}`
`or npm i electron@${newVersion.substr(1)}.\n \n ${releaseNotes.text}`
}
githubOpts.name = `${githubOpts.name}`
githubOpts.prerelease = true
Expand Down Expand Up @@ -262,7 +207,7 @@ async function prepareRelease (isBeta, notesOnly) {
const currentBranch = (args.branch) ? args.branch : await getCurrentBranch(gitDir)
if (notesOnly) {
const releaseNotes = await getReleaseNotes(currentBranch)
console.log(`Draft release notes are: \n${releaseNotes}`)
console.log(`Draft release notes are: \n${releaseNotes.text}`)
} else {
const changes = await changesToRelease(currentBranch)
if (changes) {
Expand Down

0 comments on commit 1672c95

Please sign in to comment.