Skip to content

fix: npm publish for public repo #3

fix: npm publish for public repo

fix: npm publish for public repo #3

Workflow file for this run

name: Publish SDK package on NPM
on:
push:
tags:
- v*
jobs:
wait:
name: "Wait for tests"
runs-on: ubuntu-latest
steps:
- name: Wait for tests to succeed
uses: lewagon/wait-on-check-action@latest
with:
ref: ${{ github.ref }}
running-workflow-name: 'Test'
check-regexp: Setup and test.*
publish:
name: Publish
runs-on: ubuntu-latest
needs: wait
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
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:]]+$"
npm ci && npm run build
npm version $BRANCH_NAME
if [[ $BRANCH_NAME =~ $REG_TAG ]]; then
npm publish
elif [[ $BRANCH_NAME =~ $REG_TAG_ALPHA ]]; then
npm publish --tag alpha
else
echo invalid tag name: $BRANCH_NAME
exit 1
fi