Files
kill-the-news/.github/workflows/release.yml
T
Julien Herr d2f3e1ca27 ci(release): derive release version from the tag, not the commit
The release job built whatever version package.json held at the tagged
commit — but main always carries a -develop suffix, so a vX.Y.Z bundle
would have reported X.Y.Z-develop. Make the tag the source of truth:
strip the suffix in the ephemeral CI checkout before building (never
committed), and fail fast when the tag base doesn't match package.json's
base (wrong-commit guard). Update CONTRIBUTING with the tag-driven flow.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 16:08:24 +02:00

64 lines
2.0 KiB
YAML

name: Release
on:
push:
tags:
- "v*"
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 22
cache: npm
- run: npm ci
# The tag is the source of truth for a release version. main always carries
# a `-develop` pre-release suffix, so strip it here (in the ephemeral CI
# checkout only — never committed) so the built bundle reports the bare
# X.Y.Z. Guard against tagging the wrong commit: the tag's base must match
# package.json's base version.
- name: Align package.json version to the tag
env:
TAG_NAME: ${{ github.ref_name }}
run: |
VERSION="${TAG_NAME#v}"
PKG_BASE="$(node -p 'require("./package.json").version.split("-")[0]')"
if [ "$VERSION" != "$PKG_BASE" ]; then
echo "Tag $TAG_NAME (base $VERSION) does not match package.json base ($PKG_BASE)." >&2
echo "Tag the commit whose package.json is ${VERSION}-develop." >&2
exit 1
fi
npm version "$VERSION" --no-git-tag-version --allow-same-version
- run: npm run build
- name: Locate bundled output
id: bundle
run: |
for f in dist/index.js dist/worker.js dist/_worker.js; do
if [ -f "$f" ]; then
echo "path=$f" >> "$GITHUB_OUTPUT"
exit 0
fi
done
echo "No bundled output found in dist/" >&2
exit 1
- name: Create GitHub Release and upload bundle
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.ref_name }}
BUNDLE_PATH: ${{ steps.bundle.outputs.path }}
run: |
gh release create "$TAG_NAME" --generate-notes --verify-tag || true
gh release upload "$TAG_NAME" "$BUNDLE_PATH" --clobber