Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pkgs/desktop-commander/worker/promote.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ const created = cfJson([
"--worker", config.worker,
"--strategy", "percentage",
"--versions", JSON.stringify([{ version_id: manifest.versionId, percentage: 100 }]),
"--message", `promote ${manifest.tag} (${manifest.sha})`,
]);
const deploymentId = created?.id ?? created?.deployment_id;
console.log(`promoted ${config.worker} version ${manifest.versionId} (tag ${manifest.tag}) to 100%${deploymentId ? `; deployment ${deploymentId}` : ""}`);
Expand Down
14 changes: 10 additions & 4 deletions pkgs/desktop-commander/worker/upload-version.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,20 @@ if (dryRun) {
process.stdout.write(output);
console.log(`dry run: ${config.worker} version is valid; nothing uploaded`);
} else {
const version = unwrapJson(output);
// cf's versions-create stdout is a human panel in this build, not
// JSON — resolve the uploaded version by its unique tag instead of
// parsing that output. Exactly one version may carry the tag.
const listed = cfJson(["workers", "versions", "list", "--worker-id", config.worker, "--per-page", "50"]);
const allVersions = Array.isArray(listed) ? listed : listed?.versions ?? listed?.items ?? [];
const matches = allVersions.filter((v) => v.annotations?.["workers/tag"] === tag);
if (matches.length !== 1) {
throw new Error(`expected exactly one uploaded version with tag ${tag}, found ${matches.length}; refusing to emit provenance`);
}
const version = matches[0];
const versionId = version.id ?? version.version_id;
if (typeof versionId !== "string" || !versionId) {
throw new Error("cf did not return the uploaded version ID; refusing to emit provenance");
}
if (version.annotations?.["workers/tag"] && version.annotations["workers/tag"] !== tag) {
throw new Error("cf returned an uploaded version with an unexpected tag");
}
if (baselineDeployment) {
const deployment = firstDeployment(cfJson(["workers", "deployments", "list", "--worker", config.worker, "--per-page", "1"]));
if (deployment?.id !== baselineDeployment.id || deployment?.versions?.[0]?.version_id !== baselineDeployment.versions[0].version_id) {
Expand Down