From 35f933b4fa61efb9d3a0c65d108e87775083019a Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Mon, 4 May 2026 14:00:39 +0200 Subject: [PATCH 1/3] chore: trigger releases from main changesets --- .github/pull_request_template.md | 1 - .github/workflows/release.yml | 35 ++++++++++++++------------------ RELEASING.md | 28 +++++++++++++++++++------ 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 6fb6b302..804c8c8f 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -17,6 +17,5 @@ ### If releasing new changes - [ ] Ran `sampo add` to generate a changeset file -- [ ] Added the `release` label to the PR diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0da2fae4..842b55de 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,32 +1,27 @@ name: "Release" on: - pull_request: - types: [closed] + push: branches: [main] + paths: + - '.sampo/changesets/**' workflow_dispatch: permissions: contents: read # Concurrency control: only one release process can run at a time -# This prevents race conditions if multiple PRs with 'release' label merge simultaneously +# This prevents race conditions if multiple releasable changesets merge simultaneously concurrency: group: release cancel-in-progress: false jobs: - check-release-label: - name: Check for release label + check-changesets: + name: Check for changesets runs-on: ubuntu-latest - # Run when PR with 'release' label is merged to main - if: | - github.event_name == 'workflow_dispatch' || - (github.event_name == 'pull_request' && - github.event.pull_request.merged == true && - contains(github.event.pull_request.labels.*.name, 'release')) outputs: - should-release: ${{ steps.check.outputs.should-release }} + has-changesets: ${{ steps.check.outputs.has-changesets }} steps: - name: Checkout repository uses: actions/checkout@v6 @@ -34,22 +29,22 @@ jobs: ref: main fetch-depth: 0 - - name: Check release conditions + - name: Check for changesets id: check run: | changeset_count=$(find .sampo/changesets -name '*.md' 2>/dev/null | wc -l) if [ "$changeset_count" -gt 0 ]; then - echo "should-release=true" >> "$GITHUB_OUTPUT" + echo "has-changesets=true" >> "$GITHUB_OUTPUT" echo "Found $changeset_count changeset(s), ready to release" else - echo "should-release=false" >> "$GITHUB_OUTPUT" + echo "has-changesets=false" >> "$GITHUB_OUTPUT" echo "No changesets to release" fi notify-approval-needed: name: Notify Slack - Approval Needed - needs: check-release-label - if: needs.check-release-label.outputs.should-release == 'true' + needs: check-changesets + if: needs.check-changesets.outputs.has-changesets == 'true' uses: posthog/.github/.github/workflows/notify-approval-needed.yml@main with: slack_channel_id: ${{ vars.SLACK_APPROVALS_CLIENT_LIBRARIES_CHANNEL_ID }} @@ -60,11 +55,11 @@ jobs: release: name: Release and publish - needs: [check-release-label, notify-approval-needed] + needs: [check-changesets, notify-approval-needed] runs-on: ubuntu-latest # Use `always()` to ensure the job runs even if notify-approval-needed is skipped, # but still depend on it to access `needs.notify-approval-needed.outputs.slack_ts` - if: always() && needs.check-release-label.outputs.should-release == 'true' + if: always() && needs.check-changesets.outputs.has-changesets == 'true' environment: "Release" # This will require an approval from a maintainer, they are notified in Slack above permissions: contents: write @@ -257,7 +252,7 @@ jobs: notify-released: name: Notify Slack - Released - needs: [check-release-label, notify-approval-needed, release] + needs: [check-changesets, notify-approval-needed, release] runs-on: ubuntu-latest if: always() && needs.release.result == 'success' && needs.notify-approval-needed.outputs.slack_ts != '' steps: diff --git a/RELEASING.md b/RELEASING.md index e80c5ba8..8bbc2fe1 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,10 +1,26 @@ # Releasing -This repository uses [Sampo](https://github.com/bruits/sampo) for versioning and changelog generation, with GitHub Actions publishing packages to PyPI. +This repository uses [Sampo](https://github.com/bruits/sampo) for versioning and changelog generation, with GitHub Actions handling publishing. -1. When making changes, include a changeset: `sampo add` -2. Create a PR with your changes and the changeset file -3. Add the `release` label and merge to `main` -4. Approve the release in Slack when prompted — this triggers the version bump, publishes both `posthog` and the `posthoganalytics` mirror package to PyPI, creates a git tag, and creates a GitHub Release +## How to Release -You can also trigger a release manually via the workflow's `workflow_dispatch` trigger (still requires pending changesets). +1. When making a change that should be released, include a Sampo changeset: + + ```bash + sampo add + ``` + +2. Commit the generated `.sampo/changesets/*.md` file with your pull request. +3. After review, merge the PR to `main`. No GitHub release label is required. +4. A push to `main` that includes `.sampo/changesets/**` changes automatically starts the release workflow. +5. Approve the release when prompted in Slack / the GitHub `Release` environment. + +After approval, The workflow runs Sampo, publishes both `posthog` and the `posthoganalytics` mirror package to PyPI, tags the release, and creates a GitHub Release. + +## Manual Trigger + +You can also manually trigger the release workflow from the Actions tab with `workflow_dispatch`. Manual runs still require pending Sampo changesets. + +## Troubleshooting + +If the release workflow reports that no changesets were found, make sure your PR includes at least one releasable `.sampo/changesets/*.md` file. From 7b34891cd19b86fa02e8e48d7acea92935a5c7b7 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Mon, 4 May 2026 14:16:10 +0200 Subject: [PATCH 2/3] chore: skip release workflow on version bump commits --- .github/workflows/release.yml | 4 ++-- RELEASING.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 842b55de..8c477690 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,7 @@ on: push: branches: [main] paths: - - '.sampo/changesets/**' + - '.sampo/changesets/*.md' workflow_dispatch: permissions: @@ -138,7 +138,7 @@ jobs: id: commit-release uses: planetscale/ghcommit-action@25309d8005ac7c3bcd61d3fe19b69e0fe47dbdde # v0.2.20 with: - commit_message: "chore: Release v${{ steps.sampo-release.outputs.new_version }}" + commit_message: "chore: Release v${{ steps.sampo-release.outputs.new_version }} [skip ci]" repo: ${{ github.repository }} branch: main env: diff --git a/RELEASING.md b/RELEASING.md index 8bbc2fe1..0d7c8685 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -12,7 +12,7 @@ This repository uses [Sampo](https://github.com/bruits/sampo) for versioning and 2. Commit the generated `.sampo/changesets/*.md` file with your pull request. 3. After review, merge the PR to `main`. No GitHub release label is required. -4. A push to `main` that includes `.sampo/changesets/**` changes automatically starts the release workflow. +4. A push to `main` that includes `.sampo/changesets/*.md` changes automatically starts the release workflow. 5. Approve the release when prompted in Slack / the GitHub `Release` environment. After approval, The workflow runs Sampo, publishes both `posthog` and the `posthoganalytics` mirror package to PyPI, tags the release, and creates a GitHub Release. From 401edbed06aacd15aaead0b659060f8fa972afc3 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Mon, 4 May 2026 14:53:34 +0200 Subject: [PATCH 3/3] docs: keep existing release details --- RELEASING.md | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index 0d7c8685..94ce2291 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,26 +1,10 @@ # Releasing -This repository uses [Sampo](https://github.com/bruits/sampo) for versioning and changelog generation, with GitHub Actions handling publishing. +This repository uses [Sampo](https://github.com/bruits/sampo) for versioning and changelog generation, with GitHub Actions publishing packages to PyPI. -## How to Release +1. When making changes, include a changeset: `sampo add` +2. Create a PR with your changes and the changeset file +3. Merge to `main` (no release label required) +4. Approve the release in Slack when prompted — this triggers the version bump, publishes both `posthog` and the `posthoganalytics` mirror package to PyPI, creates a git tag, and creates a GitHub Release -1. When making a change that should be released, include a Sampo changeset: - - ```bash - sampo add - ``` - -2. Commit the generated `.sampo/changesets/*.md` file with your pull request. -3. After review, merge the PR to `main`. No GitHub release label is required. -4. A push to `main` that includes `.sampo/changesets/*.md` changes automatically starts the release workflow. -5. Approve the release when prompted in Slack / the GitHub `Release` environment. - -After approval, The workflow runs Sampo, publishes both `posthog` and the `posthoganalytics` mirror package to PyPI, tags the release, and creates a GitHub Release. - -## Manual Trigger - -You can also manually trigger the release workflow from the Actions tab with `workflow_dispatch`. Manual runs still require pending Sampo changesets. - -## Troubleshooting - -If the release workflow reports that no changesets were found, make sure your PR includes at least one releasable `.sampo/changesets/*.md` file. +You can also trigger a release manually via the workflow's `workflow_dispatch` trigger (still requires pending changesets).