Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Release

on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
tag:
description: Existing tag to publish, e.g. v0.2.0
required: true

permissions:
contents: write
id-token: write

concurrency:
group: release-${{ inputs.tag || github.ref_name }}
cancel-in-progress: false

jobs:
publish:
runs-on: ubuntu-latest
env:
TAG: ${{ inputs.tag || github.ref_name }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.TAG }}
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm
registry-url: https://registry.npmjs.org
# Trusted publishing (OIDC, no token) needs npm 11.5.1 or newer.
- run: npm install -g npm@latest
- run: pnpm install --frozen-lockfile

- name: Check the tag matches package.json
run: |
version="$(node -p "require('./package.json').version")"
if [ "v${version}" != "${TAG}" ]; then
echo "Tag ${TAG} does not match package.json version ${version}" >&2
exit 1
fi

# prepublishOnly runs typecheck, tests and build.
- run: npm publish --provenance --access public

- name: Create the GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
if gh release view "${TAG}" >/dev/null 2>&1; then
echo "Release ${TAG} already exists"
else
gh release create "${TAG}" --verify-tag --generate-notes --title "${TAG}"
fi
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@ vendor/bin/pest
```

Both test suites must pass. The JavaScript and PHP results have to match exactly.

## Releasing

1. Bump `version` in `package.json` and commit it as `🔖 chore(release): x.y.z`.
2. Push a signed tag: `git tag -s vx.y.z -m vx.y.z && git push origin master vx.y.z`.

The tag starts `.github/workflows/release.yml`, which checks the tag against `package.json`, runs the tests, publishes to npm with provenance and creates the GitHub release. Packagist picks up the tag by itself. To publish a tag that already exists, run the workflow by hand with that tag.
Loading