Skip to content

publishing: a publish-target contract, with npm, OCI and forge release assets (#4047) - #4078

Merged
lex00 merged 2 commits into
mainfrom
feat/4047-publish-targets
Oct 18, 2026
Merged

lex00 merged 2 commits into
mainfrom
feat/4047-publish-targets

Conversation

@lex00

@lex00 lex00 commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Closes #4047

A publish-target contract for chant release publish, with npm, OCI registry and forge release-asset targets. CI publishes with OIDC provenance; a workstation publish carries none and says so (#4027).

  • Contract (lifecycle/release-publish.ts, documented on reference/publish-targets.mdx): a PublishTarget has kind, name, destination, credentialEnv, plan(ctx) (reads and checks what it would upload: files exist, match the release's recorded digests, credentials set; changes nothing) and publish(ctx) (returns each item and where it went). Errors are PublishTargetError with a code and a fix. The context carries the release, label, tag, provenance, a tag override (npm dist-tag or OCI tags, for publishing: resume after a failure without republishing, and all-or-nothing visibility #4048's staging), env and a redactor. Every target is planned before any publishes.
  • Declared under release.publish in the member's chant.config.ts, validated by zod; a declaration names environment variables, never values, and unknown keys such as password are rejected.
  • npm: npm publish per package in the declared order (--registry, --access, --tag when set), --provenance only with a detected OIDC token; a package directory or packed .tgz; chant reads no npm token and writes no .npmrc.
  • OCI: push by digest over the plain registry HTTP API (Basic and Bearer challenges, as GHCR and Docker Hub use), from an OCI layout directory or a docker save tar with index.json; skips blobs the registry has, then tags the digest.
  • Forge assets: attach files to the forge release for the cut's tag, creating it at the release's commit if needed. GitHub uploads to upload_url (skipping a matching digest), Forgejo multipart, GitLab via the generic package registry linked to the release.
  • chant release publish is a dry run unless --yes, as release cut. With a target declared it refuses a HEAD that isn't the release's commit (release-head-mismatch) and a dirty tree, since targets read files from the checkout; a CI job on the release tag passes both.
  • Credentials come from env vars (per-target defaults: OCI_USERNAME/OCI_PASSWORD, GITHUB_TOKEN, GITLAB_TOKEN then CI_JOB_TOKEN, FORGEJO_TOKEN; OCI falls back to docker config auths). A redactor masks every credential, registry token, well-known CI token variable and auth header form in every printed line, error and the JSON document. Publish writes no record.

Level-0 output changes

On the exceptions page, #2525 and CHANGELOG: release publish without --yes is a dry run; its --json gains dryRun, next, kind and items; the "nothing published" sentence points at release.publish; the release cut dry run lists declared targets; a malformed release.publish fails config loading; with a target declared, publish refuses a moved or dirty checkout.

Acceptance

  • The contract, documented (reference/publish-targets.mdx).
  • npm, OCI (GHCR or Docker Hub style) and forge assets, each with a test against a local registry or fake (publish-targets.test.ts: a fake npm binary, a registry fake on 127.0.0.1 started and closed by the test, a recording fetch for GitHub, Forgejo and GitLab).
  • The npm target publishes a set of several packages and passes --provenance with a CI OIDC token (publish-targets.test.ts, and the e2e release-publish-targets.e2e.test.ts: cut, dry run, --yes under OIDC, two packages in order with --provenance, no secret in output or in git log -p --all, a moved HEAD refused).

Checks

  • npx tsx scripts/typecheck.ts: no regressions (26 baselined)
  • npx tsx scripts/check-lexicons.ts: no untracked tier-1 failures
  • lifecycle, release e2e (cut, publish targets, workstation and CI), level-0 goldens: 963 passed with GITHUB_SHA, GITHUB_RUN_ID and CI set, after rebasing on main; npx vitest run --project unit passes
  • lint-docs-sentences (no regressions; the new page's subject words "publish" and "target" baselined as rare-lemma), lint-prompts, check-docs-diataxis, ./scripts/build-docs.sh: pass
  • Nothing was published anywhere real; the real repository's chant/lifecycle was unchanged.

lex00 added 2 commits October 17, 2026 18:34
…e assets (#4047)

A member declares its publish targets under release.publish in chant.config.ts, validated with the config. chant release publish runs them in order: npm publish per package (directories or packed .tgz) with --provenance when the run has an OIDC token and a tag parameter for #4048's staging; an OCI image layout (directory or docker save tar) pushed by digest over the registry HTTP API through Basic or Bearer challenges, then tagged, for GHCR, Docker Hub and other registries; and release assets on GitHub (upload_url, skipped when the digest matches), Forgejo (multipart) and GitLab (generic package plus a release link), creating the forge release at the release's commit when the tag has none.

The PublishTarget contract gains kind, credentialEnv and plan(ctx), which reads and checks what a target would publish (files present, release artifact digests matching, credentials set) and sends nothing; publish(ctx) takes a PublishContext with releaseTag, tag, env, a redactor and log. Every target is planned before any publishes. publish is a dry run without --yes, mirroring cut, and with a target it refuses a checkout whose HEAD is not the release's commit or whose tree has changes (release-head-mismatch, release-worktree-dirty). Credentials come from the environment or the docker config, never from a declaration, and every printed line, error and --json document is redacted. The cut's dry run lists the declared targets.

Tests use stand-ins only: a fake npm binary, a registry fake on 127.0.0.1 started and closed in the test, and a recording fetch for the forges. Reference page Publish Targets; level-0 row and changelog entry added.

(#4047)
@lex00
lex00 merged commit ad64e71 into main Oct 18, 2026
11 checks passed
@lex00
lex00 deleted the feat/4047-publish-targets branch October 18, 2026 03:51
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.

publishing: a publish-target contract, with npm, OCI and forge release assets

1 participant