build: fix release script

pull/183/head
Eduardo San Martin Morote 4 years ago
parent 9d64538d03
commit e79108cce0

@ -8,8 +8,6 @@ const currentVersion = require('../package.json').version
const versionIncrements = ['patch', 'minor', 'major'] const versionIncrements = ['patch', 'minor', 'major']
const tags = ['latest', 'next']
const inc = (i) => semver.inc(currentVersion, i) const inc = (i) => semver.inc(currentVersion, i)
const bin = (name) => path.resolve(__dirname, `../node_modules/.bin/${name}`) const bin = (name) => path.resolve(__dirname, `../node_modules/.bin/${name}`)
const run = (bin, args, opts = {}) => const run = (bin, args, opts = {}) =>
@ -43,19 +41,10 @@ async function main() {
throw new Error(`Invalid target version: ${targetVersion}`) throw new Error(`Invalid target version: ${targetVersion}`)
} }
const { tag } = await prompt({
type: 'select',
name: 'tag',
message: 'Select tag type',
choices: tags
})
console.log(tag)
const { yes: tagOk } = await prompt({ const { yes: tagOk } = await prompt({
type: 'confirm', type: 'confirm',
name: 'yes', name: 'yes',
message: `Releasing v${targetVersion} with the "${tag}" tag. Confirm?` message: `Releasing v${targetVersion}. Confirm?`
}) })
if (!tagOk) { if (!tagOk) {
@ -73,6 +62,7 @@ async function main() {
// Generate the changelog. // Generate the changelog.
step('\nGenerating the changelog...') step('\nGenerating the changelog...')
await run('yarn', ['changelog']) await run('yarn', ['changelog'])
await run('yarn', ['prettier', '--write', 'CHANGELOG.md'])
const { yes: changelogOk } = await prompt({ const { yes: changelogOk } = await prompt({
type: 'confirm', type: 'confirm',
@ -84,17 +74,16 @@ async function main() {
return return
} }
// Commit changes to the Git. // Commit changes to the Git and create a tag.
step('\nCommitting changes...') step('\nCommitting changes...')
await run('git', ['add', '-A']) await run('git', ['add', 'CHANGELOG.md', 'package.json'])
await run('git', ['commit', '-m', `release: v${targetVersion}`]) await run('git', ['commit', '-m', `release: v${targetVersion}`])
await run('git', ['tag', `v${targetVersion}`])
// Publish the package. // Publish the package.
step('\nPublishing the package...') step('\nPublishing the package...')
await run('yarn', [ await run('yarn', [
'publish', 'publish',
'--tag',
tag,
'--new-version', '--new-version',
targetVersion, targetVersion,
'--no-commit-hooks', '--no-commit-hooks',
@ -103,7 +92,6 @@ async function main() {
// Push to GitHub. // Push to GitHub.
step('\nPushing to GitHub...') step('\nPushing to GitHub...')
await run('git', ['tag', `v${targetVersion}`])
await run('git', ['push', 'origin', `refs/tags/v${targetVersion}`]) await run('git', ['push', 'origin', `refs/tags/v${targetVersion}`])
await run('git', ['push']) await run('git', ['push'])
} }

Loading…
Cancel
Save