Skip to content

Release

Release #3

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
version:
description: "Version to publish (e.g. 0.2.0, 0.2.0-rc.1)"
required: true
type: string
npm-tag:
description: "npm dist-tag"
required: true
type: choice
options:
- latest
- rc
concurrency:
group: release
cancel-in-progress: false
jobs:
publish:
name: "Publish"
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout tag
uses: actions/checkout@v4
with:
ref: v${{ inputs.version }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Type check
run: npm run check-types
- name: Publish to npm
run: |
VERSION="${{ inputs.version }}"
NAME=$(jq -r .name package.json)
if npm view "${NAME}@${VERSION}" version >/dev/null 2>&1; then
echo "⏭ ${NAME}@${VERSION} already published, skipping."
else
echo "Publishing ${NAME}@${VERSION}..."
npm publish --access public --tag ${{ inputs.npm-tag }}
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub release
run: |
if gh release view "v${{ inputs.version }}" >/dev/null 2>&1; then
echo "GitHub release v${{ inputs.version }} already exists, skipping."
else
PRERELEASE=""
if [ "${{ inputs.npm-tag }}" = "rc" ]; then
PRERELEASE="--prerelease"
fi
gh release create "v${{ inputs.version }}" \
--title "v${{ inputs.version }}" \
--generate-notes \
$PRERELEASE
fi
env:
GH_TOKEN: ${{ github.token }}