Skip to content

0.0.2

0.0.2 #2

Workflow file for this run

name: Publish to npm
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+"
jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
registry-url: "https://registry.npmjs.org/"
- name: Determine pre-release tag
run: |
TAG_NAME=${GITHUB_REF_NAME}
echo "Detected tag: $TAG_NAME"
if [[ "$TAG_NAME" == *-alpha.* ]]; then
echo "tag=alpha" >> $GITHUB_ENV
else
echo "tag=latest" >> $GITHUB_ENV
fi
- name: Verify version matches tag
run: |
PKG_VERSION=$(node -p "require('./package.json').version")
TAG_VERSION=${GITHUB_REF_NAME#v}
if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
echo "::error::package.json version ($PKG_VERSION) does not match tag ($TAG_VERSION)"
exit 1
fi
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Build
run: npm run build
- name: Publish
run: npm publish --access public --tag ${{ env.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}