1+ name : CI
2+
3+ on :
4+ push :
5+ pull_request :
6+ workflow_dispatch :
7+
8+ concurrency :
9+ group : ${{ github.workflow }}-${{ github.ref }}
10+ cancel-in-progress : true
11+
12+ jobs :
13+ version-check :
14+ name : Check Version
15+ runs-on : ubuntu-latest
16+ outputs :
17+ version_changed : ${{ steps.check.outputs.version_changed }}
18+ new_version : ${{ steps.check.outputs.new_version }}
19+
20+ steps :
21+ - name : Checkout Code
22+ uses : actions/checkout@v4
23+
24+ - name : Check the version
25+ id : check
26+ run : |
27+ CURRENT_VERSION=$(jq -r .version package.json)
28+ echo "Current version: $CURRENT_VERSION"
29+ LATEST_VERSION=$(npm view @mercuryworkshop/wisp-js versions --json | jq -r '.[-1]' || echo "0.0.0")
30+ echo "Latest NPM version: $LATEST_VERSION"
31+
32+ if [ "$LATEST_VERSION" != "$CURRENT_VERSION" ];
33+ then
34+ echo "Version changed"
35+ echo "version_changed=true" >> "$GITHUB_OUTPUT"
36+ echo "new_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
37+ else
38+ echo "Version not changed"
39+ echo "version_changed=false" >> "$GITHUB_OUTPUT"
40+ fi
41+
42+ build :
43+ name : Build wisp-js
44+ runs-on : ubuntu-latest
45+
46+ steps :
47+ - name : Checkout code
48+ uses : actions/checkout@v4
49+
50+ - name : Setup Node.js
51+ uses : actions/setup-node@v4
52+ with :
53+ node-version : " 22"
54+ cache : " npm"
55+
56+ - name : Install npm dependencies
57+ run : npm install
58+
59+ - name : Pack wisp-js
60+ run : npm pack
61+
62+ - name : Upload Artifact (packaged)
63+ uses : actions/upload-artifact@v4
64+ with :
65+ name : packaged-wisp-js
66+ path : mercuryworkshop-wisp-js-*.tgz
67+
68+ - name : Upload Artifact
69+ uses : actions/upload-artifact@v4
70+ with :
71+ name : wisp-js
72+ path : |
73+ dist
74+ lib
75+
76+ publish :
77+ name : Publish wisp-js to NPM
78+ runs-on : ubuntu-latest
79+ needs : [version-check, build]
80+ permissions : write-all
81+ if : github.ref == 'refs/heads/master' && needs.version-check.outputs.version_changed == 'true'
82+
83+ steps :
84+ - name : Setup Node.js
85+ uses : actions/setup-node@v4
86+ with :
87+ node-version : " 22"
88+ registry-url : " https://registry.npmjs.org"
89+
90+ - name : Get artifacts
91+ uses : actions/download-artifact@v4
92+ with :
93+ name : packaged-wisp-js
94+ path : .
95+
96+ - name : Update npm
97+ run : npm install -g npm@latest
98+
99+ - name : Publish
100+ run : npm publish mercuryworkshop-wisp-js-${{ needs.version-check.outputs.new_version }}.tgz --access public --no-git-checks
0 commit comments