Skip to content

Deploy (manual)

Deploy (manual) #86

name: publish-package
on:
workflow_dispatch:
inputs:
version:
description: 'Package version (e.g., 0.2.9)'
required: true
type: string
tag:
description: 'NPM tag (latest, beta, next, etc.)'
required: false
default: 'latest'
type: string
jobs:
test:
name: Run Tests
uses: ./.github/workflows/ci.yml
publish:
name: Publish Package
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
- name: Install dependencies
run: yarn install --immutable
- name: Update version
run: |
npm version ${{ github.event.inputs.version }} --no-git-tag-version
echo "Updated package.json to version ${{ github.event.inputs.version }}"
- name: Build package
run: yarn prepare
- name: Commit version bump
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add package.json
git commit -m "chore: release ${{ github.event.inputs.version }}" || echo "No changes to commit"
- name: Push version bump
run: git push
- name: Create and push tag
run: |
git tag v${{ github.event.inputs.version }}
git push origin v${{ github.event.inputs.version }}
- name: Create GitHub Release
run: |
gh release create v${{ github.event.inputs.version }} \
--title "v${{ github.event.inputs.version }}" \
--generate-notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Configure npm for publishing
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Publish to NPM
run: npm publish --tag ${{ github.event.inputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}