generated from layer5io/layer5-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from aabidsofi19/ci/release-workflow
[CI] Update release workflow
- Loading branch information
Showing
2 changed files
with
61 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
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,45 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
// for building and release the package | ||
|
||
// bump version | ||
const bump = (version) => { | ||
const packagePath = path.resolve(__dirname, "package.json"); | ||
const package = require(packagePath); | ||
package.version = version; | ||
fs.writeFileSync(packagePath, JSON.stringify(package, null, 2)); | ||
console.log("bumped version to " + version); | ||
}; | ||
|
||
// build | ||
const build = () => { | ||
// nothing here yet | ||
}; | ||
|
||
const publish = () => { | ||
// publish to npm | ||
const execSync = require("child_process").execSync; | ||
execSync("npm publish --verbose", { stdio: [0, 1, 2] }); | ||
console.log("published to npm"); | ||
}; | ||
|
||
// main | ||
const main = () => { | ||
const args = process.argv.slice(2); | ||
const version = args[0]; | ||
if (!version) { | ||
console.error("version is required"); | ||
process.exit(1); | ||
} | ||
try { | ||
bump(version); | ||
build(); | ||
publish(); | ||
console.log("done"); | ||
} catch (e) { | ||
console.error(e); | ||
process.exit(1); | ||
} | ||
}; | ||
|
||
main(); |