Skip to content

Publish v0.4.0-dev.1 #23

Publish v0.4.0-dev.1

Publish v0.4.0-dev.1 #23

Workflow file for this run

name: Publish to npm
run-name: Publish v${{ inputs.version }}
on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., 1.0.0, 1.0.1-beta.1)'
required: true
type: string
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Update npm
run: npm install -g npm@latest
- name: Validate version format
run: |
if ! echo "${{ inputs.version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$'; then
echo "Error: Invalid version format. Use semver (e.g., 1.0.0, 1.0.1-beta.1)"
exit 1
fi
- name: Update package version
run: npm version ${{ inputs.version }} --no-git-tag-version
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Build
run: npm run build
- name: Determine npm dist-tag
id: dist-tag
run: |
if [ "${{ github.ref_name }}" = "main" ]; then
echo "tag=latest" >> "$GITHUB_OUTPUT"
else
echo "tag=dev" >> "$GITHUB_OUTPUT"
fi
- name: Publish to npm
run: npm publish --access public --tag ${{ steps.dist-tag.outputs.tag }}
- name: Create git tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add package.json package-lock.json
git commit -m "chore: release v${{ inputs.version }}"
git tag "v${{ inputs.version }}"
git push origin HEAD --tags