Skip to content

Release Static Site Client #17

Release Static Site Client

Release Static Site Client #17

name: Release Static Site Client
on:
workflow_dispatch:
inputs:
version_type:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
concurrency:
group: sdk-release
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
token: ${{ secrets.RELEASE_PAT || secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: '22.13.1'
registry-url: 'https://registry.npmjs.org'
- name: Upgrade npm for Trusted Publishers
run: npm install -g npm@11.5.1
- name: Install pnpm
run: |
npm install -g corepack@latest
corepack enable
corepack prepare pnpm@11.3.0 --activate
- name: Configure git
run: |
git config --local user.email "${{ secrets.GIT_USER_EMAIL }}"
git config --local user.name "${{ secrets.GIT_USER_NAME }}"
- name: Ensure we have latest main
run: |
git fetch origin main
git reset --hard origin/main
- name: Get current version
id: current_version
working-directory: ./clients/static-site
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
- name: Bump version
id: version
working-directory: ./clients/static-site
run: |
NEW_VERSION=$(npm version ${{ github.event.inputs.version_type }} --no-git-tag-version | sed 's/v//')
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "tag=static-site/v$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Generate changelog
continue-on-error: true
uses: openai/codex-action@a26d2d4d8b78a694338b8e3715c3630254340b2c # v1
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
sandbox: workspace-write
safety-strategy: drop-sudo
prompt: |
Generate release notes for the Vizzly Static Site Plugin v${{ steps.version.outputs.version }}.
Context:
- Client location: `clients/static-site/`
- Previous tag: `static-site/v${{ steps.current_version.outputs.version }}`
- New version: `${{ steps.version.outputs.version }}`
- This is a monorepo with multiple clients and a CLI.
Instructions:
1. Use git commands to inspect commits and changed files since the previous Static Site tag.
2. Analyze which changes are relevant to `clients/static-site/`.
3. Read relevant code changes when commit messages are not enough.
4. Generate user-friendly release notes with categories: Added, Changed, Fixed.
5. Focus on user-facing changes only.
6. If there are no relevant changes, output: "No changes to Static Site plugin in this release".
7. Save the changelog to `clients/static-site/CHANGELOG-RELEASE.md`.
Use this format:
## What's Changed
### Added
- New features
### Changed
- Breaking or notable changes
### Fixed
- Bug fixes
**Full Changelog**: https://github.com/vizzly-testing/cli/compare/static-site/v${{ steps.current_version.outputs.version }}...static-site/v${{ steps.version.outputs.version }}
- name: Set Node.js back to release version
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: '22.13.1'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
working-directory: ./clients/static-site
run: pnpm install --frozen-lockfile
- name: Run tests
working-directory: ./clients/static-site
run: pnpm test
- name: Run linter
working-directory: ./clients/static-site
run: pnpm run lint
- name: Verify package version is unpublished
working-directory: ./clients/static-site
run: |
if npm view @vizzly-testing/static-site@${{ steps.version.outputs.version }} version >/dev/null 2>&1; then
echo "@vizzly-testing/static-site@${{ steps.version.outputs.version }} is already published"
exit 1
fi
- name: Update CHANGELOG.md
working-directory: ./clients/static-site
run: |
# Check if changelog was generated successfully
if [ ! -f CHANGELOG-RELEASE.md ]; then
echo "Warning: CHANGELOG-RELEASE.md not found, creating fallback changelog"
cat > CHANGELOG-RELEASE.md << 'EOF'
## What's Changed
Release v${{ steps.version.outputs.version }}
See the full diff for detailed changes.
EOF
fi
# Extract old releases (everything after the first version heading, excluding Unreleased)
PREVIOUS_RELEASES=""
if grep -q "^## \[" CHANGELOG.md 2>/dev/null; then
# Get everything starting from first version (not Unreleased)
PREVIOUS_RELEASES=$(awk '/^## \[[0-9]/{found=1} found' CHANGELOG.md)
fi
# Create new CHANGELOG.md
cat > CHANGELOG.md << EOF
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [${{ steps.version.outputs.version }}] - $(date +%Y-%m-%d)
EOF
# Append the generated release notes
cat CHANGELOG-RELEASE.md >> CHANGELOG.md
# Append previous releases if they exist
if [ -n "$PREVIOUS_RELEASES" ]; then
echo "" >> CHANGELOG.md
echo "$PREVIOUS_RELEASES" >> CHANGELOG.md
fi
rm -f CHANGELOG-RELEASE.md
- name: Build package
working-directory: ./clients/static-site
run: pnpm run build
- name: Pack package
id: pack
working-directory: ./clients/static-site
run: |
PACK_FILE=$(npm pack --ignore-scripts)
echo "file=$PACK_FILE" >> $GITHUB_OUTPUT
- name: Configure git identity
run: |
git config --local user.email "${{ secrets.GIT_USER_EMAIL }}"
git config --local user.name "${{ secrets.GIT_USER_NAME }}"
- name: Commit and push changes
run: |
git add clients/static-site/package.json clients/static-site/CHANGELOG.md
git commit -m "🔖 Static site plugin v${{ steps.version.outputs.version }}"
git push origin main
git tag "${{ steps.version.outputs.tag }}"
git push origin "${{ steps.version.outputs.tag }}"
- name: Publish to npm
working-directory: ./clients/static-site
run: npm publish "${{ steps.pack.outputs.file }}" --provenance --access public
- name: Read changelog for release
id: release_notes
working-directory: ./clients/static-site
run: |
# Extract just this version's changelog
CHANGELOG=$(sed -n '/## \[${{ steps.version.outputs.version }}\]/,/## \[/p' CHANGELOG.md | sed '$ d')
{
echo 'notes<<CHANGELOG_EOF'
echo "$CHANGELOG"
echo 'CHANGELOG_EOF'
} >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: 🏗️ Static Site Plugin v${{ steps.version.outputs.version }}
body: ${{ steps.release_notes.outputs.notes }}
files: ./clients/static-site/${{ steps.pack.outputs.file }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}