feat: add rename-after-install-and-build input to publish-preview.yml workflow#254
Conversation
Allow callers to pass arbitrary build-time environment variables to the build step via a JSON object passed as a secret. This is needed by snap consumers whose build commands require additional configuration (e.g. API URLs, RPC endpoints) to produce valid preview builds.
|
This workflow variation has been tested on this repository: |
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b97ae02. Configure here.
Co-authored-by: Michele Esposito <34438276+mikesposito@users.noreply.github.com>
is-snap argument to publish-preview.yml workflowrename-after-install-and-build input to publish-preview.yml workflow
Mrtenz
left a comment
There was a problem hiding this comment.
We need to rethink this, as this conflicts with NPM trusted publishing. 😞 We can't configure multiple sources for a single package, so if the preview packages use the same NPM package name, we'd need to allow npm publish (in addition to npm stage publish) for the production workflow as well.
Is there really no way to publish these Snaps with a different package name?
Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>

The reusable publish-preview workflow renames each workspace's package.json#name from
@metamask/...to@metamask-previews/...before running the build. This works for typical libraries but breaks for Snap packages, because:When the rename happens before the build, the bundle and manifest are produced against the preview scope, the shasum is computed over the contaminated bundle, and downstream clients that verify against the published @metamask/... shasum reject the snap.
The workaround used by snap repos today (e.g. snap-tron-wallet) is to build first, then rename — but the reusable workflow had no way to express that ordering.
To fix this issue and make this workflow usable for Snaps, this PR adds a new boolean input
is-snap(default false) to.github/workflows/publish-preview.yml.Existing consumers don't need to change anything. Snap consumers add a single input:
Note
Medium Risk
Changes CI ordering for preview builds and introduces secret env injection into build steps; default path is unchanged but misconfigured BUILD_ENV or rename ordering could break consumer preview builds.
Overview
Extends the reusable
publish-previewworkflow so consumers can control when package names are rewritten to the preview NPM scope, and can inject build-time environment from secrets.Adds
rename-after-install-and-build(defaultfalse). Whentrue, the job runs install → build → manifest rename → install so artifacts like Snap bundles andsnap.manifest.jsonare built under the original@metamask/...name before preview renaming. Whenfalse, behavior stays rename → install → build.Adds optional secret
BUILD_ENV(JSON key/value map) applied to the build step viafromJSON, with a step that masks those values in logs. The prepare step is renamed to Prepare preview manifests; install/build are split into conditional pre-rename and post-rename steps.Reviewed by Cursor Bugbot for commit 9994d8b. Bugbot is set up for automated code reviews on this repo. Configure here.