release-notes.js 674 B

12345678910111213141516171819202122
  1. // Given a version, figure out what the release notes are so that we can use this to pre-fill the
  2. // release notes on a GitHub release for the current version.
  3. let path = require('path')
  4. let fs = require('fs')
  5. let version =
  6. process.argv[2] || process.env.npm_package_version || require('../package.json').version
  7. let changelog = fs.readFileSync(path.resolve(__dirname, '..', 'CHANGELOG.md'), 'utf8')
  8. let match = new RegExp(
  9. `## \\[${version}\\] - (.*)\\n\\n([\\s\\S]*?)\\n(?:(?:##\\s)|(?:\\[))`,
  10. 'g'
  11. ).exec(changelog)
  12. if (match) {
  13. let [, , notes] = match
  14. console.log(notes.trim())
  15. } else {
  16. console.log(`Placeholder release notes for version: v${version}`)
  17. }