File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Build & Publish to npm
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ jobs :
9+ build-and-publish :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - name : Checkout repo
14+ uses : actions/checkout@v4
15+
16+ - name : Set up Node
17+ uses : actions/setup-node@v4
18+ with :
19+ node-version : 20
20+ registry-url : https://registry.npmjs.org/
21+
22+ - name : Install dependencies
23+ run : npm ci
24+
25+ - name : Run build
26+ run : npm run build
27+
28+ - name : Check if version already exists on npm
29+ id : check
30+ run : |
31+ VERSION=$(node -p "require('./package.json').version")
32+ NAME=$(node -p "require('./package.json').name")
33+
34+ if npm view $NAME@$VERSION > /dev/null 2>&1; then
35+ echo "exists=true" >> $GITHUB_OUTPUT
36+ else
37+ echo "exists=false" >> $GITHUB_OUTPUT
38+ fi
39+
40+ - name : Publish to npm
41+ if : steps.check.outputs.exists == 'false'
42+ run : npm publish --access public
43+ env :
44+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
You can’t perform that action at this time.
0 commit comments