chore(release): Harden agent npm and desktop release pipelines#3153
chore(release): Harden agent npm and desktop release pipelines#3153charlesvien wants to merge 6 commits into
Conversation
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
|
|
Re the outside-diff heredoc finding on notify-release-failed: addressed in 9362a78. The truncation could not actually fire before (head -1 forced the comment to a single prefixed line), but that also silently dropped multiline rejection comments. The step now takes the first rejection comment in full and writes it with a random heredoc delimiter, so reviewer-controlled text can neither terminate the heredoc nor get truncated. |
Problem
@posthog/agentauto-publishes to npm on every merge touchingpackages/agent/**, 3 to 8 times a day, with no human review. It runs in PostHog cloud sandboxes, so one bad merge tomainis live in production within minutes. This adopts the SDK release handbook process (example: posthog-php), as asked for supply chain risk.Changes
One commit each, desktop isolated in the last:
package.json, so the0.0.0-dev"latest source" sentinel that dev and desktop builds rely on is now injected by tsup instead. Only release builds (AGENT_RELEASE_BUILD=1) bake the real version.pnpm changeset), not on every merge. Config locks versioning to@posthog/agentonly.agent-release.ymlas prepare -> verify (build + test) -> Slack ping -> approval on the protectedReleaseenvironment -> version-bump commit, tag, npm publish with OIDC provenance, GitHub release. Integrity-checked (sha256 patch, main-moved check), idempotent on re-run. Adds CODEOWNERS on release-critical files and stops agent tags from posting to the desktop Discord.finalize-release(the step that makes a release public) now runs in aDesktop Releaseenvironment, inert until reviewers are configured on it, and two checkouts stop persisting write tokens they never use.Full process doc:
packages/agent/RELEASING.md.What I need from a human
Before merging:
Releaseenvironment: required reviewers, prevent self-review, no admin bypass, deployments restricted tomain. Skip this and the first changeset still publishes ungated.GH_APP_POSTHOG_AGENT_RELEASER_APP_ID/_PRIVATE_KEYasReleaseenvironment secrets.mainruleset bypass list (it commits the version bump straight to main) and CodeQL ruleset bypass. Check classic branch protection separately.2.3.1250still matches the latestagent-v*tag at merge time.After merging: merge a trivial test changeset, let it pause at the gate, then set the npm trusted publisher for
@posthog/agentto environmentRelease(orgPostHog, case-sensitive), then approve.Recommended, not blocking: tag rulesets for
agent-v*andv*(bypass only the App), reviewers onDesktop Release, Slack secrets (SLACK_CLIENT_LIBRARIES_BOT_TOKEN,POSTHOG_PROJECT_API_KEY) and vars (SLACK_APPROVALS_CODE_CHANNEL_ID,GROUP_CODE_SLACK_GROUP_ID). Slack failures never block a release; the environment is the gate.How did you test this?
AGENT_RELEASE_BUILD=1;distbakes the real version with the flag, the sentinel without.main.changeset versiondry run changes exactly the three allowlisted files and nothing else.Automatic notifications
packages/agent,shared,gitorenricherchanges to npm; runpnpm changeset)No changeset on purpose: it would trigger the pipeline on merge before the environment exists.