1
1
mirror of https://github.com/primer/css.git synced 2024-11-30 01:04:04 +03:00
css/script/changelog.js
2019-10-25 16:46:18 -07:00

35 lines
922 B
JavaScript
Executable File

#!/usr/bin/env node
const semanticRelease = require('semantic-release')
const {spawnSync} = require('child_process')
const {WritableStreamBuffer} = require('stream-buffers')
const branch = getBranch()
const options = {branch, dryRun: true}
console.warn(`Running semantic-release with options: ${JSON.stringify(options)}...`)
semanticRelease(options, {
stdout: new WritableStreamBuffer(),
stderr: new WritableStreamBuffer()
})
.then(result => {
const {
nextRelease: {version, notes}
} = result
console.warn(`Release ${version} notes:\n`)
console.log(notes)
})
.catch(error => {
console.error(error.message)
process.exitCode = 1
})
function getBranch() {
const {GITHUB_REF} = process.env
if (GITHUB_REF) {
return GITHUB_REF.replace(/^refs\/heads\//, '')
} else {
return spawnSync('git', ['symbolic-ref', '--short', 'HEAD'], {encoding: 'utf8'}).stdout.trim()
}
}