Skip to content

fix: npm publish for public repo #10

fix: npm publish for public repo

fix: npm publish for public repo #10

Workflow file for this run

name: Publish SDK package on NPM
on:
push:
tags:
- v*
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout
- uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_PUBLIC }}
run: |
REG_TAG_PART="v[[:digit:]]+([[:punct:]]+[[:digit:]]){2}"
REG_TAG="^$REG_TAG_PART$"
REG_TAG_ALPHA="^$REG_TAG_PART-alpha[[:punct:]][[:digit:]]+$"
VERSION=$GITHUB_REF_NAME
echo version: $VERSION
npm ci && npm run build
npm version $VERSION --no-git-tag-version
if [[ $VERSION =~ $REG_TAG ]]; then
npm publish -f
elif [[ $VERSION =~ $REG_TAG_ALPHA ]]; then
npm publish -f --tag alpha
else
echo invalid tag name: $VERSION
exit 1
fi