Skip to content

fix(ci): publish the try-bindgen preview from the PR's branch, not the reset worktree - #136

Merged
jagguji merged 1 commit into
mainfrom
ci/fix-try-bindgen-publish-order
Aug 6, 2026
Merged

fix(ci): publish the try-bindgen preview from the PR's branch, not the reset worktree#136
jagguji merged 1 commit into
mainfrom
ci/fix-try-bindgen-publish-order

Conversation

@jagguji

@jagguji jagguji commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #135. publish_preview=true would have published a preview containing the old bindings.

The bug

The publish step ran immediately after peter-evans/create-pull-request:

- uses: peter-evans/create-pull-request@v8   # commits regenerated src/ to its own branch, pushes,
                                             # then RESTORES the local repo to its pre-action state
- name: Publish preview to pkg.pr.new
  run: npx pkg-pr-new publish                # ...so this packs the BASE bindings

The action leaves the working tree back at the base state, so the published tarball would carry the pre-regeneration src/ while the draft PR right next to it showed the new one. You'd install the link, see no change, and have no signal why — the same "looks convincing, is wrong" class the fingerprint step was added to eliminate.

The fix

Fetch and check out the PR's branch before publishing:

env:
  BRANCH: ${{ steps.slug.outputs.branch }}
run: |
  git fetch origin "$BRANCH"
  git checkout "$BRANCH"
  echo "Publishing from $BRANCH @ $(git rev-parse --short HEAD)"
  npx pkg-pr-new publish

This also pins the pkg.pr.new URL to a commit that actually contains the content, rather than to the dispatched ref's SHA — so the preview's provenance is checkable, which is the whole point of the workflow.

node_modules is gitignored and survives the checkout, so no reinstall is needed.

Also

The full branch name is now emitted once as a step output and consumed by both the PR step and the publish step. It was previously written out twice as the same inline expression — two chances to drift, and a drifted publish step would git fetch a branch that doesn't exist.

Why it wasn't caught before merge

The publish path can only be exercised on Actions. Everything testable locally was tested — YAML parse, step-reference resolution, the slugify sed against all three input forms, the bucket-delta script against this repo's real _bindgen-summary.json, and the fingerprint snippet against an actually-installed pkg.pr.new build. #135 said as much: "Not exercised end-to-end on Actions — that needs it on the default branch first." This is that gap closing.

Still not end-to-end verified — publish_preview needs a real run with the input on. The non-publish path (the diff PR, which is the main use) is unaffected either way.

🤖 Generated with Claude Code

…tree

`publish_preview` ran `npx pkg-pr-new publish` straight after
`create-pull-request`. That action commits the regenerated files to its own
branch and pushes, then restores the local repository to its pre-action state
— so the working tree is back to the BASE bindings by the time the publish
runs. The published preview would have contained the OLD output while the PR
sitting next to it showed the new one: a silent mismatch, and exactly the
"looks convincing, is wrong" failure the fingerprint step exists to prevent.

Fetch and check out the PR's branch before publishing. That also pins the
pkg.pr.new URL to a commit that actually CONTAINS the content, instead of to
the dispatched ref's SHA.

The full branch name is now emitted once as a step output and consumed by both
the PR step and the publish step — two copies of the same expression are two
chances to drift, and a drifted publish step would fetch a branch that does
not exist.

Not caught before merge because the publish path can only be exercised on
Actions; the YAML, slugify, bucket-delta and fingerprint snippets were all
validated locally.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jagguji
jagguji merged commit e20138a into main Aug 6, 2026
6 checks passed
jagguji added a commit that referenced this pull request Aug 6, 2026
Reverts #135 and #136. Removes .github/workflows/try-bindgen.yml; no other
file was ever touched by either PR, so main returns to exactly its pre-#135
state.

Reverted at the author's request — the workflow is not wanted on main.

Nothing else depends on it: it was dispatch-only, never referenced by another
workflow, and never ran. The two paths it was built to serve remain available:

  - reviewing an unreleased bindgen: install it locally with
    `npm i --no-save <spec>` and run `npm run generate`
  - an installable preview of this package: `preview.yml`, dispatched
    against any branch

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant