@intentius/chant 0.124.100 → 0.124.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action-pins.d.ts +2 -0
- package/dist/action-pins.js +3 -0
- package/dist/ci-detect.d.ts +13 -0
- package/dist/ci-detect.js +12 -0
- package/dist/ci-evidence-claims.d.ts +12 -0
- package/dist/ci-evidence-claims.js +12 -0
- package/dist/ci-system.d.ts +66 -0
- package/dist/ci-system.js +61 -0
- package/dist/cli/handlers/build.js +27 -0
- package/dist/cli/handlers/release-doctor.d.ts +12 -0
- package/dist/cli/handlers/release-doctor.js +118 -0
- package/dist/cli/handlers/release-init.d.ts +10 -0
- package/dist/cli/handlers/release-init.js +374 -0
- package/dist/cli/handlers/release.d.ts +43 -2
- package/dist/cli/handlers/release.js +667 -39
- package/dist/cli/handlers/run-generate.js +11 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +44 -101
- package/dist/cli/parse-args.js +48 -0
- package/dist/cli/registry.d.ts +16 -0
- package/dist/cli/release-commands/artifacts.d.ts +3 -0
- package/dist/cli/release-commands/artifacts.js +14 -0
- package/dist/cli/release-commands/candidates.d.ts +3 -0
- package/dist/cli/release-commands/candidates.js +16 -0
- package/dist/cli/release-commands/changed.d.ts +3 -0
- package/dist/cli/release-commands/changed.js +14 -0
- package/dist/cli/release-commands/compose.d.ts +3 -0
- package/dist/cli/release-commands/compose.js +16 -0
- package/dist/cli/release-commands/cut.d.ts +3 -0
- package/dist/cli/release-commands/cut.js +50 -0
- package/dist/cli/release-commands/doctor.d.ts +3 -0
- package/dist/cli/release-commands/doctor.js +14 -0
- package/dist/cli/release-commands/export.d.ts +3 -0
- package/dist/cli/release-commands/export.js +12 -0
- package/dist/cli/release-commands/images.d.ts +3 -0
- package/dist/cli/release-commands/images.js +13 -0
- package/dist/cli/release-commands/index.d.ts +8 -0
- package/dist/cli/release-commands/index.js +52 -0
- package/dist/cli/release-commands/init.d.ts +3 -0
- package/dist/cli/release-commands/init.js +19 -0
- package/dist/cli/release-commands/list.d.ts +3 -0
- package/dist/cli/release-commands/list.js +10 -0
- package/dist/cli/release-commands/next.d.ts +3 -0
- package/dist/cli/release-commands/next.js +13 -0
- package/dist/cli/release-commands/publish.d.ts +3 -0
- package/dist/cli/release-commands/publish.js +22 -0
- package/dist/cli/release-commands/stamp.d.ts +3 -0
- package/dist/cli/release-commands/stamp.js +15 -0
- package/dist/cli/release-commands/status.d.ts +3 -0
- package/dist/cli/release-commands/status.js +17 -0
- package/dist/cli/release-commands/tag.d.ts +3 -0
- package/dist/cli/release-commands/tag.js +12 -0
- package/dist/cli/release-commands/types.d.ts +20 -0
- package/dist/cli/release-commands/types.js +1 -0
- package/dist/cli/release-commands/verify.d.ts +3 -0
- package/dist/cli/release-commands/verify.js +15 -0
- package/dist/cli/release-commands/workflow.d.ts +3 -0
- package/dist/cli/release-commands/workflow.js +15 -0
- package/dist/cloud-lister/index.d.ts +4 -1
- package/dist/cloud-lister/index.js +2 -1
- package/dist/cloud-lister/kubernetes-components.d.ts +56 -0
- package/dist/cloud-lister/kubernetes-components.js +642 -0
- package/dist/cloud-lister/kubernetes.d.ts +18 -0
- package/dist/cloud-lister/kubernetes.js +26 -1
- package/dist/cloud-lister/mask.d.ts +5 -1
- package/dist/cloud-lister/mask.js +14 -5
- package/dist/components/cli-support.d.ts +1 -1
- package/dist/components/cli-support.js +1 -1
- package/dist/config-environments.d.ts +8 -1
- package/dist/config-environments.js +2 -0
- package/dist/config-import.d.ts +1 -1
- package/dist/config-import.js +6 -2
- package/dist/config-sandbox.d.ts +1 -1
- package/dist/config-sandbox.js +3 -3
- package/dist/config.d.ts +369 -10
- package/dist/config.js +127 -7
- package/dist/deep-observation.js +9 -3
- package/dist/floor-table.data.js +21 -1
- package/dist/forge-remote.d.ts +13 -0
- package/dist/forge-remote.js +15 -0
- package/dist/lexicon.d.ts +45 -4
- package/dist/lifecycle/__fixtures__/package-files.d.ts +32 -0
- package/dist/lifecycle/__fixtures__/package-files.js +72 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +62 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.js +275 -3
- package/dist/lifecycle/publish-attachments.d.ts +2 -1
- package/dist/lifecycle/publish-attachments.js +19 -2
- package/dist/lifecycle/publish-cargo.d.ts +99 -0
- package/dist/lifecycle/publish-cargo.js +412 -0
- package/dist/lifecycle/publish-credentials.d.ts +1 -1
- package/dist/lifecycle/publish-credentials.js +13 -0
- package/dist/lifecycle/publish-declaration.d.ts +322 -4
- package/dist/lifecycle/publish-declaration.js +340 -9
- package/dist/lifecycle/publish-forge.d.ts +45 -2
- package/dist/lifecycle/publish-forge.js +434 -34
- package/dist/lifecycle/publish-git-ssh.d.ts +15 -0
- package/dist/lifecycle/publish-git-ssh.js +30 -4
- package/dist/lifecycle/publish-github.d.ts +40 -2
- package/dist/lifecycle/publish-github.js +100 -3
- package/dist/lifecycle/publish-helm.d.ts +83 -0
- package/dist/lifecycle/publish-helm.js +452 -0
- package/dist/lifecycle/publish-homebrew.d.ts +7 -9
- package/dist/lifecycle/publish-homebrew.js +34 -197
- package/dist/lifecycle/publish-index.d.ts +141 -0
- package/dist/lifecycle/publish-index.js +719 -0
- package/dist/lifecycle/publish-marketplace.js +77 -0
- package/dist/lifecycle/publish-maven.d.ts +79 -0
- package/dist/lifecycle/publish-maven.js +364 -0
- package/dist/lifecycle/publish-mcp-registry.d.ts +66 -0
- package/dist/lifecycle/publish-mcp-registry.js +305 -0
- package/dist/lifecycle/publish-npm.d.ts +27 -1
- package/dist/lifecycle/publish-npm.js +216 -3
- package/dist/lifecycle/publish-nuget.d.ts +93 -0
- package/dist/lifecycle/publish-nuget.js +377 -0
- package/dist/lifecycle/publish-oci.d.ts +91 -2
- package/dist/lifecycle/publish-oci.js +247 -8
- package/dist/lifecycle/publish-package-files.d.ts +16 -0
- package/dist/lifecycle/publish-package-files.js +39 -0
- package/dist/lifecycle/publish-pypi.d.ts +138 -0
- package/dist/lifecycle/publish-pypi.js +657 -0
- package/dist/lifecycle/publish-record.d.ts +6 -3
- package/dist/lifecycle/publish-record.js +6 -3
- package/dist/lifecycle/publish-rubygems.d.ts +84 -0
- package/dist/lifecycle/publish-rubygems.js +366 -0
- package/dist/lifecycle/publish-signing.d.ts +147 -0
- package/dist/lifecycle/publish-signing.js +257 -0
- package/dist/lifecycle/publish-targets.d.ts +37 -1
- package/dist/lifecycle/publish-targets.js +102 -0
- package/dist/lifecycle/publish-tauri.js +43 -0
- package/dist/lifecycle/publish-train-names.d.ts +57 -0
- package/dist/lifecycle/publish-train-names.js +123 -0
- package/dist/lifecycle/publish-verify.d.ts +121 -0
- package/dist/lifecycle/publish-verify.js +130 -0
- package/dist/lifecycle/query.js +8 -0
- package/dist/lifecycle/release-artifacts.d.ts +290 -0
- package/dist/lifecycle/release-artifacts.js +808 -0
- package/dist/lifecycle/release-changelog.d.ts +13 -1
- package/dist/lifecycle/release-changelog.js +35 -2
- package/dist/lifecycle/release-cut.d.ts +64 -4
- package/dist/lifecycle/release-cut.js +147 -34
- package/dist/lifecycle/release-doctor.d.ts +113 -0
- package/dist/lifecycle/release-doctor.js +1198 -0
- package/dist/lifecycle/release-green.d.ts +86 -0
- package/dist/lifecycle/release-green.js +286 -0
- package/dist/lifecycle/release-init-registries.d.ts +48 -0
- package/dist/lifecycle/release-init-registries.js +97 -0
- package/dist/lifecycle/release-init.d.ts +275 -0
- package/dist/lifecycle/release-init.js +984 -0
- package/dist/lifecycle/release-intents.d.ts +73 -0
- package/dist/lifecycle/release-intents.js +128 -0
- package/dist/lifecycle/release-next.d.ts +111 -0
- package/dist/lifecycle/release-next.js +251 -0
- package/dist/lifecycle/release-prerelease.d.ts +19 -0
- package/dist/lifecycle/release-prerelease.js +30 -0
- package/dist/lifecycle/release-publish.d.ts +256 -10
- package/dist/lifecycle/release-publish.js +247 -35
- package/dist/lifecycle/release-status-change.d.ts +226 -0
- package/dist/lifecycle/release-status-change.js +478 -0
- package/dist/lifecycle/release-status.d.ts +11 -0
- package/dist/lifecycle/release-status.js +1 -1
- package/dist/lifecycle/release-store.d.ts +73 -2
- package/dist/lifecycle/release-store.js +32 -1
- package/dist/lifecycle/release-tag.d.ts +142 -0
- package/dist/lifecycle/release-tag.js +322 -0
- package/dist/lifecycle/release-verify.d.ts +73 -1
- package/dist/lifecycle/release-verify.js +117 -2
- package/dist/lifecycle/release-version-formats.d.ts +73 -0
- package/dist/lifecycle/release-version-formats.js +570 -0
- package/dist/lifecycle/release-version.d.ts +58 -10
- package/dist/lifecycle/release-version.js +164 -36
- package/dist/lifecycle/release-workstation.d.ts +3 -2
- package/dist/lifecycle/release-workstation.js +3 -2
- package/dist/op/generate-pipeline.js +1 -1
- package/dist/op/local-executor.d.ts +1 -1
- package/dist/op/local-executor.js +2 -2
- package/dist/op/op-waves-evidence.js +9 -2
- package/dist/pr-forge-base.js +4 -2
- package/dist/pr-forge.d.ts +20 -2
- package/dist/pr-forge.js +46 -10
- package/dist/release-floors.d.ts +8 -1
- package/dist/release-floors.js +9 -2
- package/dist/sensitive-key.d.ts +12 -0
- package/dist/sensitive-key.js +52 -0
- package/dist/tool-pins.d.ts +40 -0
- package/dist/tool-pins.js +66 -0
- package/dist/ts-loader.d.ts +8 -0
- package/dist/ts-loader.js +19 -0
- package/dist/wave-runtime.mjs +345 -342
- package/dist/workspace/ci-forge.d.ts +17 -0
- package/dist/workspace/ci-forge.js +17 -0
- package/dist/workspace/ci-init.js +1 -1
- package/dist/workspace/composites.schema.json +1 -0
- package/dist/workspace/declaration.d.ts +8 -0
- package/dist/workspace/declaration.js +12 -0
- package/dist/workspace/declaration.schema.json +8 -0
- package/dist/workspace/environments.d.ts +2 -0
- package/dist/workspace/environments.js +1 -1
- package/dist/workspace/identity-gate-rule.d.ts +61 -5
- package/dist/workspace/identity-gate-rule.js +81 -12
- package/dist/workspace/lexicon-outputs.d.ts +1 -1
- package/dist/workspace/lexicon-outputs.js +1 -1
- package/dist/workspace/member-pipeline.d.ts +2 -1
- package/dist/workspace/member-pipeline.js +5 -2
- package/dist/workspace/reason-codes.d.ts +2 -0
- package/dist/workspace/reason-codes.js +3 -1
- package/dist/workspace/release-changed.d.ts +75 -4
- package/dist/workspace/release-changed.js +205 -34
- package/dist/workspace/release-changed.schema.json +20 -2
- package/dist/workspace/release-steps/artifacts.d.ts +7 -0
- package/dist/workspace/release-steps/artifacts.js +45 -0
- package/dist/workspace/release-steps/builds.d.ts +12 -0
- package/dist/workspace/release-steps/builds.js +38 -0
- package/dist/workspace/release-steps/doctor.d.ts +8 -0
- package/dist/workspace/release-steps/doctor.js +14 -0
- package/dist/workspace/release-steps/goreleaser.d.ts +16 -0
- package/dist/workspace/release-steps/goreleaser.js +36 -0
- package/dist/workspace/release-steps/green.d.ts +3 -0
- package/dist/workspace/release-steps/green.js +6 -0
- package/dist/workspace/release-steps/images.d.ts +22 -0
- package/dist/workspace/release-steps/images.js +59 -0
- package/dist/workspace/release-steps/index.d.ts +9 -0
- package/dist/workspace/release-steps/index.js +50 -0
- package/dist/workspace/release-steps/nfpm.d.ts +13 -0
- package/dist/workspace/release-steps/nfpm.js +29 -0
- package/dist/workspace/release-steps/nuget.d.ts +14 -0
- package/dist/workspace/release-steps/nuget.js +16 -0
- package/dist/workspace/release-steps/pypi.d.ts +15 -0
- package/dist/workspace/release-steps/pypi.js +21 -0
- package/dist/workspace/release-steps/qemu.d.ts +21 -0
- package/dist/workspace/release-steps/qemu.js +35 -0
- package/dist/workspace/release-steps/signing.d.ts +18 -0
- package/dist/workspace/release-steps/signing.js +30 -0
- package/dist/workspace/release-steps/stamp.d.ts +3 -0
- package/dist/workspace/release-steps/stamp.js +4 -0
- package/dist/workspace/release-steps/targets.d.ts +31 -0
- package/dist/workspace/release-steps/targets.js +40 -0
- package/dist/workspace/release-steps/types.d.ts +104 -0
- package/dist/workspace/release-steps/types.js +2 -0
- package/dist/workspace/release-steps/verify.d.ts +3 -0
- package/dist/workspace/release-steps/verify.js +4 -0
- package/dist/workspace/release-toolchains.d.ts +59 -0
- package/dist/workspace/release-toolchains.js +133 -0
- package/dist/workspace/release-train-workflow.d.ts +36 -0
- package/dist/workspace/release-train-workflow.js +121 -0
- package/dist/workspace/release-train.d.ts +3 -1
- package/dist/workspace/release-train.js +20 -3
- package/dist/workspace/release-workflow.d.ts +183 -59
- package/dist/workspace/release-workflow.js +570 -201
- package/dist/workspace/releases.schema.json +70 -1
- package/dist/workspace/search-contract.d.ts +1 -1
- package/dist/workspace/security.js +9 -2
- package/dist/workspace/train-cut.d.ts +182 -0
- package/dist/workspace/train-cut.js +504 -0
- package/dist/workspace/train-prepare.d.ts +64 -0
- package/dist/workspace/train-prepare.js +313 -0
- package/dist/workspace/train-publish.d.ts +177 -0
- package/dist/workspace/train-publish.js +574 -0
- package/dist/workspace/train-range-labels.d.ts +33 -0
- package/dist/workspace/train-range-labels.js +109 -0
- package/dist/workspace/train-shell.d.ts +5 -0
- package/dist/workspace/train-shell.js +17 -0
- package/dist/workspace/trust/check-evidence-report.d.ts +3 -7
- package/dist/workspace/trust/check-evidence-report.js +3 -7
- package/dist/workspace/trust/seal.d.ts +13 -3
- package/dist/workspace/trust/seal.js +14 -4
- package/dist/workspace/work-cli.d.ts +3 -2
- package/dist/workspace/work-cli.js +3 -2
- package/dist/workspace/workspace-ledger.d.ts +14 -1
- package/dist/workspace/workspace-ledger.js +33 -7
- package/package.json +1 -1
|
@@ -46,219 +46,56 @@
|
|
|
46
46
|
* The asset URLs are the declaration's `url` pattern, so the files must be
|
|
47
47
|
* downloadable there by the time the formula is: declare the `forge` target
|
|
48
48
|
* that attaches them before this one, and its reveal runs first.
|
|
49
|
+
*
|
|
50
|
+
* Since #5158 this target is the `index` target's `homebrew-tap` preset
|
|
51
|
+
* (./publish-index.ts) with the fields, kind, key, error codes and order it
|
|
52
|
+
* always had: it stages and reveals in the order declared, a refusal fails
|
|
53
|
+
* the publish, and each SHA-256 is of the file in the checkout.
|
|
49
54
|
*/
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import { readCredential } from "./publish-credentials.js";
|
|
53
|
-
import { SshGitRepo } from "./publish-git-ssh.js";
|
|
54
|
-
import { GitHubRepo, githubApi } from "./publish-github.js";
|
|
55
|
-
import { bytesDigest, checkReleaseDigest, memberFile, publishTargetKey } from "./publish-targets.js";
|
|
55
|
+
import { fillUrl, indexTargetOf, releaseVersion, renderManifest } from "./publish-index.js";
|
|
56
|
+
import { publishTargetKey } from "./publish-targets.js";
|
|
56
57
|
import { PublishTargetError } from "./release-publish.js";
|
|
58
|
+
import { basename } from "node:path";
|
|
59
|
+
export { fillUrl, releaseVersion };
|
|
57
60
|
/** The first chant that publishes a `homebrew` target (#4676). */
|
|
58
61
|
export const PUBLISH_HOMEBREW_FLOOR = "0.124.63";
|
|
59
62
|
/** The first chant that reads a homebrew target's `sshKeyEnv` (#4699). */
|
|
60
63
|
export const PUBLISH_HOMEBREW_SSH_KEY_FLOOR = "0.124.64";
|
|
61
64
|
/** The variable the tap token is read from when the declaration names none. */
|
|
62
65
|
export const HOMEBREW_TOKEN_ENV = "HOMEBREW_TAP_TOKEN";
|
|
63
|
-
/** A release's version for a package manager: its label from the first digit on, or null when the label has no digit. */
|
|
64
|
-
export function releaseVersion(label) {
|
|
65
|
-
const at = label?.search(/\d/) ?? -1;
|
|
66
|
-
return label && at >= 0 ? label.slice(at) : null;
|
|
67
|
-
}
|
|
68
|
-
/** `pattern` with `{tag}`, `{label}`, `{version}` and `{name}` filled in, each URL-encoded except the tag's slashes. */
|
|
69
|
-
export function fillUrl(pattern, values) {
|
|
70
|
-
return pattern.replace(/\{(tag|label|version|name)\}/g, (_, k) => k === "tag" ? values.tag.split("/").map(encodeURIComponent).join("/") : encodeURIComponent(values[k]));
|
|
71
|
-
}
|
|
72
66
|
/** Render a formula template, or name what it can't fill. */
|
|
73
67
|
export function renderFormula(template, values, assets) {
|
|
74
|
-
return template
|
|
75
|
-
if (inner === "version" || inner === "label" || inner === "tag")
|
|
76
|
-
return values[inner];
|
|
77
|
-
const m = /^(url|sha256):(.+)$/.exec(inner);
|
|
78
|
-
const asset = m ? assets.get(m[2].trim()) : undefined;
|
|
79
|
-
if (m && asset)
|
|
80
|
-
return m[1] === "url" ? asset.url : asset.sha256;
|
|
81
|
-
throw new PublishTargetError("publish-homebrew-template", m ? `the formula template names ${whole}, and no declared asset is named ${m[2].trim()}` : `the formula template has ${whole}, which chant does not fill`, `The placeholders are {{version}}, {{label}}, {{tag}}, and {{url:<name>}} and {{sha256:<name>}} for an asset in assets: ${[...assets.keys()].join(", ")}.`);
|
|
82
|
-
});
|
|
68
|
+
return renderManifest(template, values, assets, "publish-homebrew-template", "the formula template");
|
|
83
69
|
}
|
|
84
70
|
export function homebrewTarget(decl, deps) {
|
|
85
|
-
const fetchImpl = deps.fetch ?? ((url, init) => fetch(url, init));
|
|
86
71
|
if (decl.sshKeyEnv && decl.tokenEnv) {
|
|
87
72
|
throw new PublishTargetError("publish-homebrew-auth-invalid", `the homebrew target for ${decl.tap} names both tokenEnv and sshKeyEnv`, "Keep one: sshKeyEnv pushes with git over SSH, tokenEnv commits through the API.");
|
|
88
73
|
}
|
|
89
|
-
const ssh = decl.sshKeyEnv !== undefined;
|
|
90
|
-
const tokenNames = [decl.sshKeyEnv ?? decl.tokenEnv ?? HOMEBREW_TOKEN_ENV];
|
|
91
74
|
const formulaName = basename(decl.formula).replace(/\.rb$/, "");
|
|
92
|
-
|
|
93
|
-
const version = releaseVersion(ctx.label);
|
|
94
|
-
if (!version || !ctx.label || !ctx.releaseTag) {
|
|
95
|
-
throw new PublishTargetError("publish-homebrew-no-version", `a formula's version is the release's label from its first digit, and release ${ctx.release.releaseDigest} has ${ctx.label ? `the label ${ctx.label}, which has no digit` : "no label"}`, "Cut the release with a label such as v1.4.0.");
|
|
96
|
-
}
|
|
97
|
-
const token = readCredential(ctx.env, tokenNames, ctx.redactor);
|
|
98
|
-
if (!token) {
|
|
99
|
-
throw new PublishTargetError("publish-credentials-missing", `the homebrew target reads its ${ssh ? "SSH key" : "token"} from ${tokenNames[0]}, and it is not set`, ssh ? `Set ${tokenNames[0]} to a private key that may push to ${decl.tap}, such as a deploy key with write access.` : `Set ${tokenNames[0]} to a token that may push to ${decl.tap}.`);
|
|
100
|
-
}
|
|
101
|
-
const assets = new Map();
|
|
102
|
-
for (const p of decl.assets) {
|
|
103
|
-
const abs = memberFile(ctx.cwd, p);
|
|
104
|
-
const digest = bytesDigest(new Uint8Array(readFileSync(abs)));
|
|
105
|
-
checkReleaseDigest(ctx.release, "asset", ctx.cwd, p, [digest]);
|
|
106
|
-
const name = basename(p);
|
|
107
|
-
if (assets.has(name))
|
|
108
|
-
throw new PublishTargetError("publish-homebrew-asset-name-taken", `two assets are named ${name}, and the template names an asset by its file name`);
|
|
109
|
-
const url = fillUrl(decl.url, { tag: ctx.releaseTag, label: ctx.label, version, name });
|
|
110
|
-
assets.set(name, { url, sha256: digest.slice("sha256:".length) });
|
|
111
|
-
}
|
|
112
|
-
const template = readFileSync(memberFile(ctx.cwd, decl.template), "utf-8");
|
|
113
|
-
const bytes = new Uint8Array(Buffer.from(renderFormula(template, { version, label: ctx.label, tag: ctx.releaseTag }, assets), "utf-8"));
|
|
114
|
-
return { version, token, assets, bytes, digest: bytesDigest(bytes) };
|
|
115
|
-
};
|
|
116
|
-
const where = (branch) => `${decl.tap}@${branch}:${decl.formula}`;
|
|
117
|
-
const target = {
|
|
75
|
+
return indexTargetOf({
|
|
118
76
|
kind: "homebrew",
|
|
119
|
-
|
|
120
|
-
destination: `github ${decl.tap}`,
|
|
121
|
-
credentialEnv: tokenNames,
|
|
77
|
+
code: "publish-homebrew",
|
|
122
78
|
key: publishTargetKey(decl),
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
const staging = `chant-publish/${formulaName}-${version}`;
|
|
147
|
-
const stagingHead = await tap.branchHead(staging);
|
|
148
|
-
if (stagingHead) {
|
|
149
|
-
const onStaging = await tap.file(decl.formula, staging);
|
|
150
|
-
if (onStaging && onStaging.bytes.equals(Buffer.from(bytes))) {
|
|
151
|
-
ctx.log(`${staging} already has ${decl.formula} for ${version}`);
|
|
152
|
-
return done({ staging, commit: stagingHead }, true);
|
|
153
|
-
}
|
|
154
|
-
await tap.moveRef(`heads/${staging}`, head, true);
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
await tap.createBranch(staging, head);
|
|
158
|
-
}
|
|
159
|
-
ctx.log(`committing ${decl.formula} for ${version} to ${staging}, at ${branch}'s head ${head.slice(0, 12)}`);
|
|
160
|
-
const commit = await tap.putFile(decl.formula, staging, bytes, `${formulaName} ${version}`, onTap?.sha ?? null);
|
|
161
|
-
return done({ staging, commit }, false);
|
|
162
|
-
},
|
|
163
|
-
async reveal(ctx, staged) {
|
|
164
|
-
const items = staged.items.map((i) => ({ name: i.name, destination: i.destination, ...(i.digest ? { digest: i.digest } : {}) }));
|
|
165
|
-
const published = { target: target.name, destination: target.destination, items };
|
|
166
|
-
if (staged.state.present === "true")
|
|
167
|
-
return { ...published, items: items.map((i) => ({ ...i, present: true })) };
|
|
168
|
-
const { version, token, bytes } = setup(ctx);
|
|
169
|
-
const { branch, staging, commit } = staged.state;
|
|
170
|
-
if (!branch || !staging || !commit)
|
|
171
|
-
throw new PublishTargetError("publish-homebrew-failed", `the staged formula for ${decl.tap} has no staging commit to reveal`);
|
|
172
|
-
if (ssh) {
|
|
173
|
-
await withSsh(ctx, token, (tap) => revealOverSsh(ctx, tap, { branch, staging, commit }, version, bytes));
|
|
174
|
-
return published;
|
|
175
|
-
}
|
|
176
|
-
const tap = new GitHubRepo(githubApi(decl.api, ctx.env), decl.tap, token, fetchImpl, ctx, "publish-homebrew-failed");
|
|
177
|
-
ctx.log(`fast-forwarding ${branch} to ${commit.slice(0, 12)}`);
|
|
178
|
-
if (!(await tap.moveRef(`heads/${branch}`, commit, false))) {
|
|
179
|
-
// The tap moved since the stage: one commit of the formula onto it, unless it already holds it.
|
|
180
|
-
const onTap = await tap.file(decl.formula, branch);
|
|
181
|
-
if (onTap && onTap.bytes.equals(Buffer.from(bytes))) {
|
|
182
|
-
ctx.log(`${branch} moved since the stage and already has ${decl.formula} for ${version}`);
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
ctx.log(`${branch} moved since the stage; committing ${decl.formula} for ${version} onto it`);
|
|
186
|
-
await tap.putFile(decl.formula, branch, bytes, `${formulaName} ${version}`, onTap?.sha ?? null);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
await tap.deleteRef(`heads/${staging}`);
|
|
190
|
-
return published;
|
|
191
|
-
},
|
|
192
|
-
};
|
|
193
|
-
async function withSsh(ctx, key, step) {
|
|
194
|
-
const tap = await SshGitRepo.open({ api: githubApi(decl.api, ctx.env), repo: decl.tap, key, ctx, fetch: fetchImpl, code: "publish-homebrew-failed", git: deps.git, ssh: deps.ssh });
|
|
195
|
-
try {
|
|
196
|
-
return await step(tap);
|
|
197
|
-
}
|
|
198
|
-
finally {
|
|
199
|
-
tap.close();
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
async function stageOverSsh(ctx, tap, version, bytes, digest) {
|
|
203
|
-
const { defaultBranch, heads } = await tap.heads();
|
|
204
|
-
const branch = decl.branch ?? defaultBranch;
|
|
205
|
-
const head = branch ? heads.get(branch) : undefined;
|
|
206
|
-
if (!branch || !head)
|
|
207
|
-
throw new PublishTargetError("publish-homebrew-failed", `${tap.remote} has no branch ${branch ?? "HEAD points at"}`, "Set branch to the branch brew installs from.");
|
|
208
|
-
const item = { name: decl.formula, destination: where(branch), digest };
|
|
209
|
-
const done = (state, present) => ({ target: target.name, destination: target.destination, items: [{ ...item, ...(present ? { present: true } : {}) }], state: { branch, ...state } });
|
|
210
|
-
ctx.log(`reading ${branch} of ${tap.remote} over SSH`);
|
|
211
|
-
await tap.fetch(branch);
|
|
212
|
-
const onTap = await tap.file(head, decl.formula);
|
|
213
|
-
if (onTap && onTap.equals(Buffer.from(bytes))) {
|
|
214
|
-
ctx.log(`${branch} already has ${decl.formula} for ${version}`);
|
|
215
|
-
return done({ present: "true" }, true);
|
|
216
|
-
}
|
|
217
|
-
const staging = `chant-publish/${formulaName}-${version}`;
|
|
218
|
-
const stagingHead = heads.get(staging);
|
|
219
|
-
if (stagingHead) {
|
|
220
|
-
await tap.fetch(staging);
|
|
221
|
-
const onStaging = await tap.file(stagingHead, decl.formula);
|
|
222
|
-
if (onStaging && onStaging.equals(Buffer.from(bytes))) {
|
|
223
|
-
ctx.log(`${staging} already has ${decl.formula} for ${version}`);
|
|
224
|
-
return done({ staging, commit: stagingHead }, true);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
ctx.log(`committing ${decl.formula} for ${version} to ${staging}, at ${branch}'s head ${head.slice(0, 12)}, and pushing it over SSH`);
|
|
228
|
-
const commit = await tap.commitFile(head, decl.formula, bytes, `${formulaName} ${version}`);
|
|
229
|
-
await tap.push(commit, staging, true);
|
|
230
|
-
return done({ staging, commit }, false);
|
|
231
|
-
}
|
|
232
|
-
async function revealOverSsh(ctx, tap, state, version, bytes) {
|
|
233
|
-
const { branch, staging, commit } = state;
|
|
234
|
-
const { heads } = await tap.heads();
|
|
235
|
-
// The staged commit is on the staging branch: fetch it, since this run may be a resume on a fresh clone.
|
|
236
|
-
// Depth 2: the staged commit and the head it was made on, so git sees the push as a fast-forward.
|
|
237
|
-
const stagingHead = heads.get(staging) === commit ? await tap.fetch(staging, 2) : null;
|
|
238
|
-
let moved = true;
|
|
239
|
-
if (stagingHead === commit) {
|
|
240
|
-
ctx.log(`fast-forwarding ${branch} to ${commit.slice(0, 12)} over SSH`);
|
|
241
|
-
moved = (await tap.push(commit, branch, false)) === "rejected";
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
ctx.log(`${staging} is not at the staged commit ${commit.slice(0, 12)} any more`);
|
|
245
|
-
}
|
|
246
|
-
if (moved) {
|
|
247
|
-
// The tap moved since the stage, or the staged commit is gone: one commit of the formula onto it, unless it already holds it.
|
|
248
|
-
const head = await tap.fetch(branch);
|
|
249
|
-
const onTap = await tap.file(head, decl.formula);
|
|
250
|
-
if (onTap && onTap.equals(Buffer.from(bytes))) {
|
|
251
|
-
ctx.log(`${branch} already has ${decl.formula} for ${version}`);
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
ctx.log(`committing ${decl.formula} for ${version} onto ${branch}'s head ${head.slice(0, 12)}`);
|
|
255
|
-
const onto = await tap.commitFile(head, decl.formula, bytes, `${formulaName} ${version}`);
|
|
256
|
-
if ((await tap.push(onto, branch, false)) === "rejected") {
|
|
257
|
-
throw new PublishTargetError("publish-homebrew-failed", `${branch} of ${tap.remote} moved again while ${decl.formula} was committed onto it`, "Run the same publish again: it commits the formula onto the branch's new head.");
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
await tap.deleteBranch(staging);
|
|
262
|
-
}
|
|
263
|
-
return target;
|
|
79
|
+
label: `homebrew formula ${formulaName} in ${decl.tap}`,
|
|
80
|
+
destination: `github ${decl.tap}`,
|
|
81
|
+
name: formulaName,
|
|
82
|
+
repo: decl.tap,
|
|
83
|
+
mode: "commit",
|
|
84
|
+
files: [{ path: decl.formula, template: decl.template }],
|
|
85
|
+
zed: false,
|
|
86
|
+
assets: decl.assets,
|
|
87
|
+
url: decl.url,
|
|
88
|
+
branch: decl.branch,
|
|
89
|
+
fork: undefined,
|
|
90
|
+
title: "{name} {version}",
|
|
91
|
+
body: "",
|
|
92
|
+
api: decl.api,
|
|
93
|
+
tokenEnv: decl.tokenEnv ?? HOMEBREW_TOKEN_ENV,
|
|
94
|
+
sshKeyEnv: decl.sshKeyEnv,
|
|
95
|
+
revealsLast: false,
|
|
96
|
+
refusalWarns: false,
|
|
97
|
+
digests: "file",
|
|
98
|
+
placeholders: ["version", "label", "tag"],
|
|
99
|
+
branchIs: "the branch brew installs from",
|
|
100
|
+
}, deps);
|
|
264
101
|
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The index-repository target (#5158): manifests in a repository on GitHub
|
|
3
|
+
* that a package manager or a directory reads, rendered from templates in
|
|
4
|
+
* the member, and either committed to a repository the publisher may push
|
|
5
|
+
* to or proposed in a pull request on one it can't.
|
|
6
|
+
*
|
|
7
|
+
* Presets fill in what a known index needs (./publish-declaration.ts,
|
|
8
|
+
* `INDEX_PRESETS`):
|
|
9
|
+
*
|
|
10
|
+
* | Preset | Repository | Mode | Manifest |
|
|
11
|
+
* |---|---|---|---|
|
|
12
|
+
* | `krew` | kubernetes-sigs/krew-index | pull-request | `plugins/{name}.yaml` |
|
|
13
|
+
* | `winget` | microsoft/winget-pkgs | pull-request | `files`, under `manifests/{letter}/{namePath}/{version}/` |
|
|
14
|
+
* | `scoop` | yours | commit | `bucket/{name}.json` |
|
|
15
|
+
* | `homebrew-core` | Homebrew/homebrew-core | pull-request | `Formula/{letter}/{name}.rb` |
|
|
16
|
+
* | `homebrew-tap` | yours | commit | `Formula/{name}.rb` |
|
|
17
|
+
* | `zed` | zed-industries/extensions | pull-request | `version` in `extensions.toml`, and the `extensions/{name}` submodule at the release's commit |
|
|
18
|
+
* | `artifacthub` | yours | commit | `{name}/{version}/artifacthub-pkg.yml` |
|
|
19
|
+
*
|
|
20
|
+
* The templates take the `homebrew` target's placeholders (`{{version}}`,
|
|
21
|
+
* `{{label}}`, `{{tag}}`, `{{url:<asset>}}`, `{{sha256:<asset>}}`) and
|
|
22
|
+
* `{{name}}` and `{{commit}}`. Each asset is one the release records, named
|
|
23
|
+
* by `artifact:<name>` (#5151) or by its path, and its SHA-256 is the one the
|
|
24
|
+
* release records: the file is never read or hashed again.
|
|
25
|
+
*
|
|
26
|
+
* `mode: "commit"` is the tap's two steps (./publish-homebrew.ts): the stage
|
|
27
|
+
* commits to `chant-publish/<name>-<version>` beside the branch, and the
|
|
28
|
+
* reveal fast-forwards the branch. `mode: "pull-request"` stages the same
|
|
29
|
+
* commit on a branch of the publisher's fork (made when there is none), and
|
|
30
|
+
* the reveal opens the pull request. A resume finds the pull request it
|
|
31
|
+
* opened, open or merged, and opens none again; one the index closed without
|
|
32
|
+
* merging is a refusal. An index that already holds the manifests as
|
|
33
|
+
* rendered, such as one a bot updated, gets nothing.
|
|
34
|
+
*
|
|
35
|
+
* The target reveals last (`revealsLast`, as the MCP Registry does): it
|
|
36
|
+
* stages with the other targets, onto a branch no consumer reads, and
|
|
37
|
+
* reveals after every other target, since the index points at files those
|
|
38
|
+
* targets make downloadable. Targets that reveal last go in the order
|
|
39
|
+
* declared. A refusal is a warning unless `onRefusal: "fail"`
|
|
40
|
+
* (`refusalWarns`).
|
|
41
|
+
*
|
|
42
|
+
* The `homebrew` target is this target's `homebrew-tap` preset with its own
|
|
43
|
+
* fields, kind and codes, staged and revealed in the order declared as
|
|
44
|
+
* before, its hashes read from the checkout and checked against the record.
|
|
45
|
+
*
|
|
46
|
+
* Status changes (#5163, `chant release yank|restore`): an index has no
|
|
47
|
+
* per-version deprecation, so deprecate changes nothing. In `mode: "commit"`
|
|
48
|
+
* a yank puts back each manifest as the head release (the newest active one
|
|
49
|
+
* of the channel) published it, found by its digest among the last 100
|
|
50
|
+
* commits of the branch that touch it, when the branch still holds this
|
|
51
|
+
* release's; a manifest the head release did not publish, such as Artifact
|
|
52
|
+
* Hub's `{name}/{version}/artifacthub-pkg.yml`, is removed. A restore puts
|
|
53
|
+
* this release's manifests back, from the same history, where no newer
|
|
54
|
+
* active release holds the path. One commit either way. In
|
|
55
|
+
* `mode: "pull-request"` the index's maintainers merge what changes, so a
|
|
56
|
+
* yank or restore is refused (`release-status-index-pull-request`).
|
|
57
|
+
*/
|
|
58
|
+
import type { IndexPublishDeclaration } from "./publish-declaration.js";
|
|
59
|
+
import { type PublishDeps, type PublishTarget } from "./release-publish.js";
|
|
60
|
+
/** The first chant that publishes an `index` target (#5158). */
|
|
61
|
+
export declare const PUBLISH_INDEX_FLOOR = "0.124.101";
|
|
62
|
+
/** The variable an index target reads its token from when the declaration names none. */
|
|
63
|
+
export declare const INDEX_TOKEN_ENV = "INDEX_TOKEN";
|
|
64
|
+
type Preset = NonNullable<IndexPublishDeclaration["preset"]>;
|
|
65
|
+
/** What each preset fills in. */
|
|
66
|
+
export declare const INDEX_PRESET_DEFAULTS: Readonly<Record<Preset, {
|
|
67
|
+
repo?: string;
|
|
68
|
+
mode: "commit" | "pull-request";
|
|
69
|
+
path?: string;
|
|
70
|
+
title: string;
|
|
71
|
+
tokenEnv?: string;
|
|
72
|
+
}>>;
|
|
73
|
+
/** A release's version for a package manager: its label from the first digit on, or null when the label has no digit. */
|
|
74
|
+
export declare function releaseVersion(label: string | null): string | null;
|
|
75
|
+
/** `pattern` with `{tag}`, `{label}`, `{version}` and `{name}` filled in, each URL-encoded except the tag's slashes. */
|
|
76
|
+
export declare function fillUrl(pattern: string, values: {
|
|
77
|
+
tag: string;
|
|
78
|
+
label: string;
|
|
79
|
+
version: string;
|
|
80
|
+
name: string;
|
|
81
|
+
}): string;
|
|
82
|
+
/** Render a manifest template with `values` (each `{{key}}`) and each asset's `{{url:<name>}}` and `{{sha256:<name>}}`, or name what it can't fill, refused with `code`. */
|
|
83
|
+
export declare function renderManifest(template: string, values: Readonly<Record<string, string>>, assets: ReadonlyMap<string, {
|
|
84
|
+
url: string;
|
|
85
|
+
sha256: string;
|
|
86
|
+
}>, code: string, what?: string): string;
|
|
87
|
+
/** An index path with `{name}`, `{version}`, `{label}`, `{letter}` and `{namePath}` filled in, refused when it names anything else or leaves the repository. */
|
|
88
|
+
export declare function fillIndexPath(pattern: string, values: {
|
|
89
|
+
name: string;
|
|
90
|
+
version: string;
|
|
91
|
+
label: string;
|
|
92
|
+
}, code: string): string;
|
|
93
|
+
/**
|
|
94
|
+
* `text` with `version = "<version>"` set in the TOML table `[<table>]`, the
|
|
95
|
+
* rest of the file as it was. Null when the file has no such table.
|
|
96
|
+
*/
|
|
97
|
+
export declare function setTomlTableVersion(text: string, table: string, version: string): string | null;
|
|
98
|
+
/** What the target is, from an `index` declaration or a `homebrew` one. */
|
|
99
|
+
export interface IndexSettings {
|
|
100
|
+
kind: "index" | "homebrew";
|
|
101
|
+
/** The error code prefix: `publish-index` or `publish-homebrew`. */
|
|
102
|
+
code: string;
|
|
103
|
+
key: string;
|
|
104
|
+
/** The target's name in messages. */
|
|
105
|
+
label: string;
|
|
106
|
+
destination: string;
|
|
107
|
+
/** The package's name in the index. */
|
|
108
|
+
name: string;
|
|
109
|
+
repo: string;
|
|
110
|
+
mode: "commit" | "pull-request";
|
|
111
|
+
/** Each manifest: its path pattern in the index, and its template in the member. */
|
|
112
|
+
files: Array<{
|
|
113
|
+
path: string;
|
|
114
|
+
template: string;
|
|
115
|
+
}>;
|
|
116
|
+
zed: boolean;
|
|
117
|
+
assets: string[];
|
|
118
|
+
url: string | undefined;
|
|
119
|
+
branch: string | undefined;
|
|
120
|
+
fork: string | undefined;
|
|
121
|
+
title: string;
|
|
122
|
+
body: string;
|
|
123
|
+
api: string | undefined;
|
|
124
|
+
tokenEnv: string;
|
|
125
|
+
sshKeyEnv: string | undefined;
|
|
126
|
+
revealsLast: boolean;
|
|
127
|
+
refusalWarns: boolean;
|
|
128
|
+
/** `record`: each asset's SHA-256 is the release's record of it. `file`: the file in the checkout's, checked against the record (the `homebrew` target). */
|
|
129
|
+
digests: "record" | "file";
|
|
130
|
+
/** The placeholders a template may use beyond the assets'. */
|
|
131
|
+
placeholders: ReadonlyArray<"version" | "label" | "tag" | "name" | "commit">;
|
|
132
|
+
/** What the branch is, for a fix: "the branch brew installs from". */
|
|
133
|
+
branchIs: string;
|
|
134
|
+
}
|
|
135
|
+
/** The settings of an `index` declaration, its preset filled in. Refuses a declaration that can't publish (`publish-index-invalid`). */
|
|
136
|
+
export declare function indexSettings(decl: IndexPublishDeclaration): IndexSettings;
|
|
137
|
+
/** An index target from a declaration. */
|
|
138
|
+
export declare function indexTarget(decl: IndexPublishDeclaration, deps: PublishDeps): PublishTarget;
|
|
139
|
+
/** The target for `s`: an index declaration's, or the `homebrew` target's (./publish-homebrew.ts). */
|
|
140
|
+
export declare function indexTargetOf(s: IndexSettings, deps: PublishDeps): PublishTarget;
|
|
141
|
+
export {};
|