-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enchancements to the build process - changelog generation (#332)
* Release script now accepts a base branch rather than take master * Added automatic changelog generator * Added more release process commands * Fixed version source
- Loading branch information
Steve Hobbs
authored
Jan 15, 2020
1 parent
f8172a7
commit 2b410d1
Showing
5 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ coverage | |
stats.html | ||
cypress/screenshots | ||
cypress/videos | ||
.release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
if (process.platform === 'win32') { | ||
console.error('Must be run on a Unix OS'); | ||
process.exit(1); | ||
} | ||
|
||
const repo = 'auth0-spa-js'; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const execSync = require('child_process').execSync; | ||
const moment = require('moment'); | ||
|
||
module.exports = function(newVersion) { | ||
return new Promise((resolve, reject) => { | ||
const tmp = fs.readFileSync('.release', 'utf-8'); | ||
|
||
const currentVersion = fs.readFileSync( | ||
path.resolve(tmp, 'current-version'), | ||
'utf-8' | ||
); | ||
|
||
const changelogPath = path.resolve(tmp, 'CHANGELOG.md'); | ||
const stream = fs.createWriteStream(changelogPath); | ||
const webtask = `https://webtask.it.auth0.com/api/run/wt-hernan-auth0_com-0/oss-changelog.js?webtask_no_cache=1&repo=${repo}&milestone=v${newVersion}`; | ||
const command = `curl -f -s -H "Accept: text/markdown" "${webtask}"`; | ||
const changes = execSync(command, { encoding: 'utf-8' }); | ||
|
||
const previous = execSync( | ||
'sed "s/# Change Log//" CHANGELOG.md | sed \'1,2d\'' | ||
); | ||
|
||
stream.once('open', function(fd) { | ||
stream.write('# Change Log'); | ||
stream.write('\n'); | ||
stream.write('\n'); | ||
|
||
stream.write( | ||
`## [v${newVersion}](https://github.com/auth0/${repo}/tree/v${newVersion}) (${moment().format( | ||
'YYYY-MM-DD' | ||
)})` | ||
); | ||
|
||
stream.write('\n'); | ||
|
||
stream.write( | ||
`[Full Changelog](https://github.com/auth0/${repo}/compare/v${currentVersion}...v${newVersion})` | ||
); | ||
|
||
stream.write('\n'); | ||
stream.write(changes); | ||
stream.write('\n'); | ||
stream.write(previous); | ||
stream.end(); | ||
}); | ||
|
||
stream.once('close', function(fd) { | ||
execSync(`mv ${changelogPath} CHANGELOG.md`, { stdio: 'inherit' }); | ||
execSync('git add CHANGELOG.md', { stdio: 'inherit' }); | ||
resolve(); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const execSync = require('child_process').execSync; | ||
const fs = require('fs'); | ||
|
||
if (fs.existsSync('dist')) { | ||
execSync(`rm -r dist`, { stdio: 'inherit' }); | ||
} | ||
|
||
if (fs.existsSync('coverage')) { | ||
execSync(`rm -r coverage`, { stdio: 'inherit' }); | ||
} | ||
|
||
if (!fs.existsSync('.release')) { | ||
console.log('No in progress release found'); | ||
process.exit(0); | ||
} | ||
|
||
const tmp = fs.readFileSync('.release'); | ||
|
||
if (fs.existsSync(tmp)) { | ||
execSync(`rm -r ${tmp}`, { stdio: 'inherit' }); | ||
} | ||
|
||
execSync(`rm -r .release`, { stdio: 'inherit' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters