:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(desktop): hold the release app key in an environment (#105655)
Tom Piccirello73676d46efe3
diff --git a/.github/workflows/desktop-agent-tag.yml b/.github/workflows/desktop-agent-tag.ymlindex cd955046f1cb..281c03c16d01 100644--- a/.github/workflows/desktop-agent-tag.yml+++ b/.github/workflows/desktop-agent-tag.yml@@ -19,6 +19,8 @@ jobs:tag:# A manual run can start from any branch, so the ref check keeps a release tag on master.if: github.ref == 'refs/heads/master'+ # The release App's key lives in this environment, which only master and a desktop-v* tag reach.+ environment: desktop-taggingpermissions:contents: writeruns-on: depot-ubuntu-24.04@@ -31,6 +33,25 @@ jobs:app_id: ${{ vars.GH_APP_ARRAY_RELEASER_APP_ID }}private_key: ${{ secrets.GH_APP_ARRAY_RELEASER_PRIVATE_KEY }}+ - name: Check the dispatcher is on team-posthog-desktop+ if: github.event_name == 'workflow_dispatch'+ env:+ GH_TOKEN: ${{ steps.app-token.outputs.token }}+ # A re-run keeps github.actor from the first attempt, so the check reads the+ # account that started this attempt.+ ACTOR: ${{ github.triggering_actor }}+ ORG: ${{ github.repository_owner }}+ TEAM_SLUG: team-posthog-desktop+ run: |+ if ! MEMBERS=$(gh api "orgs/${ORG}/teams/${TEAM_SLUG}/members" --paginate --jq '.[].login'); then+ echo "::error::Could not read ${TEAM_SLUG} membership, so the release is held."+ exit 1+ fi+ if ! echo "$MEMBERS" | grep -qixF "$ACTOR"; then+ echo "::error::@${ACTOR} is not on ${TEAM_SLUG}, so a manual release is not allowed."+ exit 1+ fi+- name: Checkoutuses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2with:diff --git a/.github/workflows/desktop-cleanup-draft-releases.yml b/.github/workflows/desktop-cleanup-draft-releases.ymlindex 11de063915fd..0d883b7bd963 100644--- a/.github/workflows/desktop-cleanup-draft-releases.yml+++ b/.github/workflows/desktop-cleanup-draft-releases.yml@@ -11,6 +11,8 @@ concurrency:jobs:cleanup:+ # The release App's key lives in this environment, which only master and a desktop-v* tag reach.+ environment: desktop-taggingruns-on: depot-ubuntu-24.04timeout-minutes: 10permissions:diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.ymlindex cb10042964a1..d249954380c9 100644--- a/.github/workflows/desktop-release.yml+++ b/.github/workflows/desktop-release.yml@@ -16,6 +16,7 @@ env:jobs:prepare-release:+ environment: desktop-releaseruns-on: depot-ubuntu-24.04timeout-minutes: 10permissions:@@ -51,6 +52,7 @@ jobs:fipublish-macos:+ environment: desktop-releaseneeds: [prepare-release]strategy:fail-fast: false@@ -313,6 +315,7 @@ jobs:retention-days: 1publish-windows:+ environment: desktop-releaseneeds: [prepare-release]runs-on: depot-windows-2022-4timeout-minutes: 90@@ -499,6 +502,7 @@ jobs:retention-days: 1publish-linux:+ environment: desktop-releaseneeds: [prepare-release]strategy:fail-fast: false@@ -678,6 +682,7 @@ jobs:retention-days: 1finalize-release:+ environment: desktop-releaseneeds: [publish-macos, publish-windows, publish-linux]# Publish only when every platform built successfully. Without an `if:` override# the default `needs` gate skips this job (leaving the GitHub release a draft) ifdiff --git a/.github/workflows/desktop-tag.yml b/.github/workflows/desktop-tag.ymlindex 4f6876f6b73d..fe18e37971c0 100644--- a/.github/workflows/desktop-tag.yml+++ b/.github/workflows/desktop-tag.yml@@ -12,13 +12,6 @@ on:description: Skip the master Desktop Tests check, for a break-glass release.type: booleandefault: false- pull_request:- types: [closed]- branches:- - master- paths:- - 'products/desktop/**'- - '.github/workflows/desktop-tag.yml'concurrency:group: desktop-tag@@ -31,15 +24,13 @@ jobs:if: >-github.event_name == 'schedule' ||(github.event_name == 'workflow_dispatch' &&- (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/desktop-v'))) ||- (github.event.pull_request.merged == true &&- contains(github.event.pull_request.labels.*.name, 'desktop-release'))+ (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/desktop-v')))+ # The release App's key lives in this environment, which only master and a desktop-v* tag reach.+ environment: desktop-taggingpermissions:contents: writeactions: writechecks: read- pull-requests: write- issues: writeruns-on: depot-ubuntu-24.04timeout-minutes: 60steps:@@ -50,60 +41,57 @@ jobs:app_id: ${{ vars.GH_APP_ARRAY_RELEASER_APP_ID }}private_key: ${{ secrets.GH_APP_ARRAY_RELEASER_PRIVATE_KEY }}- - name: Checkout- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2- with:- fetch-depth: 0- filter: blob:none- token: ${{ steps.app-token.outputs.token }}-- - name: Check labeler is a member of team-posthog-desktop- id: labeler- if: github.event_name == 'pull_request'+ # The quiet-period step below dispatches its retry with the release App's token, and the App+ # is not on the team. Only a holder of the App key can dispatch as the App. Any branch workflow+ # can dispatch as github-actions[bot], so that bot gets no exception. Keep the two input+ # conditions equal to the ones the later steps read, so an App run still runs Desktop Tests.+ - name: Check the dispatcher is on team-posthog-desktop+ if: >-+ github.event_name == 'workflow_dispatch' &&+ !(github.triggering_actor == 'releaser-posthog-desktop[bot]' &&+ github.event.inputs.quiet_retries != '0' &&+ github.event.inputs.ignore_master_ci != 'true')env:GH_TOKEN: ${{ steps.app-token.outputs.token }}- COMMENT_TOKEN: ${{ github.token }}- REPOSITORY: ${{ github.repository }}- PR_NUMBER: ${{ github.event.pull_request.number }}+ # A re-run keeps github.actor from the first attempt, so the check reads the+ # account that started this attempt.+ ACTOR: ${{ github.triggering_actor }}+ ORG: ${{ github.repository_owner }}TEAM_SLUG: team-posthog-desktoprun: |- skip() {- echo "$1 Skipping auto-release; the next scheduled release will pick this up."- echo "authorized=false" >> "$GITHUB_OUTPUT"- GH_TOKEN="$COMMENT_TOKEN" gh pr comment "$PR_NUMBER" --repo "$REPOSITORY" \- --body "$1 Auto-release is limited to members of the ${TEAM_SLUG} GitHub team, so this will ship with the next scheduled release instead." || true- }-- LABELER=$(gh api "repos/${REPOSITORY}/issues/${PR_NUMBER}/events" --paginate \- --jq '.[] | select(.event == "labeled" and (.label.name | ascii_downcase) == "desktop-release") | "\(.id) \(.actor.login)"' \- | sort -n | tail -1 | cut -d" " -f2)-- if [ -z "$LABELER" ]; then- skip "Could not determine who added the 'desktop-release' label."- exit 0+ if ! MEMBERS=$(gh api "orgs/${ORG}/teams/${TEAM_SLUG}/members" --paginate --jq '.[].login'); then+ echo "::error::Could not read ${TEAM_SLUG} membership, so the release is held."+ exit 1fi-- if ! MEMBERS=$(gh api "orgs/${REPOSITORY%%/*}/teams/${TEAM_SLUG}/members" --paginate --jq '.[].login'); then- skip "Could not verify ${TEAM_SLUG} membership (GitHub API error)."- exit 0+ if ! echo "$MEMBERS" | grep -qixF "$ACTOR"; then+ echo "::error::@${ACTOR} is not on ${TEAM_SLUG}, so a manual release is not allowed."+ exit 1fi- if echo "$MEMBERS" | grep -qixF "$LABELER"; then- echo "'desktop-release' was added by ${LABELER}, a member of ${TEAM_SLUG}."- echo "authorized=true" >> "$GITHUB_OUTPUT"- else- skip "'desktop-release' was added by @${LABELER}, who is not on ${TEAM_SLUG}."- fi+ - name: Checkout+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ fetch-depth: 0+ filter: blob:none+ token: ${{ steps.app-token.outputs.token }}- name: Check quiet periodid: quietif: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.quiet_retries != '0')env:- GH_TOKEN: ${{ github.token }}+ # The dispatcher check trusts a retry from the release App, so the retry must run as it.+ GH_TOKEN: ${{ steps.app-token.outputs.token }}QUIET_RETRIES: ${{ github.event.inputs.quiet_retries || 0 }}run: |RETRIES="${QUIET_RETRIES}"MAX_RETRIES=5+ # Bash arithmetic evaluates a variable's value as an expression, which can run a command.+ case "$RETRIES" in+ '' | *[!0-9]*)+ echo "::error::quiet_retries must be a whole number."+ exit 1+ ;;+ esac# Scoped to products/desktop/: monorepo master always has commits landing, so an# unscoped check would never see a quiet period.LAST_COMMIT_EPOCH=$(git log -1 --format=%ct HEAD -- products/desktop/)@@ -133,7 +121,7 @@ jobs:# the tag job runs Desktop Tests on the tree it is about to tag and waits.- name: Run Desktop Tests on masterid: master-ci-run- if: steps.quiet.outputs.proceed != 'false' && steps.labeler.outputs.authorized != 'false' && github.event.inputs.ignore_master_ci != 'true'+ if: steps.quiet.outputs.proceed != 'false' && github.event.inputs.ignore_master_ci != 'true'env:GH_TOKEN: ${{ github.token }}run: |@@ -177,10 +165,6 @@ jobs:CONCLUSION: ${{ steps.master-ci.outputs.conclusion }}SHA: ${{ steps.master-ci-run.outputs.sha }}RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ steps.master-ci-run.outputs.run_id }}- EVENT_NAME: ${{ github.event_name }}- COMMENT_TOKEN: ${{ github.token }}- REPOSITORY: ${{ github.repository }}- PR_NUMBER: ${{ github.event.pull_request.number }}run: |if [ "$CONCLUSION" = "success" ]; thenecho "Desktop Tests passed on ${SHA}: ${RUN_URL}"@@ -195,13 +179,9 @@ jobs:fiecho "::warning::Desktop Tests concluded '${CONCLUSION}' on ${SHA}, so the release tag is held. ${RUN_URL}"- if [ "$EVENT_NAME" = "pull_request" ]; then- GH_TOKEN="$COMMENT_TOKEN" gh pr comment "$PR_NUMBER" --repo "$REPOSITORY" \- --body "Auto-release is on hold: Desktop Tests concluded \`${CONCLUSION}\` on master (${RUN_URL}). It ships with the next scheduled release once master is green." || true- fi- name: Compute version and create tag- if: steps.quiet.outputs.proceed != 'false' && steps.labeler.outputs.authorized != 'false' && steps.master-ci-run.outputs.proceed != 'false' && steps.master-ci-verdict.outputs.proceed != 'false'+ if: steps.quiet.outputs.proceed != 'false' && steps.master-ci-run.outputs.proceed != 'false' && steps.master-ci-verdict.outputs.proceed != 'false'env:GH_TOKEN: ${{ steps.app-token.outputs.token }}REPOSITORY: ${{ github.repository }}diff --git a/products/desktop/apps/code/README.md b/products/desktop/apps/code/README.mdindex 84a4df10d226..852b30d6942c 100644--- a/products/desktop/apps/code/README.md+++ b/products/desktop/apps/code/README.md@@ -97,11 +97,10 @@ pnpm build-nativePostHog auto-updates on macOS and Windows. Current builds use `electron-updater`, which reads the `latest-mac.yml` and `latest.yml` manifests published with each non-draft GitHub release and downloads the matching archive. Builds made by the old Electron Forge toolchain (`v0.55.x` and earlier) take a single bridge update through the public `update.electronjs.org` service, which serves the same GitHub releases to their built-in Squirrel client, and become `electron-updater` clients from the next launch. See [docs/UPDATES.md](../../docs/UPDATES.md) and [docs/AUTO-UPDATE-TESTING.md](../../docs/AUTO-UPDATE-TESTING.md).-There are three ways a release can fire:+There are two ways a release can fire:-1. **Scheduled (default)** — automatic at 17:00 and 01:00 UTC.-2. **Hotfix** — add the `desktop-release` label to a PR before it merges. On merge, the tag workflow runs immediately and ships whatever is on `master`.-3. **Manual** — run `Tag PostHog Release` via `workflow_dispatch` from the Actions tab.+1. **Scheduled (default)**: automatic at 17:00 and 01:00 UTC.+2. **Manual**: for a hotfix, ask a `team-posthog-desktop` member to run `Desktop Tag Release` on `master` from the Actions tab.Local prep (only needed for one-off manual builds):diff --git a/products/desktop/docs/UPDATES.md b/products/desktop/docs/UPDATES.mdindex cb4436c57154..79605243eca9 100644--- a/products/desktop/docs/UPDATES.md+++ b/products/desktop/docs/UPDATES.md@@ -47,10 +47,8 @@ Remote announcements can drive this flow: a `required-update` announcement block## Releasing a patch-Merge to `master` and wait for the next scheduled `desktop-tag.yml` run. To release sooner:--- Add the `desktop-release` label to your PR before merging (the labeler must be a `team-posthog-desktop` member). The merge then tags immediately.-- Or trigger `desktop-tag.yml` manually with `gh workflow run desktop-tag.yml`.+Merge to `master` and wait for the next scheduled `desktop-tag.yml` run.+To release sooner, ask a `team-posthog-desktop` member to run `gh workflow run desktop-tag.yml`, which tags `master`.## Releasing a minor or major version