Skip to content

NPM publish action

NPM publish action #1

Workflow file for this run

name: Publish to npm
on:
workflow_dispatch:
inputs:
version_bump:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
dry_run:
description: 'Dry run (skip actual publish)'
required: false
default: false
type: boolean
jobs:
publish:
runs-on: ubuntu-latest
# Only allow publishing from master branch
if: github.ref == 'refs/heads/master'
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test
- name: Build
run: npm run build
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version
run: npm version ${{ inputs.version_bump }} -m "chore: release v%s"

Check failure on line 54 in .github/workflows/publish.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/publish.yml

Invalid workflow file

You have an error in your yaml syntax on line 54
- name: Push version commit and tag
if: ${{ inputs.dry_run == false }}
run: git push --follow-tags
- name: Publish to npm
if: ${{ inputs.dry_run == false }}
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Dry run summary
if: ${{ inputs.dry_run == true }}
run: |
echo "🧪 Dry run completed successfully!"
echo "Version would be: $(node -p "require('./package.json').version")"
echo "Package contents:"
npm pack --dry-run