Skip to content

Release (manual)

Release (manual) #1

name: Release (manual)
on:
workflow_dispatch:
inputs:
tag:
description: "Release tag (e.g., v1.0.0)"
required: true
type: string
name:
description: "Release title (optional; defaults to package name + tag)"
required: false
type: string
draft:
description: "Create as draft"
required: false
type: boolean
default: false
prerelease:
description: "Mark as prerelease"
required: false
type: boolean
default: false
permissions:
contents: write
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build library
run: npm run build
- name: Validate tag equals package.json version
run: |
PKG_VERSION=$(node -p "require('./package.json').version")
TAG="${{ github.event.inputs.tag }}"
TAG_STRIPPED="${TAG#v}"
echo "package.json version: $PKG_VERSION"
echo "input tag: $TAG (stripped: $TAG_STRIPPED)"
if [ "$PKG_VERSION" != "$TAG_STRIPPED" ]; then
echo "::error::Tag $TAG does not match package.json version $PKG_VERSION" && exit 1
fi
- name: Zip dist artifacts
run: |
TAG=${{ github.event.inputs.tag }}
ZIP_NAME="tweakpane-compact-kit-${TAG}-dist.zip"
zip -r "$ZIP_NAME" dist/
echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_ENV
- name: Zip JS-only artifacts (ES/UMD)
run: |
TAG=${{ github.event.inputs.tag }}
JS_ZIP_NAME="tweakpane-compact-kit-${TAG}-js.zip"
# Include only .js files from dist
(cd dist && zip -r "../$JS_ZIP_NAME" . -i '*.js')
echo "JS_ZIP_NAME=$JS_ZIP_NAME" >> $GITHUB_ENV
- name: Create or update GitHub Release and upload assets
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.tag }}
name: ${{ github.event.inputs.name || format('tweakpane-compact-kit {0}', github.event.inputs.tag) }}
draft: ${{ github.event.inputs.draft }}
prerelease: ${{ github.event.inputs.prerelease }}
generate_release_notes: true
target_commitish: ${{ github.sha }}
files: |
${{ env.ZIP_NAME }}
${{ env.JS_ZIP_NAME }}