1- name : Version and Publish to NPM
1+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+ # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
23
3- on :
4- workflow_dispatch :
5- inputs :
6- version :
7- description : ' Specify the version type (path, minor, major)'
8- required : true
9- default : ' patch'
4+ name : Publish Node.js Package
105
11- jobs :
12- build :
13- name : Build
14- runs-on : ubuntu-latest
15- steps :
16- - name : Checkout Repo
17- uses : actions/checkout@v4
18- with :
19- fetch-depth : 0
20- token : ${{ secrets.RELEASEDRAFTER_PAT }}
21- ref : ' master'
22-
23- - name : Setup Node.js 18.x
24- uses : actions/setup-node@v3
25- with :
26- node-version : 18
27- registry-url : " https://registry.npmjs.org"
28- scope : " @layer5"
6+ on :
7+ release :
8+ types : [published]
9+ workflow_dispatch :
10+ inputs :
11+ release-version :
12+ required : true
2913
30- - name : Install deps and build
31- run : |
32- yarn
33- yarn build-all
34-
35- - name : Initialize the NPM config
36- run : npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
37- env :
38- NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
39- GITHUB_AUTH : ${{ secrets.GH_TOKEN }}
40-
41- - name : Initialize Git User
42- run : |
43- git config user.name "${{ github.actor }}"
44- git config user.email "${{ github.actor}}@users.noreply.github.com"
14+ jobs :
15+ build :
16+ runs-on : ubuntu-latest
17+ steps :
18+ - uses : actions/checkout@v4
19+ with :
20+ token : ${{secrets.GH_TOKEN}}
4521
46- - name : Identify changed packages
47- id : changed-packages
48- run : |
49- echo "Changed packages: $(yarn lerna changed --json | jq -r '.[].name')"
22+ - uses : actions/setup-node@v3
23+ with :
24+ node-version : 18
25+ - run : |
26+ npm install
5027
51- - name : Check if there are changed packages
52- run : |
53- echo "Changed packages: ${{ steps.changed-packages.outputs.changed-packages }}"
54- if : steps.changed-packages.outputs.changed-packages != ''
55-
56- - name : Version packages
57- run : |
58- if [ "${{ github.event.inputs.version }}" != 'none' ]; then
59- ./scripts/version-release.sh "${{ steps.changed-packages.outputs.changed-packages }}"
60- else
61- echo "Skipping versioning based on input."
62- fi
63-
64- - name : Use git-auto-commit-action
65- uses : stefanzweifel/git-auto-commit-action@v5
66- with :
67- commit_message : ' chore: publish'
68- commit_user_name : l5io
69- commit_user_email : ci@layer5.io
70- commit_author : ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
71- commit_options : ' --signoff'
72-
73- - name : Create Git tags
74- run : ./scripts/create-multiple-git-tag.sh
75-
76- - name : Publish packages
77- run : make publish-ci
78- env :
79- GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
80- GITHUB_AUTH : ${{ secrets.GH_TOKEN }}
81- NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
82- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
28+ publish-gpr :
29+ needs : build
30+ runs-on : ubuntu-latest
31+ permissions :
32+ contents : read
33+ packages : write
34+ steps :
35+ - uses : actions/checkout@v4
36+ with :
37+ token : ${{secrets.GH_TOKEN}}
38+ - uses : actions/setup-node@v3
39+ with :
40+ node-version : 18
41+ registry-url : " https://registry.npmjs.org"
42+ scope : " @layer5"
43+ - run : npm publish --verbose
44+ env :
45+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
0 commit comments