feat(release): prepare 1.1.0 candidate
This commit is contained in:
parent
5a34f66981
commit
5205dcdfa9
736 changed files with 115667 additions and 12203 deletions
40
scripts/ci/extract-release-notes.mjs
Normal file
40
scripts/ci/extract-release-notes.mjs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import { readFile, writeFile } from 'node:fs/promises'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const root = join(dirname(fileURLToPath(import.meta.url)), '..', '..')
|
||||
const args = process.argv.slice(2)
|
||||
const version = option('--version')
|
||||
const output = option('--output')
|
||||
|
||||
if (!/^\d+\.\d+\.\d+$/.test(version)) fail(`Invalid stable version: ${version}`)
|
||||
|
||||
const changelog = await readFile(join(root, 'CHANGELOG.md'), 'utf8')
|
||||
const escaped = version.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||
const lines = changelog.split(/\r?\n/)
|
||||
const start = lines.findIndex((line) => new RegExp(`^## \\[${escaped}\\] - \\d{4}-\\d{2}-\\d{2}$`).test(line))
|
||||
if (start === -1) fail(`CHANGELOG.md is missing the ${version} release section.`)
|
||||
|
||||
let end = lines.length
|
||||
for (let index = start + 1; index < lines.length; index += 1) {
|
||||
if (/^##\s+/.test(lines[index])) {
|
||||
end = index
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
const notes = `${lines.slice(start, end).join('\n').trim()}\n`
|
||||
await writeFile(join(root, output), notes, 'utf8')
|
||||
process.stdout.write(`[release-notes] wrote ${output} for ${version}\n`)
|
||||
|
||||
function option(name) {
|
||||
const index = args.indexOf(name)
|
||||
const value = index === -1 ? undefined : args[index + 1]
|
||||
if (!value || value.startsWith('--')) fail(`${name} is required.`)
|
||||
return value
|
||||
}
|
||||
|
||||
function fail(message) {
|
||||
process.stderr.write(`[release-notes] ${message}\n`)
|
||||
process.exit(1)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue