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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ on: | |
types: [created] | ||
workflow_dispatch: | ||
inputs: | ||
release-type: | ||
release-version: | ||
required: true | ||
|
||
jobs: | ||
|
@@ -21,6 +21,7 @@ jobs: | |
node-version: 16 | ||
- run: | | ||
npm install | ||
publish-gpr: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
|
@@ -34,6 +35,19 @@ jobs: | |
node-version: 16 | ||
registry-url: "https://registry.npmjs.org" | ||
scope: "@layer5" | ||
- run: npm publish --verbose | ||
|
||
- name: Run npm release | ||
run: npm run release ${{ github.event.inputs.release-version || github.event.release.tag_name }} | ||
if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' | ||
|
||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Commit and push version change | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_user_name: l5io | ||
commit_user_email: [email protected] | ||
commit_author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | ||
commit_options: "--signoff" | ||
commit_message: "[Release]: Bump version to ${{ github.event.inputs.release-version || github.event.release.tag_name }}" |
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(); |