Files
sandbox-runtime/.github/workflows/release.yml
2026-02-19 14:48:18 -08:00

50 lines
1.3 KiB
YAML

name: Release
on:
release:
types: [published]
permissions:
contents: read
id-token: write
jobs:
publish:
name: Publish to npm
runs-on: ubuntu-latest
environment: npm
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Verify release tag is on main
run: |
git fetch origin main
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
echo "::error::Release tag points to a commit not on main. Refusing to publish unreviewed code."
exit 1
fi
- name: Verify tag matches package.json version
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
PKG_VERSION=$(node -p "require('./package.json').version")
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
echo "::error::Tag version ($TAG_VERSION) doesn't match package.json ($PKG_VERSION)"
exit 1
fi
- uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- run: npm install
- run: npm run clean && npm run build
- name: Publish to npm
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}