Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@ name: Publish to npm

on:
push:
branches: [main]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Release instructions are outdated

The Releasing section in README.md still says only tags publish and branch pushes never release to npm. This workflow now publishes an unpublished version as soon as it reaches main, so maintainers following those instructions could publish before they expect to. Update the release instructions alongside this change.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code

tags:
- "v*"
pull_request:
branches: ["*"]
# Serialize releases so a main push and its tag cannot publish concurrently.
concurrency:
group: npm-${{ github.event_name == 'push' && 'publish' || github.ref }}
cancel-in-progress: false
Comment on lines +11 to +13

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Waiting releases get canceled

All pushes share npm-publish, but GitHub Actions keeps only one running run and one pending run per group. cancel-in-progress: false protects the running run, not the pending one. If one release is running, another version's tag is pending, and a newer main push arrives, the tag run is canceled and that version never publishes. Use a queue that preserves waiting releases while keeping publication serialized.

Fix in Claude Code


env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

jobs:
publish:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
permissions:
contents: read
id-token: write
Expand All @@ -28,10 +34,27 @@ jobs:
run: vp install
- name: Build
run: vp run build
- name: Check release version
id: release
if: github.event_name == 'push'
shell: bash
run: |
node --input-type=module <<'NODE'
import { readFileSync, appendFileSync } from 'node:fs';
const { name, version } = JSON.parse(readFileSync('package.json', 'utf8'));
const ref = process.env.GITHUB_REF;
if (ref.startsWith('refs/tags/') && ref !== `refs/tags/v${version}`) {
throw new Error(`Tag ${ref} does not match package version ${version}`);
}
const response = await fetch(`https://registry.npmjs.org/${encodeURIComponent(name)}/${encodeURIComponent(version)}`);
if (!response.ok && response.status !== 404) {
throw new Error(`npm version lookup failed: ${response.status}`);
}
appendFileSync(process.env.GITHUB_OUTPUT, `publish=${response.status === 404}\n`);
console.log(response.ok ? `${name}@${version} already published; skipping` : `Publishing ${name}@${version}`);
NODE
- name: Publish Package
# publish only on v* tag pushes — PR runs are CI-only (a PR run once
# published a version before the tag did)
if: startsWith(github.ref, 'refs/tags/v')
if: steps.release.outputs.publish == 'true'
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand All @@ -42,12 +65,12 @@ jobs:
channel: '#alerts-deploys'
message:
'Charizard was successfully published to npm'
if: success() && startsWith(github.ref, 'refs/tags/v')
if: success() && steps.release.outputs.publish == 'true'
- name: slack - build failed
uses: act10ns/slack@v2.2.0
with:
status: ${{ job.status }}
channel: '#alerts-deploys'
message:
'Charizard has failed to publish to npm'
if: failure() && startsWith(github.ref, 'refs/tags/v')
if: failure() && github.event_name == 'push'
8 changes: 4 additions & 4 deletions .github/workflows/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- uses: voidzero-dev/setup-vp@v1
Expand All @@ -31,16 +31,16 @@ jobs:
# Lets the star count refresh without hitting the anonymous rate limit.
# A failed fetch is non-fatal — the committed count is kept.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-pages-artifact@v4
- uses: actions/upload-pages-artifact@v5
with:
path: dist-site

deploy:
needs: build
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v5