Skip to content

Commit

Permalink
fix(ci_cd): fix changelog generation on release
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentlp committed Aug 23, 2021
1 parent cff7316 commit 510040a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
node-version: '12.18.3'
cache: 'yarn'
- name: Git Unshalow
- name: Git Unshallow
run: git fetch --prune --unshallow
- name: Fetch Node Packages
run: |
Expand Down
4 changes: 2 additions & 2 deletions scripts/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const build = async ({ writeToFile } = { writeToFile: false }) => {

let text = ''
const stream = changelog(changelogOts, context, gitRawCommitsOpts, commitsParserOpts, changelogWriterOpts)
stream.on('data', chunk => (text += chunk))
await Promise.fromCallback(cb => stream.on('end', cb))
stream.on('data', (chunk) => (text += chunk))
await Promise.fromCallback((cb) => stream.on('end', cb))

if (writeToFile) {
const existingChangelog = await fse.readFile('./CHANGELOG.md', 'utf-8')
Expand Down
13 changes: 6 additions & 7 deletions scripts/release.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const { execute } = require('./exec')
const semver = require('semver')
const yargs = require('yargs')
const fse = require('fs-extra')
const { spawn } = require('child_process')
const path = require('path')
const changelog = require('./changelog')
const logger = require('./logger')

yargs
.command(['$0 <releaseType>'], 'Bump release version. releaseType options: major, minor, patch', {}, async argv => {
.command(['$0 <releaseType>'], 'Bump release version. releaseType options: major, minor, patch', {}, async (argv) => {
yargs.positional('releaseType', {
describe: 'Type of release to do: major, minor or patch',
type: 'string',
Expand All @@ -18,13 +18,12 @@ yargs
const version = (await fse.readJSON(path.join('package.json'))).version
const newVersion = semver.inc(version, argv.releaseType)

const bumpCommand = `version --new-version ${newVersion} --no-git-tag-version`
await execute(`yarn ${bumpCommand}`, undefined, { silent: true })
await execute(`yarn workspace @botpress/messaging-server ${bumpCommand}`, undefined, { silent: true })

const changes = await changelog.build({ writeToFile: true })
logger.info(`Change Log:\n\n${changes}`)

spawn('yarn', ['version', '--new-version', newVersion, '--no-git-tag-version'], {
stdio: 'inherit',
shell: true
})
} catch (err) {
logger.error(err)
}
Expand Down

0 comments on commit 510040a

Please sign in to comment.