Skip to content

0.3.5

0.3.5 #8

Workflow file for this run

name: Publish to npm
on:
push:
tags:
- 'v*.*.*' # Triggers on version tags like v1.0.0, v1.2.3, etc.
jobs:
build-and-test:
name: Build and Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Type check
run: npm run typecheck
- name: Lint
run: npm run lint
- name: Run tests
run: npm test
- name: Build
run: npm run build
- name: Verify build output
shell: bash
run: |
if [ ! -f "dist/index.js" ]; then
echo "Build failed - dist/index.js not found"
exit 1
fi
echo "Build successful - dist/index.js exists"
publish:
name: Publish to npm
needs: build-and-test
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # Required for npm provenance
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Verify package.json version matches tag
shell: bash
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v}
PACKAGE_VERSION=$(node -p "require('./package.json').version")
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
echo "Error: Tag version ($TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)"
exit 1
fi
echo "Version check passed: $PACKAGE_VERSION"
- name: Publish to npm
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}