Skip to content

v9.0.0

v9.0.0 #96

Workflow file for this run

name: Publish
on:
release:
types: [published]
permissions:
contents: write
id-token: write # Required for OIDC
jobs:
publish-to-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v6
with:
node-version: 24
cache: 'npm'
- run: npm ci
- run: npm test
- run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'github-actions@localhost'
# Update the version in the package files
- run: |
GIT_TAG="${{github.event.release.tag_name}}"
NEW_VERSION="${GIT_TAG/v/}"
npm version "$NEW_VERSION" --allow-same-version --git-tag-version=false
git add package* && git commit -m "Release $NEW_VERSION"
- run: npm publish --provenance --access=public
- run: git show
- run: |
git fetch origin master
TAG_NAME="${{github.event.release.tag_name}}"
LAST_COMMIT_ID="$(git rev-parse $TAG_NAME)"
MASTER_COMMIT_ID="$(git rev-parse origin/master)"
if [ "$LAST_COMMIT_ID" = "$MASTER_COMMIT_ID" ]; then
git push origin HEAD:master
else
echo "Not pushing to master because the tag we're operating on is behind"
fi
# See https://stackoverflow.com/a/24849501
- run: |
git tag -f "${{github.event.release.tag_name}}" HEAD
git push -f origin "refs/tags/${{github.event.release.tag_name}}"