Skip to content

Update action

Update action #7

Workflow file for this run

name: Build and Publish to npm
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-*'
jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
if [[ "$VERSION" == *-* ]]; then
echo "DRY_RUN=true" >> $GITHUB_OUTPUT
else
echo "DRY_RUN=false" >> $GITHUB_OUTPUT
fi
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Update package.json version
run: npm version ${{ steps.version.outputs.VERSION }} --no-git-tag-version
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Build
run: npm run build
- name: Verify build output
run: |
echo "📦 Version: ${{ steps.version.outputs.VERSION }}"
echo "🧪 Dry run: ${{ steps.version.outputs.DRY_RUN }}"
ls -la dist/
- name: Publish to npm (Dry Run)
if: steps.version.outputs.DRY_RUN == 'true'
run: npm publish --dry-run
- name: Publish to npm
if: steps.version.outputs.DRY_RUN == 'false'
run: npm publish --provenance --access public