Repository navigation
publishing: a publish-target contract, with npm, OCI and forge release assets (#4047) - #4078
Merged
Merged
Conversation
…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)
…r scan leaves out (#4047)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).lifecycle/release-publish.ts, documented onreference/publish-targets.mdx): aPublishTargethaskind,name,destination,credentialEnv,plan(ctx)(reads and checks what it would upload: files exist, match the release's recorded digests, credentials set; changes nothing) andpublish(ctx)(returns each item and where it went). Errors arePublishTargetErrorwith a code and a fix. The context carries the release, label, tag, provenance, atagoverride (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.release.publishin the member'schant.config.ts, validated by zod; a declaration names environment variables, never values, and unknown keys such aspasswordare rejected.npm publishper package in the declared order (--registry,--access,--tagwhen set),--provenanceonly with a detected OIDC token; a package directory or packed.tgz; chant reads no npm token and writes no.npmrc.docker savetar withindex.json; skips blobs the registry has, then tags the digest.upload_url(skipping a matching digest), Forgejo multipart, GitLab via the generic package registry linked to the release.chant release publishis a dry run unless--yes, asrelease 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.OCI_USERNAME/OCI_PASSWORD,GITHUB_TOKEN,GITLAB_TOKENthenCI_JOB_TOKEN,FORGEJO_TOKEN; OCI falls back to docker configauths). 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 publishwithout--yesis a dry run; its--jsongainsdryRun,next,kindanditems; the "nothing published" sentence points atrelease.publish; therelease cutdry run lists declared targets; a malformedrelease.publishfails config loading; with a target declared, publish refuses a moved or dirty checkout.Acceptance
reference/publish-targets.mdx).publish-targets.test.ts: a fakenpmbinary, a registry fake on 127.0.0.1 started and closed by the test, a recordingfetchfor GitHub, Forgejo and GitLab).--provenancewith a CI OIDC token (publish-targets.test.ts, and the e2erelease-publish-targets.e2e.test.ts: cut, dry run,--yesunder OIDC, two packages in order with--provenance, no secret in output or ingit 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 failuresGITHUB_SHA,GITHUB_RUN_IDandCIset, after rebasing on main;npx vitest run --project unitpasseslint-docs-sentences(no regressions; the new page's subject words "publish" and "target" baselined asrare-lemma),lint-prompts,check-docs-diataxis,./scripts/build-docs.sh: passchant/lifecyclewas unchanged.