File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11name : Node.js CI
22
33on :
4- push :
5- branches : ['main' ]
4+ release :
5+ types : [published ]
66
77jobs :
88 publish-npm :
99 runs-on : ubuntu-latest
1010
1111 steps :
12- - uses : actions/checkout@v3
13- - uses : actions/setup-node@v3
12+ - name : Git checkout
13+ uses : actions/checkout@v3
14+
15+ - name : Setup Node.js (v20.x)
16+ uses : actions/setup-node@v3
1417 with :
1518 node-version : 20.x
1619 registry-url : https://registry.npmjs.org/
17- - run : npm ci
18- - run : npm run build --if-present
20+
21+ - name : Build package
22+ run : |
23+ npm ci
24+ npm run build --if-present
25+
26+ - name : Bump package version
27+ run : |
28+ git config --global user.name="GitHub"
29+ git config --global user.email="<noreply@github.com>"
30+ RELEASE=${{ github.event.release.name}}
31+ NEXT_VERSION=${RELEASE} node ./scripts/tasks/bump-version.js
32+ git add package.json
33+ git commit -m "chore: bump package version to ${RELEASE}"
34+
1935 - run : npm publish --access=public
2036 env :
2137 NODE_AUTH_TOKEN : ${{ secrets.npm_token }}
Original file line number Diff line number Diff line change 1+ const { exec } = require ( 'child_process' ) ;
2+ const package = require ( '../../package.json' ) ;
3+
4+ const version = {
5+ old : package . version ,
6+ next : null ,
7+ } ;
8+
9+ if ( process . env . NEXT_VERSION === null ) {
10+ console . log ( 'NEXT_VERSION could not be `null`.' ) ;
11+ process . exit ( 1 ) ;
12+ }
13+
14+ version . next = process . env . NEXT_VERSION ;
15+
16+ const cmd = `sed -i "s/${ version . old } /${ version . next } /" ./package.json` ;
17+
18+ exec ( cmd , ( error , stdout ) => {
19+ if ( error ) {
20+ console . log ( error . message ) ;
21+ process . exit ( error . code ) ;
22+ }
23+ console . log ( stdout ) ;
24+ process . exit ( 0 ) ;
25+ } ) ;
You can’t perform that action at this time.
0 commit comments