@intentius/chant 0.124.99 → 0.124.101
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/bin/chant +3 -3
- 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-system.d.ts +66 -0
- package/dist/ci-system.js +61 -0
- package/dist/cli/commands/carve-emit.js +2 -2
- package/dist/cli/commands/check-lexicon-plugin.d.ts +2 -2
- package/dist/cli/commands/check-lexicon-plugin.js +3 -3
- package/dist/cli/commands/check-lexicon.js +4 -4
- package/dist/cli/commands/init-lexicon/templates/project.d.ts +1 -1
- package/dist/cli/commands/init-lexicon/templates/project.js +4 -4
- package/dist/cli/commands/init.d.ts +13 -0
- package/dist/cli/commands/init.js +30 -2
- 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 +342 -0
- package/dist/cli/handlers/release.d.ts +50 -1
- package/dist/cli/handlers/release.js +688 -30
- package/dist/cli/handlers/run-generate.js +11 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +45 -97
- package/dist/cli/parse-args.js +55 -0
- package/dist/cli/registry.d.ts +18 -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 +49 -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 +16 -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 +13 -0
- package/dist/codegen/pinned-upgrade.js +1 -1
- package/dist/components/capability-plugin.d.ts +1 -1
- package/dist/components/capability-plugin.js +1 -1
- 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.d.ts +299 -6
- package/dist/config.js +102 -5
- package/dist/dead-guards.d.ts +5 -1
- package/dist/dead-guards.js +34 -23
- package/dist/discovery/sandbox/driver.js +1 -1
- package/dist/discovery/specifier-resolve.js +1 -1
- package/dist/floor-table.d.ts +3 -1
- package/dist/floor-table.data.js +23 -3
- package/dist/floor-table.js +4 -3
- package/dist/forge-remote.d.ts +13 -0
- package/dist/forge-remote.js +15 -0
- package/dist/lexicon.d.ts +41 -2
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +62 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.js +270 -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 +8 -0
- package/dist/lifecycle/publish-declaration.d.ts +199 -4
- package/dist/lifecycle/publish-declaration.js +200 -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-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-mcp-registry.d.ts +66 -0
- package/dist/lifecycle/publish-mcp-registry.js +306 -0
- package/dist/lifecycle/publish-npm.js +165 -2
- package/dist/lifecycle/publish-oci.d.ts +34 -1
- package/dist/lifecycle/publish-oci.js +246 -7
- package/dist/lifecycle/publish-pypi.d.ts +136 -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-signing.d.ts +147 -0
- package/dist/lifecycle/publish-signing.js +257 -0
- package/dist/lifecycle/publish-targets.d.ts +27 -1
- package/dist/lifecycle/publish-targets.js +80 -0
- package/dist/lifecycle/publish-tauri.js +43 -0
- package/dist/lifecycle/publish-train-names.d.ts +54 -0
- package/dist/lifecycle/publish-train-names.js +118 -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 +212 -0
- package/dist/lifecycle/release-artifacts.js +571 -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 +58 -3
- package/dist/lifecycle/release-cut.js +132 -34
- package/dist/lifecycle/release-doctor.d.ts +113 -0
- package/dist/lifecycle/release-doctor.js +996 -0
- package/dist/lifecycle/release-green.d.ts +86 -0
- package/dist/lifecycle/release-green.js +286 -0
- package/dist/lifecycle/release-init.d.ts +255 -0
- package/dist/lifecycle/release-init.js +859 -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 +252 -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 +246 -34
- 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 +323 -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/module-source.d.ts +2 -2
- package/dist/module-source.js +8 -8
- package/dist/op/generate-pipeline.js +1 -1
- 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 +10 -1
- package/dist/release-floors.js +10 -1
- package/dist/tool-pins.d.ts +38 -0
- package/dist/tool-pins.js +54 -0
- package/dist/ts-loader.d.ts +1 -1
- package/dist/ts-loader.js +6 -6
- package/dist/wave-runtime.mjs +337 -334
- 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/member-pipeline.d.ts +2 -1
- package/dist/workspace/member-pipeline.js +5 -2
- package/dist/workspace/reason-codes.d.ts +6 -0
- package/dist/workspace/reason-codes.js +8 -1
- package/dist/workspace/release-changed.d.ts +179 -0
- package/dist/workspace/release-changed.js +625 -0
- package/dist/workspace/release-changed.schema.json +206 -0
- 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 +46 -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 +29 -0
- package/dist/workspace/release-train-workflow.js +85 -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 +160 -61
- package/dist/workspace/release-workflow.js +539 -193
- 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 +482 -0
- package/dist/workspace/train-prepare.d.ts +61 -0
- package/dist/workspace/train-prepare.js +267 -0
- package/dist/workspace/train-publish.d.ts +177 -0
- package/dist/workspace/train-publish.js +575 -0
- package/dist/workspace/train-range-labels.d.ts +33 -0
- package/dist/workspace/train-range-labels.js +109 -0
- 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 +26 -26
|
@@ -137,6 +137,11 @@ export class SshGitRepo {
|
|
|
137
137
|
await this.must(`fetching ${branch}`, ["fetch", "-q", "--no-tags", `--depth=${depth}`, this.remote, `+refs/heads/${branch}:refs/remotes/tap/${branch}`]);
|
|
138
138
|
return (await this.must(`reading ${branch}`, ["rev-parse", `refs/remotes/tap/${branch}`])).trim();
|
|
139
139
|
}
|
|
140
|
+
/** The fetched commits of `branch` that touch `path`, newest first (#5163). Fetch the branch deep enough first. */
|
|
141
|
+
async history(branch, path) {
|
|
142
|
+
const out = await this.must(`reading the history of ${path}`, ["log", "--format=%H", `refs/remotes/tap/${branch}`, "--", path]);
|
|
143
|
+
return out.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
144
|
+
}
|
|
140
145
|
/** The bytes of `path` at a fetched commit, or null when it holds no such file. */
|
|
141
146
|
async file(commit, path) {
|
|
142
147
|
const spec = `${commit}:${path}`;
|
|
@@ -146,14 +151,35 @@ export class SshGitRepo {
|
|
|
146
151
|
execFile(this.git, ["cat-file", "blob", spec], { cwd: this.dir, env: this.env, encoding: "buffer", maxBuffer: 64 * 1024 * 1024 }, (err, stdout) => (err ? reject(err) : resolvePromise(stdout)));
|
|
147
152
|
});
|
|
148
153
|
}
|
|
154
|
+
/** The commit a submodule at `path` points to at a fetched commit, or null when `path` is not a submodule there (#5158). */
|
|
155
|
+
async gitlink(commit, path) {
|
|
156
|
+
const r = await this.run(["ls-tree", commit, "--", path]);
|
|
157
|
+
const m = /^160000 commit ([0-9a-f]{40,64})\t/m.exec(r.stdout);
|
|
158
|
+
return r.code === 0 && m ? m[1] : null;
|
|
159
|
+
}
|
|
149
160
|
/** A commit on `parent` that writes `bytes` to `path`, with `message`. Made here, not pushed. */
|
|
150
161
|
async commitFile(parent, path, bytes, message) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
162
|
+
return this.commitFiles(parent, [{ path, bytes }], message);
|
|
163
|
+
}
|
|
164
|
+
/** A commit on `parent` that writes each file, points each submodule path at its commit (#5158) and removes each `remove` path (#5163). Made here, not pushed. */
|
|
165
|
+
async commitFiles(parent, changes, message) {
|
|
154
166
|
const index = { GIT_INDEX_FILE: join(this.root, "index") };
|
|
155
167
|
await this.must("reading the tree", ["read-tree", parent], index);
|
|
156
|
-
|
|
168
|
+
for (const c of changes) {
|
|
169
|
+
if ("remove" in c) {
|
|
170
|
+
// #5163: a yank takes out a manifest the head release did not publish.
|
|
171
|
+
await this.must(`removing ${c.path}`, ["--work-tree", this.dir, "update-index", "--force-remove", "--", c.path], index);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if ("gitlink" in c) {
|
|
175
|
+
await this.must(`pointing ${c.path} at ${c.gitlink.slice(0, 12)}`, ["update-index", "--add", "--cacheinfo", `160000,${c.gitlink},${c.path}`], index);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
const blobFile = join(this.root, "blob");
|
|
179
|
+
writeFileSync(blobFile, c.bytes);
|
|
180
|
+
const blob = (await this.must("writing the file", ["hash-object", "-w", blobFile])).trim();
|
|
181
|
+
await this.must("staging the file", ["update-index", "--add", "--cacheinfo", `100644,${blob},${c.path}`], index);
|
|
182
|
+
}
|
|
157
183
|
const tree = (await this.must("writing the tree", ["write-tree"], index)).trim();
|
|
158
184
|
rmSync(index.GIT_INDEX_FILE, { force: true });
|
|
159
185
|
const who = (await this.run(["config", "user.email"])).stdout.trim() ? [] : ["-c", "user.name=chant", "-c", "user.email=chant@localhost"];
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The GitHub REST calls the targets that write to a repository other than the
|
|
3
|
-
* release's use (#4676): the Homebrew tap's formula,
|
|
4
|
-
* rolling release
|
|
3
|
+
* release's use (#4676): the Homebrew tap's formula, the Tauri updater's
|
|
4
|
+
* rolling release, and an index repository's manifests, fork and pull
|
|
5
|
+
* request (#5158). Requests go through the injectable `fetch`, with the token
|
|
5
6
|
* as a bearer, and every failure is redacted before it is thrown.
|
|
6
7
|
*/
|
|
7
8
|
import type { Credential } from "./publish-credentials.js";
|
|
@@ -37,12 +38,40 @@ export declare class GitHubRepo {
|
|
|
37
38
|
bytes: Buffer;
|
|
38
39
|
sha: string;
|
|
39
40
|
} | null>;
|
|
41
|
+
/** The commits of `branch` that touch `path`, newest first, up to 100 (#5163). */
|
|
42
|
+
commitsTouching(path: string, branch: string): Promise<string[]>;
|
|
40
43
|
/** Commit `bytes` as `path` on `branch`, replacing the blob `sha` when the file is there. Returns the commit. */
|
|
41
44
|
putFile(path: string, branch: string, bytes: Uint8Array, message: string, sha: string | null): Promise<string>;
|
|
42
45
|
/** Make `refs/heads/<branch>` at `sha`. */
|
|
43
46
|
createBranch(branch: string, sha: string): Promise<void>;
|
|
44
47
|
/** Move `refs/<ref>` to `sha`. Without `force`, a move that is not a fast-forward answers false. */
|
|
45
48
|
moveRef(ref: string, sha: string, force: boolean): Promise<boolean>;
|
|
49
|
+
/** True when the token sees the repository. */
|
|
50
|
+
exists(): Promise<boolean>;
|
|
51
|
+
/** The commit a submodule at `path` points to at `ref`, or null when `path` is not a submodule there (#5158). */
|
|
52
|
+
submodule(path: string, ref: string): Promise<string | null>;
|
|
53
|
+
/**
|
|
54
|
+
* A commit on `parent` that writes each file, points each submodule
|
|
55
|
+
* path at its commit and removes each `remove` path (#5163), made with
|
|
56
|
+
* the git data API (#5158): one commit
|
|
57
|
+
* whatever the number of files. No branch moves.
|
|
58
|
+
*/
|
|
59
|
+
commitTree(parent: string, changes: ReadonlyArray<{
|
|
60
|
+
path: string;
|
|
61
|
+
bytes: Uint8Array;
|
|
62
|
+
} | {
|
|
63
|
+
path: string;
|
|
64
|
+
gitlink: string;
|
|
65
|
+
} | {
|
|
66
|
+
path: string;
|
|
67
|
+
remove: true;
|
|
68
|
+
}>, message: string): Promise<string>;
|
|
69
|
+
/** Ask for the token's user's fork of this repository (#5158). GitHub answers with the fork it has, or makes one; it may take a moment to appear. Returns its `owner/name`. */
|
|
70
|
+
fork(): Promise<string>;
|
|
71
|
+
/** The pull request from `head` (`owner:branch`) in any state, newest first, or null (#5158). */
|
|
72
|
+
findPull(head: string): Promise<GitHubPull | null>;
|
|
73
|
+
/** Open a pull request from `head` (`owner:branch`) into `base`. */
|
|
74
|
+
openPull(title: string, body: string, head: string, base: string): Promise<GitHubPull>;
|
|
46
75
|
/** The published release for `tag`, or null. A draft is not found here. */
|
|
47
76
|
publishedRelease(tag: string): Promise<GitHubRelease | null>;
|
|
48
77
|
/** The draft release for `tag` named `name`, or null. */
|
|
@@ -58,6 +87,13 @@ export declare class GitHubRepo {
|
|
|
58
87
|
/** Delete `refs/<ref>`. One that is not there is already gone. */
|
|
59
88
|
deleteRef(ref: string): Promise<void>;
|
|
60
89
|
}
|
|
90
|
+
/** A pull request as the index target reads it (#5158). */
|
|
91
|
+
export interface GitHubPull {
|
|
92
|
+
number: number;
|
|
93
|
+
url: string;
|
|
94
|
+
state: "open" | "closed";
|
|
95
|
+
merged: boolean;
|
|
96
|
+
}
|
|
61
97
|
/** A GitHub release as the targets read it. */
|
|
62
98
|
export interface GitHubRelease {
|
|
63
99
|
id: string;
|
|
@@ -65,4 +101,6 @@ export interface GitHubRelease {
|
|
|
65
101
|
/** Asset names, with the digest GitHub reports. */
|
|
66
102
|
assets: Map<string, string | null>;
|
|
67
103
|
uploadUrl?: string;
|
|
104
|
+
/** The release's name, when GitHub gives one. */
|
|
105
|
+
name?: string;
|
|
68
106
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The GitHub REST calls the targets that write to a repository other than the
|
|
3
|
-
* release's use (#4676): the Homebrew tap's formula,
|
|
4
|
-
* rolling release
|
|
3
|
+
* release's use (#4676): the Homebrew tap's formula, the Tauri updater's
|
|
4
|
+
* rolling release, and an index repository's manifests, fork and pull
|
|
5
|
+
* request (#5158). Requests go through the injectable `fetch`, with the token
|
|
5
6
|
* as a bearer, and every failure is redacted before it is thrown.
|
|
6
7
|
*/
|
|
7
8
|
import { PublishTargetError } from "./release-publish.js";
|
|
@@ -74,6 +75,13 @@ export class GitHubRepo {
|
|
|
74
75
|
this.fail(`reading ${path} at ${ref}`, res);
|
|
75
76
|
return { bytes: body.encoding === "base64" ? Buffer.from(body.content, "base64") : Buffer.from(body.content), sha: body.sha };
|
|
76
77
|
}
|
|
78
|
+
/** The commits of `branch` that touch `path`, newest first, up to 100 (#5163). */
|
|
79
|
+
async commitsTouching(path, branch) {
|
|
80
|
+
const res = await this.call("GET", `/commits?path=${encodeURIComponent(path)}&sha=${encodeURIComponent(branch)}&per_page=100`);
|
|
81
|
+
if (res.status !== 200 || !Array.isArray(res.json))
|
|
82
|
+
this.fail(`listing the commits of ${branch} that touch ${path}`, res);
|
|
83
|
+
return res.json.map((c) => c.sha).filter((c) => typeof c === "string");
|
|
84
|
+
}
|
|
77
85
|
/** Commit `bytes` as `path` on `branch`, replacing the blob `sha` when the file is there. Returns the commit. */
|
|
78
86
|
async putFile(path, branch, bytes, message, sha) {
|
|
79
87
|
const res = await this.call("PUT", `/contents/${path.split("/").map(encodeURIComponent).join("/")}`, JSON.stringify({ message, content: Buffer.from(bytes).toString("base64"), branch, ...(sha ? { sha } : {}) }));
|
|
@@ -97,6 +105,87 @@ export class GitHubRepo {
|
|
|
97
105
|
return false;
|
|
98
106
|
this.fail(`moving ${ref} to ${sha.slice(0, 12)}`, res);
|
|
99
107
|
}
|
|
108
|
+
/** True when the token sees the repository. */
|
|
109
|
+
async exists() {
|
|
110
|
+
const res = await this.call("GET", "");
|
|
111
|
+
if (res.status === 404)
|
|
112
|
+
return false;
|
|
113
|
+
if (res.status !== 200)
|
|
114
|
+
this.fail("reading the repository", res);
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
/** The commit a submodule at `path` points to at `ref`, or null when `path` is not a submodule there (#5158). */
|
|
118
|
+
async submodule(path, ref) {
|
|
119
|
+
const res = await this.call("GET", `/contents/${path.split("/").map(encodeURIComponent).join("/")}?ref=${encodeURIComponent(ref)}`);
|
|
120
|
+
if (res.status === 404)
|
|
121
|
+
return null;
|
|
122
|
+
const body = res.json;
|
|
123
|
+
if (res.status !== 200)
|
|
124
|
+
this.fail(`reading ${path} at ${ref}`, res);
|
|
125
|
+
return body?.type === "submodule" && typeof body.sha === "string" ? body.sha : null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* A commit on `parent` that writes each file, points each submodule
|
|
129
|
+
* path at its commit and removes each `remove` path (#5163), made with
|
|
130
|
+
* the git data API (#5158): one commit
|
|
131
|
+
* whatever the number of files. No branch moves.
|
|
132
|
+
*/
|
|
133
|
+
async commitTree(parent, changes, message) {
|
|
134
|
+
const base = await this.call("GET", `/git/commits/${parent}`);
|
|
135
|
+
const tree = base.json?.tree?.sha;
|
|
136
|
+
if (base.status !== 200 || typeof tree !== "string")
|
|
137
|
+
this.fail(`reading commit ${parent.slice(0, 12)}`, base);
|
|
138
|
+
const entries = [];
|
|
139
|
+
for (const c of changes) {
|
|
140
|
+
if ("remove" in c) {
|
|
141
|
+
// #5163: a null sha takes the path out of the tree.
|
|
142
|
+
entries.push({ path: c.path, mode: "100644", type: "blob", sha: null });
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if ("gitlink" in c) {
|
|
146
|
+
entries.push({ path: c.path, mode: "160000", type: "commit", sha: c.gitlink });
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const blob = await this.call("POST", "/git/blobs", JSON.stringify({ content: Buffer.from(c.bytes).toString("base64"), encoding: "base64" }));
|
|
150
|
+
const sha = blob.json?.sha;
|
|
151
|
+
if (blob.status !== 201 || typeof sha !== "string")
|
|
152
|
+
this.fail(`writing ${c.path}`, blob);
|
|
153
|
+
entries.push({ path: c.path, mode: "100644", type: "blob", sha });
|
|
154
|
+
}
|
|
155
|
+
const made = await this.call("POST", "/git/trees", JSON.stringify({ base_tree: tree, tree: entries }));
|
|
156
|
+
const madeSha = made.json?.sha;
|
|
157
|
+
if (made.status !== 201 || typeof madeSha !== "string")
|
|
158
|
+
this.fail("writing the tree", made);
|
|
159
|
+
const commit = await this.call("POST", "/git/commits", JSON.stringify({ message, tree: madeSha, parents: [parent] }));
|
|
160
|
+
const commitSha = commit.json?.sha;
|
|
161
|
+
if (commit.status !== 201 || typeof commitSha !== "string")
|
|
162
|
+
this.fail("committing", commit);
|
|
163
|
+
return commitSha;
|
|
164
|
+
}
|
|
165
|
+
/** Ask for the token's user's fork of this repository (#5158). GitHub answers with the fork it has, or makes one; it may take a moment to appear. Returns its `owner/name`. */
|
|
166
|
+
async fork() {
|
|
167
|
+
const res = await this.call("POST", "/forks", JSON.stringify({ default_branch_only: true }));
|
|
168
|
+
const name = res.json?.full_name;
|
|
169
|
+
if ((res.status !== 202 && res.status !== 200) || typeof name !== "string")
|
|
170
|
+
this.fail("forking", res);
|
|
171
|
+
return name;
|
|
172
|
+
}
|
|
173
|
+
/** The pull request from `head` (`owner:branch`) in any state, newest first, or null (#5158). */
|
|
174
|
+
async findPull(head) {
|
|
175
|
+
const res = await this.call("GET", `/pulls?state=all&per_page=100&head=${encodeURIComponent(head)}`);
|
|
176
|
+
if (res.status !== 200)
|
|
177
|
+
this.fail(`listing pull requests from ${head}`, res);
|
|
178
|
+
const list = Array.isArray(res.json) ? res.json : [];
|
|
179
|
+
const found = list.find((p) => p.head?.label === head) ?? null;
|
|
180
|
+
return found ? toPull(found) : null;
|
|
181
|
+
}
|
|
182
|
+
/** Open a pull request from `head` (`owner:branch`) into `base`. */
|
|
183
|
+
async openPull(title, body, head, base) {
|
|
184
|
+
const res = await this.call("POST", "/pulls", JSON.stringify({ title, body, head, base, maintainer_can_modify: true }));
|
|
185
|
+
if (res.status !== 201 || !res.json)
|
|
186
|
+
this.fail(`opening a pull request from ${head} into ${base}`, res);
|
|
187
|
+
return toPull(res.json);
|
|
188
|
+
}
|
|
100
189
|
/** The published release for `tag`, or null. A draft is not found here. */
|
|
101
190
|
async publishedRelease(tag) {
|
|
102
191
|
const res = await this.call("GET", `/releases/tags/${encodeURIComponent(tag)}`);
|
|
@@ -145,9 +234,17 @@ export class GitHubRepo {
|
|
|
145
234
|
this.fail(`deleting ${ref}`, res);
|
|
146
235
|
}
|
|
147
236
|
}
|
|
237
|
+
function toPull(body) {
|
|
238
|
+
return {
|
|
239
|
+
number: Number(body.number),
|
|
240
|
+
url: typeof body.html_url === "string" ? body.html_url : `#${String(body.number)}`,
|
|
241
|
+
state: body.state === "open" ? "open" : "closed",
|
|
242
|
+
merged: typeof body.merged_at === "string" && body.merged_at.length > 0,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
148
245
|
function toRelease(body) {
|
|
149
246
|
const assets = new Map();
|
|
150
247
|
for (const a of body.assets ?? [])
|
|
151
248
|
assets.set(a.name, typeof a.digest === "string" ? a.digest : null);
|
|
152
|
-
return { id: String(body.id), draft: body.draft === true, assets, ...(typeof body.upload_url === "string" ? { uploadUrl: body.upload_url } : {}) };
|
|
249
|
+
return { id: String(body.id), draft: body.draft === true, assets, ...(typeof body.upload_url === "string" ? { uploadUrl: body.upload_url } : {}), ...(typeof body.name === "string" ? { name: body.name } : {}) };
|
|
153
250
|
}
|
|
@@ -46,24 +46,22 @@
|
|
|
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
55
|
import type { HomebrewPublishDeclaration } from "./publish-declaration.js";
|
|
56
|
+
import { fillUrl, releaseVersion } from "./publish-index.js";
|
|
51
57
|
import { type PublishDeps, type PublishTarget } from "./release-publish.js";
|
|
58
|
+
export { fillUrl, releaseVersion };
|
|
52
59
|
/** The first chant that publishes a `homebrew` target (#4676). */
|
|
53
60
|
export declare const PUBLISH_HOMEBREW_FLOOR = "0.124.63";
|
|
54
61
|
/** The first chant that reads a homebrew target's `sshKeyEnv` (#4699). */
|
|
55
62
|
export declare const PUBLISH_HOMEBREW_SSH_KEY_FLOOR = "0.124.64";
|
|
56
63
|
/** The variable the tap token is read from when the declaration names none. */
|
|
57
64
|
export declare const HOMEBREW_TOKEN_ENV = "HOMEBREW_TAP_TOKEN";
|
|
58
|
-
/** A release's version for a package manager: its label from the first digit on, or null when the label has no digit. */
|
|
59
|
-
export declare function releaseVersion(label: string | null): string | null;
|
|
60
|
-
/** `pattern` with `{tag}`, `{label}`, `{version}` and `{name}` filled in, each URL-encoded except the tag's slashes. */
|
|
61
|
-
export declare function fillUrl(pattern: string, values: {
|
|
62
|
-
tag: string;
|
|
63
|
-
label: string;
|
|
64
|
-
version: string;
|
|
65
|
-
name: string;
|
|
66
|
-
}): string;
|
|
67
65
|
/** Render a formula template, or name what it can't fill. */
|
|
68
66
|
export declare function renderFormula(template: string, values: {
|
|
69
67
|
version: string;
|
|
@@ -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
|
}
|