Skip to content

Commit 5bb4118

Browse files
committed
Add action to publish to npm
1 parent b08ca87 commit 5bb4118

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

.github/workflows/publish.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: npm publish
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- id: get-nvmrc
11+
run: echo VERSION=$(cat .nvmrc) >> $GITHUB_OUTPUT
12+
- id: get-tag
13+
run: |
14+
if [[ $GITHUB_REF =~ [0-9]+.[0-9]+.[0-9]+$ ]]; then
15+
echo TAG=latest >> $GITHUB_OUTPUT
16+
else
17+
echo TAG=beta >> $GITHUB_OUTPUT
18+
fi
19+
- uses: actions/setup-node@v3
20+
with:
21+
registry-url: https://registry.npmjs.org
22+
node-version: ${{ steps.get-nvmrc.outputs.VERSION }}
23+
- run: npm ci
24+
env:
25+
NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_KEY }}
26+
- run: npm run test
27+
- run: npm run build
28+
- run: npm version ${{ github.event.release.tag_name }} --no-git-tag-version
29+
- run: npm publish --tag ${{ steps.get-tag.outputs.TAG }}
30+
env:
31+
NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_KEY }}

0 commit comments

Comments
 (0)