Skip to content

Release (bump version, tag, publish) #20

Release (bump version, tag, publish)

Release (bump version, tag, publish) #20

Workflow file for this run

name: Release (bump version, tag, publish)
on:
workflow_dispatch:
inputs:
bump:
description: Version bump (patch/minor/major)
required: true
default: patch
type: choice
options:
- patch
- minor
- major
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write # npm publish → GitHub Packages (GITHUB_TOKEN)
id-token: write # npm publish → registry.npmjs.org (OIDC)
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://npm.pkg.github.com
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
- name: Configure git identity
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version and create tag
run: |
npm version "${{ inputs.bump }}" -m "chore(release): %s"
- name: Read new tag
id: tag
run: |
VERSION=$(node -p "require('./package.json').version")
echo "name=v$VERSION" >> "$GITHUB_OUTPUT"
- name: Push commit and tags
run: git push --follow-tags
- name: Build CLI (create dist/)
run: npm run build
env:
ENSEMBLE_FIREBASE_API_KEY: ${{ secrets.ENSEMBLE_FIREBASE_API_KEY }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.name }}
generate_release_notes: true
- name: Publish to GitHub Packages
run: npm publish --registry=https://npm.pkg.github.com
env:
NODE_AUTH_TOKEN: ${{ github.token }}
- name: Publish to npm (trusted publishing / OIDC)
run: |
npm install -g npm@latest
npm publish --registry=https://registry.npmjs.org --provenance