* ci: automate release process with workflow-driven version bumps and PR flow Adds a Release workflow that bumps all package versions, generates release notes, and opens a PR. Merging the PR auto-tags and creates the GitHub Release, which triggers npm-publish. Also adds `npm run bump` for local use and a release.yml config for categorized auto-generated notes. * ci: simplify release workflow and flatten npm-publish approval chain - Drop auto-generated RELEASES.md prepending (notes are written manually in PR) - Flatten npm-publish job dependencies so all publish jobs wait for approval together instead of sequentially, reducing 3 approval clicks to 1 - Remove Release environment from publish-mcpb (only needs GH_TOKEN) - Use --generate-notes for GitHub Release creation * fix: address review findings in release automation - release.yml: use RELEASE_TOKEN PAT for gh release create so the release:published event triggers npm-publish (GITHUB_TOKEN events don't cascade to other workflows) - release.yml: checkout merge_commit_sha in tag job instead of ref:main to avoid tagging later commits - release.yml: checkout ref:main in prepare job so dispatching from a feature branch doesn't pollute the release PR - release.yml: constrain preid to type:choice[beta] to match npm-publish.yml's tag detection - release.yml: drop -f on push so re-runs fail loudly instead of clobbering manual RELEASES.md edits; drop pr-edit fallback - release.yml: ensure release label exists before gh pr create - release.yml: make tag push idempotent for re-runs after partial failure - bump-version.mjs: update workspace dependency ranges so major bumps don't leave examples pointing at the old major - bump-version.mjs: run npm install --package-lock-only so npm ci on the release PR doesn't fail on lockfile mismatch - npm-publish.yml: add npm-tag detection to publish-examples so beta example releases don't overwrite latest - .github/release.yml: use [bot] suffix in author excludes so dependabot PRs are actually filtered from release notes - CONTRIBUTING.md: document RELEASE_TOKEN setup; fix npm run -- syntax * style: auto-fix prettier formatting * build: add npm run bump; parallel npm-publish approval - scripts/bump-version.mjs (+ npm run bump): bumps root and all workspace package versions, updates examples' ^X.Y.0 dependency range on the root package (matters on major bumps), and refreshes package-lock so npm ci accepts the release PR. - npm-publish.yml: all publish jobs now depend directly on [build, test] instead of chaining, so they enter "waiting for approval" together and a single Review-deployments click approves the lot. Prerelease versions (any X.Y.Z-…) publish under --tag beta so they don't take latest. - CONTRIBUTING.md: release steps now use npm run bump. Dropped from the original change: the workflow_dispatch release.yml (required a long-lived PAT to cascade events), label-based .github/release.yml auto-notes (PRs aren't labeled today), and the release-X.Y npm-tag for non-main branches (no backport branches yet). --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
182 lines
4.8 KiB
YAML
182 lines
4.8 KiB
YAML
name: Publish to npm
|
|
|
|
on:
|
|
release:
|
|
types: [published]
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: latest
|
|
- uses: actions/setup-node@v6
|
|
with:
|
|
node-version: "22"
|
|
cache: npm
|
|
- run: npm ci
|
|
- run: npm run build
|
|
- run: npm run prettier
|
|
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: latest
|
|
- uses: actions/setup-node@v6
|
|
with:
|
|
node-version: "22"
|
|
cache: npm
|
|
- run: npm ci
|
|
- run: npm test
|
|
|
|
# All publish jobs depend directly on [build, test] (not on each other) so
|
|
# they all enter "waiting for approval" together and can be approved in a
|
|
# single "Review deployments" click.
|
|
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'release'
|
|
environment: Release
|
|
needs: [build, test]
|
|
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: latest
|
|
- uses: actions/setup-node@v6
|
|
with:
|
|
node-version: "22"
|
|
cache: npm
|
|
registry-url: "https://registry.npmjs.org"
|
|
- run: npm ci
|
|
|
|
- name: Determine npm tag
|
|
id: npm-tag
|
|
run: |
|
|
VERSION=$(node -p "require('./package.json').version")
|
|
# Check if this is a beta release
|
|
if [[ "$VERSION" == *"-beta"* ]]; then
|
|
echo "tag=--tag beta" >> $GITHUB_OUTPUT
|
|
# Check if this release is from a non-main branch (patch/maintenance release)
|
|
elif [[ "${{ github.event.release.target_commitish }}" != "main" ]]; then
|
|
# Use "release-X.Y" as tag for old branch releases
|
|
MAJOR_MINOR=$(echo "$VERSION" | cut -d. -f1,2)
|
|
echo "tag=--tag release-${MAJOR_MINOR}" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "tag=" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- run: npm publish --provenance --access public ${{ steps.npm-tag.outputs.tag }}
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_SECRET }}
|
|
|
|
publish-examples:
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'release'
|
|
environment: Release
|
|
needs: [build, test]
|
|
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
example:
|
|
- basic-server-preact
|
|
- basic-server-react
|
|
- basic-server-solid
|
|
- basic-server-svelte
|
|
- basic-server-vanillajs
|
|
- basic-server-vue
|
|
- budget-allocator-server
|
|
- cohort-heatmap-server
|
|
- customer-segmentation-server
|
|
- debug-server
|
|
- map-server
|
|
- pdf-server
|
|
- scenario-modeler-server
|
|
- shadertoy-server
|
|
- sheet-music-server
|
|
- system-monitor-server
|
|
- threejs-server
|
|
- transcript-server
|
|
- video-resource-server
|
|
- wiki-explorer-server
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: latest
|
|
- uses: actions/setup-node@v6
|
|
with:
|
|
node-version: "22"
|
|
cache: npm
|
|
registry-url: "https://registry.npmjs.org"
|
|
- run: npm ci
|
|
|
|
- name: Build example
|
|
run: npm run build --workspace examples/${{ matrix.example }}
|
|
|
|
- name: Determine npm tag
|
|
id: npm-tag
|
|
run: |
|
|
VERSION=$(node -p "require('./package.json').version")
|
|
if [[ "$VERSION" == *"-"* ]]; then
|
|
echo "tag=--tag beta" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "tag=" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Publish example
|
|
run: npm publish --workspace examples/${{ matrix.example }} --provenance --access public ${{ steps.npm-tag.outputs.tag }}
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_SECRET }}
|
|
|
|
publish-mcpb:
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'release'
|
|
environment: Release
|
|
needs: [build, test]
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: latest
|
|
- uses: actions/setup-node@v6
|
|
with:
|
|
node-version: "22"
|
|
cache: npm
|
|
- run: npm ci
|
|
|
|
- name: Build pdf-server + MCPB bundle
|
|
run: npm run build:mcpb --workspace examples/pdf-server
|
|
|
|
- name: Upload MCPB to release
|
|
run: gh release upload "${{ github.event.release.tag_name }}" examples/pdf-server/*.mcpb --clobber
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|