File tree Expand file tree Collapse file tree 2 files changed +61
-2
lines changed Expand file tree Collapse file tree 2 files changed +61
-2
lines changed Original file line number Diff line number Diff line change 88 types : [created]
99 workflow_dispatch :
1010 inputs :
11- release-type :
11+ release-version :
1212 required : true
1313
1414jobs :
2121 node-version : 16
2222 - run : |
2323 npm install
24+
2425 publish-gpr :
2526 needs : build
2627 runs-on : ubuntu-latest
3435 node-version : 16
3536 registry-url : " https://registry.npmjs.org"
3637 scope : " @layer5"
37- - run : npm publish --verbose
38+
39+ - name : Run npm release
40+ run : npm run release ${{ github.event.inputs.release-version || github.event.release.tag_name }}
41+ if : github.event_name == 'workflow_dispatch' || github.event_name == 'release'
42+
3843 env :
3944 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
45+
46+ - name : Commit and push version change
47+ uses : stefanzweifel/git-auto-commit-action@v4
48+ with :
49+ commit_user_name : l5io
50+ commit_user_email : ci@layer5.io
51+ commit_author : ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
52+ commit_options : " --signoff"
53+ commit_message : " [Release]: Bump version to ${{ github.event.inputs.release-version || github.event.release.tag_name }}"
Original file line number Diff line number Diff line change 1+ const fs = require ( "fs" ) ;
2+ const path = require ( "path" ) ;
3+ // for building and release the package
4+
5+ // bump version
6+ const bump = ( version ) => {
7+ const packagePath = path . resolve ( __dirname , "package.json" ) ;
8+ const package = require ( packagePath ) ;
9+ package . version = version ;
10+ fs . writeFileSync ( packagePath , JSON . stringify ( package , null , 2 ) ) ;
11+ console . log ( "bumped version to " + version ) ;
12+ } ;
13+
14+ // build
15+ const build = ( ) => {
16+ // nothing here yet
17+ } ;
18+
19+ const publish = ( ) => {
20+ // publish to npm
21+ const execSync = require ( "child_process" ) . execSync ;
22+ execSync ( "npm publish --verbose" , { stdio : [ 0 , 1 , 2 ] } ) ;
23+ console . log ( "published to npm" ) ;
24+ } ;
25+
26+ // main
27+ const main = ( ) => {
28+ const args = process . argv . slice ( 2 ) ;
29+ const version = args [ 0 ] ;
30+ if ( ! version ) {
31+ console . error ( "version is required" ) ;
32+ process . exit ( 1 ) ;
33+ }
34+ try {
35+ bump ( version ) ;
36+ build ( ) ;
37+ publish ( ) ;
38+ console . log ( "done" ) ;
39+ } catch ( e ) {
40+ console . error ( e ) ;
41+ process . exit ( 1 ) ;
42+ }
43+ } ;
44+
45+ main ( ) ;
You can’t perform that action at this time.
0 commit comments