Skip to content

Publish to npm

Publish to npm #3

Workflow file for this run

name: Publish to npm
on:
workflow_dispatch:
inputs:
dry_run:
type: boolean
default: true
description: 'Dry-run (test without publishing)'
tag:
type: choice
default: 'latest'
options:
- latest
- next
description: 'npm tag (use "next" for pre-release/RC versions)'
# Required for OIDC token exchange with npm (Trusted Publishers)
permissions:
contents: read
id-token: write
jobs:
publish:
runs-on: ubuntu-latest
environment: npm-publish
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Build package
working-directory: src
run: |
npm ci
npm run build
npm test
- name: Show version info
working-directory: src/dist
run: |
VERSION=$(node -p "require('./package.json').version")
echo "📦 Package: angular-cli-ghpages"
echo "📌 Version: $VERSION"
echo "🏷️ Tag: ${{ inputs.tag }}"
echo ""
if [ "${{ inputs.dry_run }}" = "true" ]; then
echo "🧪 Mode: DRY-RUN (no actual publish)"
else
echo "🚀 Mode: PUBLISH FOR REAL"
fi
- name: Publish to npm (dry-run)
if: ${{ inputs.dry_run }}
working-directory: src/dist
run: |
echo ""
echo "==============="
npm publish --provenance --tag ${{ inputs.tag }} --dry-run
echo "==============="
echo ""
echo "✅ Dry-run successful! Package is ready to publish."
echo " To publish for real, run this workflow again with dry_run unchecked."
- name: Publish to npm
if: ${{ !inputs.dry_run }}
working-directory: src/dist
run: |
echo ""
echo "==============="
npm publish --provenance --tag ${{ inputs.tag }}
echo "==============="
echo ""
echo "✅ Published successfully with provenance!"
echo " https://www.npmjs.com/package/angular-cli-ghpages"