[STG-1739] fix: browse-cli releases publish under alpha instead of latest

Merged
SH
8mo ago
+41-4

Summary

  • Root cause: The changesets/action step corrupts git state by checking out changeset-release/main and creating a new commit. After it returns, HEAD points to the wrong branch/commit. The browse-cli check step uses HEAD/HEAD^ which are now wrong, so it always says "browse-cli version did not change" and skips the publish. Then the stagehand canary step (changeset publish --tag alpha) finds the unpublished version and publishes it under alpha instead of latest.
  • Fix: Replace all HEAD/HEAD^ references with ${{ github.sha }}/${{ github.sha }}^ (the actual merge commit SHA, immune to branch switches). Add git checkout ${{ github.sha }} to restore the working tree. Add explicit --tag latest to the publish command.
  • New: Add a browse-cli canary step that publishes X.Y.Z-alpha-{sha} versions under the alpha tag on feature branch merges (matching stagehand's existing canary pattern).

What was happening

  1. PR merged to main with browse-cli version bump (e.g. 0.3.0 -> 0.4.0)
  2. changesets/action runs, switches to changeset-release/main, creates commit
  3. HEAD now points to the changeset PR commit, not the merge commit
  4. browse-cli check compares wrong commits, finds no version change, sets should_publish=false
  5. Stagehand canary step runs changeset publish --tag alpha, which picks up the unpublished browse-cli and publishes it under alpha
  6. Result: npm info @browserbasehq/browse-cli shows latest: 0.3.0, alpha: 0.4.0

What this PR does

  1. Uses ${{ github.sha }} (the actual merge commit) instead of HEAD for all git comparisons
  2. Adds git checkout ${{ github.sha }} to restore the working tree after changesets/action
  3. Adds --tag latest to the npm publish command for clean releases
  4. Adds a new "Publish browse-cli canary" step for feature branch merges (publishes X.Y.Z-alpha-{sha} under alpha tag)

Validation

  • Traced CI logs from recent releases to confirm HEAD was pointing to changeset-release/main after the changesets step
  • Confirmed npm view @browserbasehq/browse-cli shows latest: 0.3.0 while alpha: 0.4.1 (the bug in action)
  • ${{ github.sha }} is set by GitHub Actions to the merge commit SHA and is immutable throughout the run

Linear

https://linear.app/browserbase/issue/STG-1739/fix-browse-cli-release-publishes-under-alpha-instead-of-latest

🤖 Generated with Claude Code


Summary by cubic

Fixes the release workflow so @browserbasehq/browse-cli clean releases publish to latest, and canaries publish to alpha. Addresses Linear STG-1739 by using the immutable merge SHA to avoid changesets/action HEAD switches.

  • Bug Fixes

    • Use ${{ github.sha }}/${{ github.sha }}^ for diffs and version reads to avoid wrong HEAD.
    • Restore the working tree before checks/publish and reset packages/cli/package.json after canary publish.
    • Publish clean releases with npm publish ... --tag latest.
  • New Features

    • Add canary step that publishes X.Y.Z-alpha-{shortSha} to alpha when CLI files changed but no clean release occurred.
    • Skip canary if the version already exists or no CLI changes are detected.