Skip to content

Framework Release

Framework Release #2

name: Framework Release
on:
push:
tags:
- 'framework-v*'
workflow_dispatch:
inputs:
dry_run:
description: 'Run npm publish in dry-run mode'
type: boolean
default: true
concurrency:
group: framework-release-${{ github.ref_name }}
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Resolve package directory
id: package-dir
shell: bash
run: |
if [ -d "framework" ]; then
echo "dir=framework" >> "$GITHUB_OUTPUT"
elif [ -d "interdead-framework" ]; then
echo "dir=interdead-framework" >> "$GITHUB_OUTPUT"
else
echo "Expected package directory framework or interdead-framework." >&2
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: ${{ steps.package-dir.outputs.dir }}/package-lock.json
registry-url: https://registry.npmjs.org
- name: Verify release tag matches package version
if: github.event_name == 'push'
shell: bash
run: |
TAG_NAME="${GITHUB_REF_NAME}"
if [[ ! "$TAG_NAME" =~ ^framework-v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
echo "Tag '$TAG_NAME' must match framework-vX.Y.Z" >&2
exit 1
fi
TAG_VERSION="${BASH_REMATCH[1]}"
PKG_VERSION="$(node -p "require('./${{ steps.package-dir.outputs.dir }}/package.json').version")"
if [[ "$TAG_VERSION" != "$PKG_VERSION" ]]; then
echo "Tag version '$TAG_VERSION' does not match package.json version '$PKG_VERSION'." >&2
exit 1
fi
echo "Validated version: $TAG_VERSION"
- name: Install dependencies
working-directory: ${{ steps.package-dir.outputs.dir }}
run: npm ci
- name: Check formatting
working-directory: ${{ steps.package-dir.outputs.dir }}
run: npm run format:check
- name: Run tests
working-directory: ${{ steps.package-dir.outputs.dir }}
run: npm test
- name: Build
working-directory: ${{ steps.package-dir.outputs.dir }}
run: npm run build
- name: Validate build artifacts
working-directory: ${{ steps.package-dir.outputs.dir }}
shell: bash
run: |
for artifact in dist/esm dist/cjs dist/browser; do
if [ ! -d "$artifact" ]; then
echo "Missing required build artifact directory: $artifact" >&2
exit 1
fi
done
- name: Create npm auth config
working-directory: ${{ steps.package-dir.outputs.dir }}
shell: bash
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
if [ -z "$NPM_TOKEN" ]; then
echo "NPM_TOKEN secret is not set." >&2
exit 1
fi
cat > .npmrc <<'EOF'
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
EOF
- name: Publish to npm (dry-run)
if: github.event_name == 'workflow_dispatch' && inputs.dry_run
working-directory: ${{ steps.package-dir.outputs.dir }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public --dry-run
- name: Publish to npm
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && !inputs.dry_run)
working-directory: ${{ steps.package-dir.outputs.dir }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public