Skip to content

Merge pull request #95 from dupontcyborg/1.3.0-prep #28

Merge pull request #95 from dupontcyborg/1.3.0-prep

Merge pull request #95 from dupontcyborg/1.3.0-prep #28

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to release (e.g., v1.0.0)'
required: true
type: string
jobs:
# Validate the release before proceeding
validate:
name: Validate Release
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
version: ${{ steps.get_version.outputs.version }}
tag: ${{ steps.get_version.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from tag
id: get_version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ github.event.inputs.tag }}"
else
TAG="${GITHUB_REF#refs/tags/}"
fi
VERSION="${TAG#v}"
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Release version: ${VERSION}"
- uses: actions/setup-node@v4
with:
node-version: 24
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Verify package.json version matches tag
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
TAG_VERSION="${{ steps.get_version.outputs.version }}"
if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
echo "::error::Package version ($PACKAGE_VERSION) does not match tag version ($TAG_VERSION)"
exit 1
fi
echo "✅ Version verified: $PACKAGE_VERSION"
- name: Check for changelog entry
run: |
if [ -f CHANGELOG.md ]; then
if grep -q "${{ steps.get_version.outputs.version }}" CHANGELOG.md; then
echo "✅ Changelog entry found"
else
echo "::warning::No changelog entry found for version ${{ steps.get_version.outputs.version }}"
fi
else
echo "::warning::CHANGELOG.md not found"
fi
# Run full test suite
test:
name: Full Test Suite
needs: validate
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
node: [20, 22, 24]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'npm'
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- uses: mlugg/setup-zig@v2
with:
version: "0.15.2"
- name: Install dependencies
run: |
pip install "numpy>=2"
npm install
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Run full CI test suite
run: npm run test:ci
# Build production bundles
build:
name: Build Production Bundles
needs: [validate, test]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: 'npm'
- uses: mlugg/setup-zig@v2
with:
version: "0.15.2"
- name: Install dependencies
run: npm install
- name: Build all bundles
run: npm run build
- name: Verify build artifacts
run: |
echo "## Build Artifacts" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| File | Size | Gzipped |" >> $GITHUB_STEP_SUMMARY
echo "|------|------|---------|" >> $GITHUB_STEP_SUMMARY
for file in dist/*.js dist/*.cjs; do
if [ -f "$file" ]; then
size=$(ls -lh "$file" | awk '{print $5}')
gzip -c "$file" > "$file.gz"
gzsize=$(ls -lh "$file.gz" | awk '{print $5}')
rm "$file.gz"
echo "| $(basename $file) | $size | $gzsize |" >> $GITHUB_STEP_SUMMARY
fi
done
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ needs.validate.outputs.version }}
path: dist/
retention-days: 90
# Publish to npm (requires manual approval via 'release' environment)
publish:
name: Publish to npm
needs: [validate, test, build]
runs-on: ubuntu-latest
environment:
name: release
url: https://www.npmjs.com/package/numpy-ts
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- uses: mlugg/setup-zig@v2
with:
version: "0.15.2"
- name: Upgrade npm (required for OIDC trusted publishing)
run: npm i -g npm@^11.5.1
- name: Show npm version (debug)
run: npm --version
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist-${{ needs.validate.outputs.version }}
path: dist/
- name: Publish to npm
run: npm publish --access public
- name: Create release summary
run: |
echo "## 🚀 Release Published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: ${{ needs.validate.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Tag**: ${{ needs.validate.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "- **npm**: https://www.npmjs.com/package/numpy-ts/v/${{ needs.validate.outputs.version }}" >> $GITHUB_STEP_SUMMARY
# Create GitHub Release
github-release:
name: Create GitHub Release
needs: [validate, publish]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist-${{ needs.validate.outputs.version }}
path: dist/
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.validate.outputs.tag }}
draft: false
prerelease: ${{ contains(needs.validate.outputs.version, '-') }}
files: |
dist/*.js
dist/*.cjs
dist/*.map
token: ${{ secrets.GITHUB_TOKEN }}
- name: Post release summary
run: |
echo "## ✅ GitHub Release Created" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Release**: ${{ needs.validate.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "- **URL**: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ needs.validate.outputs.tag }}" >> $GITHUB_STEP_SUMMARY