Skip to content

feat: add is-snap argument to publish-preview.yml workflow#254

Draft
mikesposito wants to merge 2 commits into
mainfrom
mikesposito/snap-previews
Draft

feat: add is-snap argument to publish-preview.yml workflow#254
mikesposito wants to merge 2 commits into
mainfrom
mikesposito/snap-previews

Conversation

@mikesposito
Copy link
Copy Markdown
Member

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:

  • The Snap build (mm-snap build) embeds the package name into dist/bundle.js.
  • snap.manifest.json contains a source.shasum computed over the bundle, the manifest itself (minus the shasum), the icon, and locales.
  • source.location.npm.packageName in the manifest must match package.json#name at publish time.
    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:

jobs:
  publish-preview:
    uses: MetaMask/github-tools/.github/workflows/publish-preview.yml
    with:
      is-snap: true
    secrets:
      PUBLISH_PREVIEW_NPM_TOKEN: ${{ secrets.PUBLISH_PREVIEW_NPM_TOKEN }}

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