Skip to content

feat(recipe): publish as @dfinity/static-site, add presync config field - #112

Merged
lwshang merged 3 commits into
mainfrom
static-site-recipe
Jul 22, 2026
Merged

feat(recipe): publish as @dfinity/static-site, add presync config field#112
lwshang merged 3 commits into
mainfrom
static-site-recipe

Conversation

@lwshang

@lwshang lwshang commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Prepares this repo's recipe for public release in icp-cli-recipes and adds a new configuration field.

Rename to @dfinity/static-site

The published recipe is renamed from @dfinity/certified-assets to @dfinity/static-site across the publish script, recipe README, user docs, and doc comments. The recipe name only appears in a project's canister.yaml, so it should name the recipe's input (a built static site) — matching the name-by-input pattern of the sibling @dfinity/rust / @dfinity/motoko recipes — not the canister's role (already name: frontend). Repo/canister references (the dfinity/certified-assets repo, the .did, "the certified-assets canister wasm") are deliberately unchanged.

New presync config field

presync is an array of shell commands, analogous to build, but expanded into the sync section as a script step before the sync-plugin step. Sync steps run after the canister exists, so icp-cli exposes the deployed canister IDs to them: ICP_CLI_CID, ICP_CLI_CID_<NAME> (per project canister), ICP_CLI_NETWORK, and ICP_CLI_ENVIRONMENT. This lets a frontend build bake in the IDs it will call — something build cannot do (it runs before creation, with only ICP_WASM_OUTPUT_PATH).

Ship + verify the recipe via the GitHub release

  • The release CI now runs make recipe-release and attaches the generated recipe.hbs (URL + sha256 pinned — the public form, not the local file-path variant) to the GitHub release.
  • publish-recipe.sh downloads that asset and commits it to the registry PR verbatim (instead of regenerating locally), and the PR links back to the release asset so reviewers can verify the two are identical. This drops the cargo/recipe-gen dependency from the publish path and removes any template-drift risk.

Tests

  • recipe-gen unit tests: 6/6, incl. local_with_presync (asserts presync renders as a sync script step before the plugin step).
  • e2e recipe tests: 4/4, incl. recipe_presync_env — a live deploy whose pre-sync step reads $ICP_CLI_CID / $ICP_CLI_CID_FRONTEND into served assets, which are then fetched through the gateway (certified) and asserted to equal the frontend canister's own principal, proving the env vars are genuinely readable.

Follow-ups (not in this PR)

  • After a v<version> release cuts, run scripts/publish-recipe.sh v<version> --push to open the @dfinity/static-site PR against icp-cli-recipes, and close the stale @dfinity/certified-assets PR #30.
  • Switch the icp new templates (icp-cli repo) to the new recipe and deprecate @dfinity/asset-canister.

🤖 Generated with Claude Code

lwshang and others added 3 commits July 22, 2026 12:20
Rename the published recipe from `@dfinity/certified-assets` to
`@dfinity/static-site` across the publish script, the recipe README, the
user docs, and doc comments. The name only ever appears in a project's
canister.yaml, so it should describe the recipe's input (a built static
site) rather than the canister's role (already `name: frontend`) — matching
the name-by-input pattern of the sibling `@dfinity/rust`/`@dfinity/motoko`
recipes. Repo/canister references (the dfinity/certified-assets repo, the
.did, "the certified-assets canister wasm") are deliberately unchanged.

The release workflow now runs `make recipe-release` (one invocation, no
extra rebuild) and uploads `dist/recipe.hbs` as a release asset — no sibling
.sha256, since the recipe pins the wasm shas internally.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`presync` is an array of shell commands, analogous to `build`, but expanded
into the sync section as a script step *before* the sync-plugin step (rather
than into the build section). Sync steps run after the canister exists, so
icp-cli exposes the deployed canister IDs to them — `ICP_CLI_CID`,
`ICP_CLI_CID_<NAME>` (per project canister), `ICP_CLI_NETWORK`, and
`ICP_CLI_ENVIRONMENT`. This lets a frontend build bake in the IDs it will
call, which `build` cannot do (it runs before creation, with only
`ICP_WASM_OUTPUT_PATH`).

The field name is `presync` (no hyphen) so it works as a Handlebars path in
the template's `{{#if presync}}` / `{{#each presync}}`.

Tests:
- recipe-gen `local_with_presync`: presync renders as a sync script step
  before the plugin step, leaving the build section untouched.
- e2e `recipe_presync_env`: a deployed project's presync steps write
  $ICP_CLI_CID and $ICP_CLI_CID_FRONTEND into the asset dir; the served files
  (fetched through the gateway, so certified) each equal the frontend
  canister's principal — proving the env vars are genuinely readable.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The release CI attaches the generated recipe.hbs (URL + sha256 pinned) to the
GitHub release, and publish-recipe.sh now downloads that asset and commits it to
the registry PR verbatim, instead of regenerating it locally from the release's
.sha256 files. This makes the release the single source of truth for the
published recipe — no template drift between build time and publish time — and
drops the cargo/recipe-gen dependency from the publish path.

The registry PR body links back to the release's recipe.hbs asset so a reviewer
can confirm the committed file is identical to what shipped.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lwshang
lwshang marked this pull request as ready for review July 22, 2026 18:40
@lwshang
lwshang requested a review from a team as a code owner July 22, 2026 18:40
@lwshang
lwshang merged commit 10b8ffb into main Jul 22, 2026
7 checks passed
@lwshang
lwshang deleted the static-site-recipe branch July 22, 2026 18:40
lwshang added a commit that referenced this pull request Jul 22, 2026
Two doc-only changes prompted by the v0.3.0 launch (first public
static-site recipe release).

- **`project-stage.md` reframed for launch.** The old "pre-launch, no
production instances, break anything" stance no longer holds now that
the recipe is public. The rule now states the compatibility contract the
release machinery already encodes (`wire-types/version.rs`, README
"Releasing"): patch bumps preserve stable state across an in-place
upgrade; breaking stable-state changes require a series (minor, pre-1.0)
bump that reinstalls and wipes state; and the recipe config
(`dir`/`build`/`presync`/`metadata`) is now a public interface.
- **README recipe snippet gains `presync`.** The field was added in #112
but the contributor-facing example still listed only
`dir`/`build`/`metadata`; now it matches the recipe README and
`docs/overview.md`.

No code changes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.8 (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