Skip to content

Release

Release #20

Workflow file for this run

name: Release
on:
release:
types:
- published
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
cache-dependency-path: ./packages/cli/package-lock.json
# npm Trusted Publishing (OIDC) needs npm >= 11.5.1; the Node
# version above ships an older npm. Pin 11.6.2 for reproducible runs
# (11.5.2 fixed an OIDC/provenance ordering bug, 11.6.2 resolves
# trusted-publishing failures seen in the wild).
- name: Upgrade npm for trusted publishing
run: npm install -g npm@11.6.2
- name: Set version from release tag
working-directory: ./packages/cli
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
TAG="${RELEASE_TAG:-${GITHUB_REF#refs/tags/}}"
VERSION="${TAG#v}"
echo "Setting package version to ${VERSION} from tag ${TAG}"
CURRENT=$(node -p "require('./package.json').version")
if [ "$CURRENT" = "$VERSION" ]; then
echo "package.json already at ${VERSION}, skipping version bump"
else
npm version "${VERSION}" --no-git-tag-version
fi
- name: Install dependencies
run: npm ci
working-directory: ./packages/cli
- name: Build
run: npm run build
working-directory: ./packages/cli
- name: Verify package
run: npm pack
working-directory: ./packages/cli
- name: Publish to NPM
run: npm publish --access public --provenance
working-directory: ./packages/cli