: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(mobile): pin tested source before publishing releases (#126993)
Chris Volzere4998eb23c55
diff --git a/.github/workflows/mobile-release.yml b/.github/workflows/mobile-release.ymlindex 3c70e9bd9893..0611167f48a1 100644--- a/.github/workflows/mobile-release.yml+++ b/.github/workflows/mobile-release.yml@@ -97,6 +97,33 @@ jobs:with:eas-version: 24.8.0token: ${{ secrets.MOBILE_PRODUCTION_EXPO_TOKEN }}+ - name: Get release tagging token+ id: release-token+ uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1+ with:+ client-id: ${{ vars.GH_APP_POSTHOG_RELEASER_APP_ID }}+ private-key: ${{ secrets.GH_APP_POSTHOG_RELEASER_PRIVATE_KEY }}+ permission-contents: write+ permission-workflows: write+ - name: Pin the exact tested source+ env:+ GH_TOKEN: ${{ steps.release-token.outputs.token }}+ RELEASE_SHA: ${{ github.sha }}+ run: |+ # A ref lets GITHUB_TOKEN create the receipt even if master changes+ # workflow files. Native builds can outlive the App token's lifetime.+ tag="mobile-source/$RELEASE_SHA"+ existing_sha=$(gh api "repos/$GITHUB_REPOSITORY/git/matching-refs/tags/$tag" \+ --jq ".[] | select(.ref == \"refs/tags/$tag\") | .object.sha")+ if [[ -n "$existing_sha" ]]; then+ if [[ "$existing_sha" != "$RELEASE_SHA" ]]; then+ echo "::error::The mobile source tag does not match the tested commit"+ exit 1+ fi+ else+ gh api "repos/$GITHUB_REPOSITORY/git/refs" --method POST \+ -f "ref=refs/tags/$tag" -f "sha=$RELEASE_SHA" > /dev/null+ fi- name: Stage and publish the exact tested sourceenv:GH_TOKEN: ${{ github.token }}diff --git a/products/mobile/docs/RELEASING.md b/products/mobile/docs/RELEASING.mdindex 141514e99825..e90c0820db5b 100644--- a/products/mobile/docs/RELEASING.md+++ b/products/mobile/docs/RELEASING.md@@ -49,7 +49,7 @@ This deliberately establishes new binaries and a verified baseline instead of gu1. `Mobile Release` checks the exact master push diff. It selects only the newly added request, rather than sweeping historical requests.2. The reusable `Mobile CI` runs typecheck, lint, Jest, release metadata validation and release policy tests on that exact commit. The simulator demo flows do not run in CI; run them locally before you merge.-3. An authorized reviewer approves the exact commit in the protected `mobile-production` GitHub environment. The publisher then loads the EAS `production` environment, fixes `APP_VARIANT=production` and disables the signup link.+3. An authorized reviewer approves the exact commit in the protected `mobile-production` GitHub environment. A repository-scoped releaser App token pins that commit with a `mobile-source/<commit>` tag. An existing tag must match the tested commit. This keeps release creation authorized if workflow files on `master` change while the release waits. The publisher then loads the EAS `production` environment, fixes `APP_VARIANT=production` and disables the signup link.4. Before contacting EAS to build or publish, it creates a durable draft GitHub receipt at `mobile-release/<id>`. This claims the request so an interrupted retry cannot duplicate a release.5. A `mobile-staging` deployment records the stage. Native requests build production binaries with the pinned public OTA certificate; OTA requests sign and publish to an unlinked `mobile-staging-<id>` EAS branch.6. Native requests submit the completed binaries. OTA requests sign and republish the exact staged group to the production channel; they do not rebuild the bundle during promotion.@@ -66,7 +66,8 @@ Keep the EAS credentials and store setup below. Also:- Protect the `mobile-production` GitHub environment with **required reviewer Chris Volzer (`@cvolzer3`)**, allow self-review so the release owner can explicitly approve their own requests, disable administrator bypass, and restrict deployments to `master`. Review the request and full source diff of the exact deployment commit before approval. The workflow's `environment` field does not configure these server-side protections: a repository administrator must set them before any release request merges.- Store a dedicated `MOBILE_PRODUCTION_EXPO_TOKEN` only in `mobile-production`. Create a separate `mobile-build` environment restricted to `master`, with a different `MOBILE_BUILD_EXPO_TOKEN` environment secret for internal builds. Do not create repository or organization secrets under these names; that would make them available outside their environment. Neither workflow falls back to the shared `EXPO_TOKEN`. Remove or revoke the inherited shared `EXPO_TOKEN` access to this production EAS project; changing these workflow references does not revoke an organization secret or its Expo authority. Coordinate any other workflows that still use it. Use the narrowest Expo account/project access available for the new tokens. Separate tokens do not impose EAS channel or build-profile authorization: both workflows also require trusted master source, and production OTA has an independent signing key.- Provision OTA signing as described below before the first hosted native release. The public certificate belongs in the repository; the private key belongs only in the protected `mobile-production` environment. Native build jobs and dependency installation do not receive the private key.-- Permit the workflow's `GITHUB_TOKEN` to create releases/tags and deployment records. The workflow requests only contents and deployments write access in its publishing job.+- Make `GH_APP_POSTHOG_RELEASER_APP_ID` and the organization secret `GH_APP_POSTHOG_RELEASER_PRIVATE_KEY` available to this repository's approved `mobile-production` job. The existing releaser App installation must grant **Contents: write** and **Workflows: write** on `PostHog/posthog`; the workflow requests only those permissions for its source-tagging token. Do not fall back to `GITHUB_TOKEN` for this step: it cannot receive Workflows write permission.+- Permit the workflow's `GITHUB_TOKEN` to create releases/tags and deployment records. The publisher retains this token throughout staging and submission because native builds can outlive an App installation token's one-hour lifetime. The `mobile-source/<commit>` tag is a source pin, not a release receipt; its presence alone does not claim or publish a request. Retain it for retries of the original commit. The publishing job requests only contents and deployments write access for `GITHUB_TOKEN`.- Keep production build-time variables readable as Plain text or Sensitive. The publisher audits both project variables and linked account variables before claiming a request; any Secret value blocks the release because it cannot be included in the compatibility check. Native signing/submission keys belong in EAS credentials; the OTA signing key belongs in the protected GitHub environment. Neither belongs in these variables.- Set `GOOGLE_SERVICES_JSON` to a **Sensitive file** variable. The publisher reads its base64 file content through the authenticated Expo API, writes an ignored file with owner-only permissions, and uses it during fingerprinting and configuration. Neither contents nor other variable values appear in receipts or artifacts. Secret files, unreadable file values and other file-variable names fail closed before an EAS build or OTA publish. Native EAS fingerprint results must match these materialized inputs.- The native environment is audited and fingerprinted again after staging. A change to variable names, types or contents blocks production publication, including removed values. Snapshot hashes stay in memory. Variables that overwrite GitHub identity, credentials or the runner command environment are rejected before any values are applied; the script imports the audited environment itself.