Loading files
name: Release
# Publishes to npm when a v* tag is pushed, e.g.:
# npm version minor && git push --follow-tags
# workflow_dispatch allows a manual run when a tag already exists.
on:
push:
tags: ['v*']
workflow_dispatch:
permissions:
contents: read
jobs:
# Reuse the exact CI job rather than re-describing it here.
test:
uses: ./.github/workflows/ci.yml
publish:
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # required for npm provenance
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
registry-url: https://registry.npmjs.org
# Fail before doing any work if the version can't be published, so a bad
# release costs seconds instead of a full KiCad-installing CI run.
#
# Note: versions at or below 0.2.1 are unusable. A previous owner of this
# name unpublished in 2022 and npm tombstones those numbers permanently.
# The registry stops advertising that list once a package has live
# versions again, so it cannot be checked here: just never go backwards.
- name: Preflight version check
run: |
VER="$(node -p "require('./package.json').version")"
echo "package.json version: $VER"
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
TAG="${GITHUB_REF_NAME#v}"
if [ "$TAG" != "$VER" ]; then
echo "::error::Tag v$TAG does not match package.json version $VER"
exit 1
fi
fi
if npm view "copperhead@$VER" version > /dev/null 2>&1; then
echo "::error::copperhead@$VER is already published. Bump the version."
exit 1
fi
echo "$VER is free to publish"
- run: npm ci
- run: npm run build
# Provenance works here (unlike locally) because Actions supplies the
# OIDC token that npm attests against.
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
0d71e153eThis file is pinned to the selected release. Download the original to open it in your design tool.