-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add changelog file to the root * add npm install instructions * add release scripts * improve the release scripts * use origin and master as github references * fix changelog release 0.1.0 link * add the publish script * stop building docs before npm publishing
- Loading branch information
1 parent
e84aa1e
commit 9f0a70b
Showing
13 changed files
with
260 additions
and
33 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
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,14 @@ | ||
# Change Log | ||
|
||
## [v0.1.0](https://github.com/auth0/auth0-angular/tree/v0.1.0) (2020-07-31) | ||
|
||
**Early Access Release** | ||
Do not use it in a Production environment. | ||
|
||
### Installation | ||
|
||
In order to install this package on your application, download the `auth0-auth0-angular-0.1.0.tgz` file from the Releases section on the Github repository and run the following command: | ||
|
||
```bash | ||
npm install /path/to/auth0-auth0-angular-0.1.0.tgz | ||
``` |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,62 @@ | ||
if (process.platform === 'win32') { | ||
console.error('Must be run on a Unix OS'); | ||
process.exit(1); | ||
} | ||
|
||
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 repo = 'auth0-angular'; | ||
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', | ||
}); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const exec = require('child_process').exec; | ||
|
||
module.exports = (cmd) => { | ||
return new Promise((resolve, reject) => { | ||
exec(cmd, (error, stdout, stderr) => { | ||
if (error) { | ||
reject(error); | ||
} | ||
resolve(stdout ? stdout : stderr); | ||
}); | ||
}); | ||
}; |
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,6 @@ | ||
const ALLOWED = !!process.env.ALLOWED; | ||
|
||
if (!ALLOWED) { | ||
console.log('Run `npm run release:publish` to publish the package'); | ||
process.exit(1); //which terminates the publish process | ||
} |
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,47 @@ | ||
const fs = require('fs'); | ||
const exec = require('./exec'); | ||
const execSync = require('child_process').execSync; | ||
const path = require('path'); | ||
const { syncBuiltinESMExports } = require('module'); | ||
|
||
if (!fs.existsSync('.release')) { | ||
console.error(`There's no release pending publication.`); | ||
process.exit(1); | ||
} | ||
|
||
const tmp = fs.readFileSync('.release', 'utf-8'); | ||
const versionFilePath = path.resolve(tmp, 'current-version'); | ||
const unpublishedFilePath = path.resolve(tmp, 'unpublished'); | ||
|
||
if (!fs.existsSync(unpublishedFilePath) || !fs.existsSync(versionFilePath)) { | ||
console.error( | ||
`The last release preparation did not complete successfully. Run 'npm run release:clean' and then 'npm run release' to start all over again.` | ||
); | ||
console.info( | ||
`If the Release PR was already merged into the base branch and only the npm publication is pending, manually run 'npm run build:prod' and then 'ALLOWED=true npm publish ./dist/auth0-angular'.` | ||
); | ||
process.exit(1); | ||
} | ||
|
||
const currentVersion = fs.readFileSync(versionFilePath, 'utf-8'); | ||
|
||
(async () => { | ||
console.log('Preparing the package for publication...'); | ||
await exec(`git checkout v${currentVersion}`); | ||
|
||
/* | ||
The command below ensures the ./dist folder has prod-ready content. | ||
It will NOT regenerate the docs nor the useragent file, which | ||
should already be updated as part of the last tagged commit. | ||
*/ | ||
await exec('npm run build:prod'); | ||
|
||
console.log('Uploading to npm, you might be prompted for the OTP...'); | ||
|
||
execSync(`ALLOWED=true npm publish ./dist/auth0-angular`, { | ||
stdio: 'inherit', | ||
}); | ||
|
||
console.log('Done!'); | ||
await exec('npm run release:clean'); | ||
})(); |
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,72 @@ | ||
const fs = require('fs'); | ||
const exec = require('./exec'); | ||
const writeChangelog = require('./changelog'); | ||
const path = require('path'); | ||
const tmp = fs.mkdtempSync(`.release-tmp-`); | ||
const libPkg = require('../projects/auth0-angular/package.json'); | ||
|
||
if (!fs.existsSync('.release')) { | ||
fs.writeFileSync('.release', tmp); | ||
} else { | ||
console.error('Found a pending release. Please run `npm run release:clean`'); | ||
process.exit(1); | ||
} | ||
|
||
const newVersion = process.argv[2]; | ||
if (!newVersion) { | ||
throw new Error('usage: `release new_version [branch]`'); | ||
} | ||
|
||
var lastVersionFile = path.resolve(tmp, 'current-version'); | ||
fs.writeFileSync(lastVersionFile, libPkg.version); | ||
|
||
const branch = process.argv[3] || 'master'; | ||
|
||
(async () => { | ||
if (branch) { | ||
await exec(`git checkout ${branch}`); | ||
} | ||
|
||
await exec('git pull origin master'); | ||
await exec(`git checkout -b prepare/${newVersion}`); | ||
|
||
const newReadme = fs | ||
.readFileSync('./README.md') | ||
.toString() | ||
.replace(libPkg.version, newVersion); | ||
|
||
fs.writeFileSync('./README.md', newReadme); | ||
|
||
fs.writeFileSync( | ||
'./projects/auth0-angular/package.json', | ||
JSON.stringify({ ...libPkg, version: newVersion }, null, 2) | ||
); | ||
|
||
/* | ||
This will take care of: | ||
1. Updating the user agent version | ||
2. Build the app and ensure there are no errors. | ||
3. Generating the docs | ||
*/ | ||
console.log('Building the library...'); | ||
await exec('npm run build'); | ||
|
||
console.log('Fetching the next version changelog...'); | ||
await writeChangelog(newVersion); | ||
|
||
console.log('Committing files and creating the tag...'); | ||
await exec('git add ./projects/auth0-angular/package.json'); | ||
await exec('git add ./projects/auth0-angular/src/useragent.ts'); | ||
await exec('git add ./README.md'); | ||
await exec('git add ./CHANGELOG.md'); | ||
await exec('git add ./docs/'); | ||
await exec(`git commit -am 'Release v${newVersion}'`); | ||
await exec(`git tag v${newVersion}`); | ||
|
||
var unpublishedFile = path.resolve(tmp, 'unpublished'); | ||
fs.closeSync(fs.openSync(unpublishedFile, 'w')); | ||
|
||
console.log( | ||
'Done! If the diff looks OK, push the changes along with the new tag using "git push origin master --tags". Once the PR is merged, come back and run "npm run release:publish".' | ||
); | ||
})(); |