fix: npm publish for public repo #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |