1
1
mirror of https://github.com/primer/css.git synced 2024-12-14 23:12:03 +03:00
css/script/changelog.js

35 lines
922 B
JavaScript
Raw Normal View History

2019-10-26 02:34:40 +03:00
#!/usr/bin/env node
const semanticRelease = require('semantic-release')
const {spawnSync} = require('child_process')
const {WritableStreamBuffer} = require('stream-buffers')
2019-10-26 02:46:18 +03:00
const branch = getBranch()
2019-10-26 02:34:40 +03:00
const options = {branch, dryRun: true}
2019-10-26 02:46:18 +03:00
2019-10-26 02:34:40 +03:00
console.warn(`Running semantic-release with options: ${JSON.stringify(options)}...`)
2019-10-26 02:46:18 +03:00
2019-10-26 02:34:40 +03:00
semanticRelease(options, {
stdout: new WritableStreamBuffer(),
stderr: new WritableStreamBuffer()
})
2019-10-26 02:46:18 +03:00
.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()
}
}