From a92ac53c0c7b00e47eb18658edac1a0f164120ac Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 16 Apr 2026 17:29:35 +0100 Subject: [PATCH 1/2] chore: add manual release workflow dispatch --- .github/workflows/release.yml | 24 ++++++++++++++++++++---- RELEASING.md | 11 +++++------ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a7d985b..0ea0903 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,16 @@ on: pull_request: types: [closed] branches: [main] + workflow_dispatch: + inputs: + bump_type: + description: Version bump to apply + required: true + type: choice + options: + - patch + - minor + - major permissions: contents: read @@ -20,8 +30,10 @@ jobs: runs-on: ubuntu-latest # Run when PR with 'release' label is merged to main, or when manually triggered if: | - github.event.pull_request.merged == true - && contains(github.event.pull_request.labels.*.name, 'release') + 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 }} bump-type: ${{ steps.check.outputs.bump-type }} @@ -37,8 +49,12 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - # Determine bump type from PR labels - if ${{ contains(github.event.pull_request.labels.*.name, 'bump-major') }}; then + # Determine bump type from workflow input or PR labels + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "bump-type=${{ inputs.bump_type }}" >> "$GITHUB_OUTPUT" + echo "should-release=true" >> "$GITHUB_OUTPUT" + echo "Manual release requested with bump type '${{ inputs.bump_type }}'" + elif ${{ contains(github.event.pull_request.labels.*.name, 'bump-major') }}; then echo "bump-type=major" >> "$GITHUB_OUTPUT" echo "should-release=true" >> "$GITHUB_OUTPUT" elif ${{ contains(github.event.pull_request.labels.*.name, 'bump-minor') }}; then diff --git a/RELEASING.md b/RELEASING.md index bfd15a6..6bb555c 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,17 +1,16 @@ # Releasing -Releases are semi-automated via GitHub Actions. When a PR with the `release` and a version bump label is merged to `main`, the release workflow is triggered. +Releases are semi-automated via GitHub Actions. When a PR with the `release` and a version bump label is merged to `main`, the release workflow is triggered. You can also trigger the `Release` workflow manually from GitHub Actions and choose the bump type. You'll need an approval from a PostHog engineer. If you're an employee, you can see the request in the [#approvals-client-libraries](https://app.slack.com/client/TSS5W8YQZ/C0A3UEVDDNF) channel. ## Release Process -1. **Create your PR** with the changes you want to release -2. **Add the `release` label** to the PR -3. **Add a version bump label** that should be either `bump-patch`, `bump-minor` or `bump-major` -4. **Merge the PR** to `main` +1. Either: + - **Create your PR** with the changes you want to release, add the `release` label, add exactly one version bump label (`bump-patch`, `bump-minor`, or `bump-major`), and **merge the PR** to `main`, or + - open the `Release` workflow in GitHub Actions, click **Run workflow**, and choose `patch`, `minor`, or `major` -Once merged, the following happens automatically: +Once the workflow is triggered, the following happens automatically: 1. A Slack notification is sent to the client libraries channel requesting approval 2. A maintainer approves the release in the GitHub `Release` environment From 1f743535deb66f4b7593d0daa362dd16586fa5af Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 16 Apr 2026 17:45:41 +0100 Subject: [PATCH 2/2] fix: avoid github context interpolation in release workflow --- .github/workflows/release.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0ea0903..cdf23b7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,19 +48,24 @@ jobs: id: check env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + EVENT_NAME: ${{ github.event_name }} + INPUT_BUMP_TYPE: ${{ inputs.bump_type }} + HAS_BUMP_MAJOR: ${{ contains(github.event.pull_request.labels.*.name, 'bump-major') }} + HAS_BUMP_MINOR: ${{ contains(github.event.pull_request.labels.*.name, 'bump-minor') }} + HAS_BUMP_PATCH: ${{ contains(github.event.pull_request.labels.*.name, 'bump-patch') }} run: | # Determine bump type from workflow input or PR labels - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - echo "bump-type=${{ inputs.bump_type }}" >> "$GITHUB_OUTPUT" + if [ "$EVENT_NAME" = "workflow_dispatch" ]; then + echo "bump-type=$INPUT_BUMP_TYPE" >> "$GITHUB_OUTPUT" echo "should-release=true" >> "$GITHUB_OUTPUT" - echo "Manual release requested with bump type '${{ inputs.bump_type }}'" - elif ${{ contains(github.event.pull_request.labels.*.name, 'bump-major') }}; then + echo "Manual release requested with bump type '$INPUT_BUMP_TYPE'" + elif [ "$HAS_BUMP_MAJOR" = "true" ]; then echo "bump-type=major" >> "$GITHUB_OUTPUT" echo "should-release=true" >> "$GITHUB_OUTPUT" - elif ${{ contains(github.event.pull_request.labels.*.name, 'bump-minor') }}; then + elif [ "$HAS_BUMP_MINOR" = "true" ]; then echo "bump-type=minor" >> "$GITHUB_OUTPUT" echo "should-release=true" >> "$GITHUB_OUTPUT" - elif ${{ contains(github.event.pull_request.labels.*.name, 'bump-patch') }}; then + elif [ "$HAS_BUMP_PATCH" = "true" ]; then echo "bump-type=patch" >> "$GITHUB_OUTPUT" echo "should-release=true" >> "$GITHUB_OUTPUT" fi