Skip to content

: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.

feat(cli): publish releases to the shared release bucket (#104503)

Hugues Pouillot28953084db06
diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml
index 84135065c6da..989eb70c4ea5 100644
--- a/.github/workflows/release-cli.yml
+++ b/.github/workflows/release-cli.yml
@@ -939,6 +939,10 @@ jobs:
if: ${{ always() && needs.plan-release.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }}
runs-on: 'ubuntu-22.04'
timeout-minutes: 15
+ permissions:
+ contents: read
+ # AssumeRoleWithWebIdentity into the release bucket's publisher role.
+ id-token: write
outputs:
val: ${{ steps.host.outputs.manifest }}
steps:
@@ -991,6 +995,73 @@ jobs:
run: |
# Remove the granular manifests
rm -f artifacts/*-dist-manifest.json
+ # Guarded on all three variables, not just the role: a role without a
+ # destination would fail the upload and take the GitHub release with
+ # it. A partial configuration skips publishing instead, which is also
+ # what a branch predating the bucket gets.
+ - name: Configure AWS credentials for the release bucket
+ if: >-
+ vars.AWS_CLI_RELEASES_ROLE_ARN != ''
+ && vars.AWS_CLI_RELEASES_BUCKET != ''
+ && vars.AWS_CLI_RELEASES_CLOUDFRONT_ID != ''
+ uses: aws-actions/configure-aws-credentials@254c19bd240aabef8777f48595e9d2d7b972184b # v6.2.1
+ with:
+ role-to-assume: ${{ vars.AWS_CLI_RELEASES_ROLE_ARN }}
+ # The bucket lives in shared-services us-east-1, and CloudFront
+ # only reads certificates from that region anyway.
+ aws-region: us-east-1
+ mask-aws-account-id: true
+ unset-current-credentials: true
+ # Runs before the GitHub Release exists on purpose. Installers prefer
+ # this origin, so the objects have to be readable before anything
+ # publishes a URL that points at them.
+ - name: Publish artifacts to the release bucket
+ if: >-
+ vars.AWS_CLI_RELEASES_ROLE_ARN != ''
+ && vars.AWS_CLI_RELEASES_BUCKET != ''
+ && vars.AWS_CLI_RELEASES_CLOUDFRONT_ID != ''
+ shell: bash
+ env:
+ PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
+ RELEASE_TAG: ${{ needs.plan-release.outputs.tag }}
+ BUCKET: ${{ vars.AWS_CLI_RELEASES_BUCKET }}
+ DISTRIBUTION_ID: ${{ vars.AWS_CLI_RELEASES_CLOUDFRONT_ID }}
+ run: |
+ set -euo pipefail
+
+ # RELEASE_TAG is posthog-cli/vX.Y.Z, so the key prefix already
+ # carries the project name and the version. Every object under
+ # it is immutable because the version is part of its key.
+ aws s3 cp artifacts/ "s3://$BUCKET/$RELEASE_TAG/" --recursive \
+ --cache-control "public, max-age=31536000, immutable" \
+ --only-show-errors
+
+ # A prerelease must not move the entry points people install from.
+ if [ -n "$PRERELEASE_FLAG" ]; then
+ echo "prerelease $RELEASE_TAG: versioned artifacts published, rolling entry points untouched"
+ exit 0
+ fi
+
+ # These three keys are republished every release, so they take a
+ # short TTL and an invalidation. Giving them the immutable header
+ # above would pin a stale installer at the edge for a year.
+ rolling="public, max-age=60"
+ aws s3 cp artifacts/posthog-cli-installer.sh \
+ "s3://$BUCKET/posthog-cli/install.sh" \
+ --cache-control "$rolling" --only-show-errors
+ aws s3 cp artifacts/posthog-cli-installer.ps1 \
+ "s3://$BUCKET/posthog-cli/install.ps1" \
+ --cache-control "$rolling" --only-show-errors
+ # The manifest carries announcement_tag and app_version, which is
+ # what a client reads to decide whether it is out of date.
+ aws s3 cp artifacts/dist-manifest.json \
+ "s3://$BUCKET/posthog-cli/stable/dist-manifest.json" \
+ --cache-control "$rolling" --only-show-errors
+
+ aws cloudfront create-invalidation --distribution-id "$DISTRIBUTION_ID" \
+ --paths /posthog-cli/install.sh /posthog-cli/install.ps1 \
+ /posthog-cli/stable/dist-manifest.json \
+ --query 'Invalidation.Id' --output text
- name: Create GitHub Release
shell: bash
env:
diff --git a/cli/RELEASING.md b/cli/RELEASING.md
index 9896f1c3d8ad..ea68f22d49ab 100644
--- a/cli/RELEASING.md
+++ b/cli/RELEASING.md
@@ -21,10 +21,39 @@ After the pull request merges to `master`, the `Release CLI` workflow:
5. Updates `cli/Cargo.toml`, `cli/Cargo.lock`, and `cli/CHANGELOG.md`
6. Commits the release bump to `master`
7. Runs cargo-dist against the release bump commit
-8. Creates the `posthog-cli/vX.Y.Z` GitHub release, refreshes `posthog-cli-latest` for stable releases, and publishes the npm package
+8. Publishes the artifacts to the release bucket, then creates the `posthog-cli/vX.Y.Z` GitHub release, refreshes `posthog-cli-latest` for stable releases, and publishes the npm package
Do not run `sampo publish`; cargo-dist owns publishing for `posthog-cli`.
+### The release bucket
+
+Artifacts are also published to `releases.posthog.com`, a shared S3 and CloudFront origin in the prod-us account, under the `posthog-cli/` prefix.
+It sits alongside the other release mirrors there, `context-mill-releases` and `desktop`.
+GitHub releases stay in place as a mirror.
+
+The upload runs before the GitHub release is created, so the objects exist before anything publishes a URL that points at them.
+Two key shapes, with different caching:
+
+| Key | Cache-Control | Written |
+| -------------------------------------------------------------------- | ----------------------------- | -------------------- |
+| `posthog-cli/vX.Y.Z/<artifact>` | `max-age=31536000, immutable` | every release |
+| `posthog-cli/install.sh`, `install.ps1`, `stable/dist-manifest.json` | `max-age=60` | stable releases only |
+
+The versioned keys are immutable because the version is part of the key.
+The three rolling keys are republished every release and then invalidated at the edge, so they must never carry the immutable header.
+A prerelease publishes its versioned artifacts and leaves the rolling keys alone.
+
+The step is skipped unless all three variables below are set, so a branch that predates the bucket still releases, and so a half-finished configuration cannot fail the release.
+It needs three repository variables:
+
+| Variable | Value |
+| -------------------------------- | -------------------------------------------------------------- |
+| `AWS_CLI_RELEASES_ROLE_ARN` | the `github-posthog-cli-releases-publish-role` role in prod-us |
+| `AWS_CLI_RELEASES_BUCKET` | the shared releases bucket name |
+| `AWS_CLI_RELEASES_CLOUDFRONT_ID` | the distribution fronting it |
+
+The role is scoped to the `posthog-cli/` prefix and to invalidations on that one distribution, so the workflow cannot touch another project's artifacts.
+
If you need to cut a release by hand, merge a CLI changeset to `master` and let `Release CLI` run from there.
Do not push `posthog-cli/vX.Y.Z` tags manually; cargo-dist tag-push releases are disabled.
If cargo-dist fails after `Release CLI` commits the release bump, rerun the failed jobs from the same workflow run.