-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bump version and refactor release process
- Loading branch information
Showing
4 changed files
with
46 additions
and
34 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const { execSync } = require("child_process"); | ||
const { version } = require("./package"); | ||
const exec = command => execSync(command, { encoding: "utf8" }).trim(); | ||
|
||
const exitWithError = error => { | ||
process.stderr.write(`\x1b[1;31m${error}\x1b[0m\n\n`); | ||
process.exit(1); | ||
}; | ||
|
||
const gitBranchName = exec("git rev-parse --abbrev-ref HEAD"); | ||
if (gitBranchName !== "master") { | ||
exitWithError("please checkout the master branch to make a release!"); | ||
} | ||
|
||
const workingCopyChanges = exec("git status --porcelain"); | ||
if (workingCopyChanges) { | ||
exitWithError("please commit your changes before making a release!"); | ||
} | ||
|
||
const tagExists = exec(`git tag -l "${version}"`); | ||
if (tagExists) { | ||
exitWithError(`${version} has already been released!`); | ||
} | ||
|
||
execSync( | ||
`npm run release:dry && git tag ${version} && git push && git push --tags && npm publish`, | ||
{ | ||
shell: true, | ||
stdio: "inherit", | ||
cwd: __dirname | ||
} | ||
); |