Skip to content

0.2.0

0.2.0 #21

Workflow file for this run

name: CI
on:
push:
pull_request:
workflow_dispatch:
jobs:
test:
name: Build & test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [22.x, 24.x, latest]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: npm
cache-dependency-path: 'package.json'
check-latest: true
- run: npm install
- run: npm run build
- run: npm test
publish:
name: Publish to npm
needs: test
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment:
name: npm
url: https://www.npmjs.com/package/unproto
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24.x
registry-url: 'https://registry.npmjs.org'
cache: npm
cache-dependency-path: 'package.json'
# Trusted publishing (tokenless OIDC) needs npm >= 11.5.1
- run: npm install -g npm@^11
- run: npm install
- run: npm run build
- name: Verify tag matches package.json version
id: version-check
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 (v$TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)"
exit 1
fi
if echo "$PACKAGE_VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "is_prerelease=false" >> $GITHUB_OUTPUT
else
echo "is_prerelease=true" >> $GITHUB_OUTPUT
fi
- name: Publish to npm
run: |
if [ "${{ steps.version-check.outputs.is_prerelease }}" == "true" ]; then
npm stage publish --provenance --tag test
npm dist-tag rm unproto test --silent
else
npm stage publish --provenance
fi