Skip to content

Publish

Publish #5

Workflow file for this run

name: Publish
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., 1.0.0)'
required: true
type: string
dry_run:
description: 'Dry run (do not actually publish)'
required: false
default: 'false'
type: boolean
jobs:
publish:
name: Publish to npm
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Update version (manual trigger only)
if: github.event_name == 'workflow_dispatch'
run: npm version ${{ inputs.version }} --no-git-tag-version
- name: Publish to npm
if: ${{ github.event.inputs.dry_run != 'true' }}
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Dry run
if: ${{ github.event.inputs.dry_run == 'true' }}
run: npm publish --access public --dry-run
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish to npm as @getlatedev/cli (legacy, backwards compat)
if: ${{ github.event.inputs.dry_run != 'true' }}
run: |
node -e "const p=JSON.parse(require('fs').readFileSync('package.json','utf8')); p.name='@getlatedev/cli'; require('fs').writeFileSync('package.json', JSON.stringify(p, null, 2)+'\n')"
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Dry run (@getlatedev/cli)
if: ${{ github.event.inputs.dry_run == 'true' }}
run: |
node -e "const p=JSON.parse(require('fs').readFileSync('package.json','utf8')); p.name='@getlatedev/cli'; require('fs').writeFileSync('package.json', JSON.stringify(p, null, 2)+'\n')"
npm publish --access public --dry-run
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/') && github.event.inputs.dry_run != 'true'
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
body: |
## Installation
```bash
npm install -g @zernio/cli@${{ github.ref_name }}
```
## Changelog
See the commit history for details.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}