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
11 changes: 0 additions & 11 deletions .changeset/config.json

This file was deleted.

2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

### If releasing new changes

- [ ] Ran `pnpm changeset` to generate a changeset file
- [ ] Ran `pnpm change` to generate a change intent file

<!-- For more details check RELEASING.md -->

Expand Down
40 changes: 25 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ permissions:
contents: read

# Concurrency control: only one release process can run at a time
# This prevents race conditions if multiple releasable changesets merge simultaneously
# This prevents race conditions if multiple releasable change intents merge simultaneously
concurrency:
group: release
cancel-in-progress: false

jobs:
check-changesets:
name: Check for changesets
name: Check for change intents
runs-on: ubuntu-latest
outputs:
has-changesets: ${{ steps.check.outputs.has-changesets }}
Expand All @@ -30,16 +30,28 @@ jobs:
fetch-depth: 0
persist-credentials: false

- name: Check for changesets
- name: Check for change intents
id: check
run: |
changeset_count=$(find .changeset -name '*.md' ! -name 'README.md' 2>/dev/null | wc -l)
if [ "$changeset_count" -gt 0 ]; then
shopt -s nullglob
releasable_count=0
for change_intent in .changeset/*.md; do
if awk -v pattern="^[[:space:]]*['\"]?posthog-php['\"]?[[:space:]]*:[[:space:]]*(patch|minor|major)[[:space:]]*$" '
NR == 1 { if ($0 != "---") exit 1; next }
$0 == "---" { found_end = 1; exit }
$0 ~ pattern { releasable = 1 }
END { if (!found_end || !releasable) exit 1 }
' "$change_intent"; then
releasable_count=$((releasable_count + 1))
fi
done

if [ "$releasable_count" -gt 0 ]; then
echo "has-changesets=true" >> "$GITHUB_OUTPUT"
echo "Found $changeset_count changeset(s), ready to release"
echo "Found $releasable_count releasable change intent(s)"
else
echo "has-changesets=false" >> "$GITHUB_OUTPUT"
echo "No changesets to release"
echo "No releasable change intents found"
fi

prepare-release-candidate:
Expand All @@ -64,16 +76,13 @@ jobs:
- name: Setup pnpm and Node.js
uses: pnpm/setup@5d160c5bc68a09337ad0d5654e237e03253b5879 # v1.0.0
with:
# pnpm/setup installs runtimes via pnpm runtime, which requires pnpm >=11.1.0.
version: 11.7.0
# Native release management requires pnpm >=11.13.0.
version: 11.13.1
runtime: node@24
cache: true
install: false

- name: Install release tooling dependencies
run: pnpm install --frozen-lockfile --ignore-scripts

- name: Apply changesets and update version
- name: Apply change intents and update version
id: candidate
env:
# If scripts/bump-version.sh changes, recompute this with:
Expand All @@ -84,7 +93,8 @@ jobs:
set -euo pipefail

source_sha=$(git rev-parse HEAD)
pnpm exec changeset version
pnpm version -r
git add --intent-to-add .changeset/ledger.yaml
new_version=$(node -p "require('./package.json').version")

actual_bump_script_sha256=$(sha256sum scripts/bump-version.sh | awk '{print $1}')
Expand All @@ -103,7 +113,7 @@ jobs:
changed_files=$(git diff --name-only)
while IFS= read -r file; do
case "$file" in
CHANGELOG.md|composer.json|package.json|lib/PostHog.php|.changeset/*.md) ;;
CHANGELOG.md|composer.json|package.json|lib/PostHog.php|.changeset/*) ;;
*)
echo "Unexpected release candidate change: $file" >&2
exit 1
Expand Down
37 changes: 20 additions & 17 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,53 @@
# Releasing

This repository uses [Changesets](https://github.com/changesets/changesets) for version management and an automated GitHub Actions workflow for releases.
This repository uses [pnpm's native release management](https://pnpm.io/versioning) and an automated GitHub Actions workflow for releases.

## How to Release

### 1. Add a Changeset
### 1. Record a Change Intent

When making a change that should be released, add a changeset:
When making a change that should be released, record a change intent:

```bash
pnpm changeset
pnpm change
```

This prompts you to select the version bump (`patch`, `minor`, or `major`) and write a short release summary. Commit the generated file in `.changeset/` with your pull request.
Select `posthog-php`, choose the version bump (`patch`, `minor`, or `major`), and enter a short release summary. Commit the generated `.changeset/*.md` file with your pull request.

### 2. Merge the Pull Request

After review, merge the PR to `main`. No GitHub release label is required.

A push to `main` that includes `.changeset/*.md` changes automatically starts the release workflow. The workflow then:

1. Checks for pending changesets
2. Prepares a release candidate patch for the triggering commit in a read-only job without release secrets, after verifying the release bump script hash
3. Verifies the release candidate in a separate read-only job and fails if the tag or GitHub Release already exists
4. Notifies the client libraries team in Slack for approval only after candidate preparation and verification both succeed
5. Waits for one approval from a maintainer via the GitHub `Release` environment
6. Applies the verified release candidate patch, creates a signed release commit, tags the release, and creates a GitHub Release
7. Notifies Slack and records PostHog failure events from separate follow-up jobs, outside the approved publishing job
1. Checks for pending change intents
2. Uses `pnpm version -r` to determine and apply the version bump, consume the intents, and update `CHANGELOG.md` and `.changeset/ledger.yaml`
3. Prepares a release candidate patch for the triggering commit in a read-only job without release secrets, after verifying the release bump script hash
4. Verifies the release candidate in a separate read-only job and fails if the tag or GitHub Release already exists
5. Notifies the client libraries team in Slack for approval only after candidate preparation and verification both succeed
6. Waits for one approval from a maintainer via the GitHub `Release` environment
7. Applies the verified release candidate patch, creates a signed release commit, tags the release, and creates a GitHub Release
8. Notifies Slack and records PostHog failure events from separate follow-up jobs, outside the approved publishing job

### Manual Trigger

You can also manually trigger the release workflow from the Actions tab with `workflow_dispatch`. Manual runs still require pending changesets.
You can also manually trigger the release workflow from the Actions tab with `workflow_dispatch`. Manual runs still require at least one pending, releasable change intent.

## Version Bumping

Changesets determines the next version from the committed changeset files:
The pending change intents determine the next version:

- **patch**: bug fixes, documentation updates, and internal changes
- **minor**: backwards-compatible features
- **major**: breaking changes

When multiple intents are pending, the workflow uses the largest requested bump.

## Troubleshooting

### No changesets found
### No releasable change intents found

If the release workflow reports that no changesets were found, make sure your PR includes at least one releasable `.changeset/*.md` file.
If the release workflow reports that no releasable change intents were found, make sure your PR includes at least one `.changeset/*.md` file generated by `pnpm change` with a `patch`, `minor`, or `major` bump.

### Updating the release bump script

Expand Down Expand Up @@ -87,4 +90,4 @@ git revert "$RELEASE_COMMIT"
git push origin main
```

After rollback, add or restore the needed changeset and let the release workflow prepare a new release candidate.
After rollback, add or restore the needed change intent and let the release workflow prepare a new release candidate.
10 changes: 2 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
"name": "posthog-php",
"version": "4.12.0",
"private": true,
"description": "Release metadata and changesets for the PostHog PHP SDK",
"packageManager": "pnpm@11.7.0",
"scripts": {
"changeset": "changeset"
},
"devDependencies": {
"@changesets/cli": "^2.30.0"
}
"description": "Release metadata for the PostHog PHP SDK",
"packageManager": "pnpm@11.13.1"
}
Loading
Loading