Skip to content

Publish CLI to NPM

Publish CLI to NPM #1

Workflow file for this run

name: Publish CLI to NPM
on:
release:
types: [published]
workflow_dispatch:
inputs:
npm_tag:
description: 'NPM tag to publish under (e.g., latest, beta, alpha)'
required: false
default: 'latest'
type: string
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: gateway
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build and bundle
run: |
npm run build
npm run bundle
- name: Remove private flag from package.json
run: |
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
delete pkg.private;
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
- name: Publish to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
NPM_TAG="${{ github.event.inputs.npm_tag || 'latest' }}"
npm publish --tag "$NPM_TAG" --access public