Skip to content
Merged
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
12 changes: 11 additions & 1 deletion pkgs/pkarr-worker/deploy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ if (dryRun) {
process.exit(0);
}

const version = listVersions().find((v) => v.annotations?.["workers/tag"] === tag);
// Re-deploying an unchanged tree uploads a second version under the
// same tag (uploads are not deduplicated), so pick the newest match.
const version = listVersions()
.filter((v) => v.annotations?.["workers/tag"] === tag)
.sort((a, b) => createdOn(b) - createdOn(a))[0];
if (!version) {
throw new Error(`uploaded version with tag ${tag} not found in versions list`);
}
Expand Down Expand Up @@ -111,6 +115,12 @@ async function assertDeployable(versionId) {
}
}

function createdOn(version) {
const raw = version.metadata?.created_on ?? version.created_on ?? version.createdOn ?? 0;
const parsed = typeof raw === "number" ? raw : Date.parse(raw);
return Number.isFinite(parsed) ? parsed : 0;
}

function listVersions() {
const out = runCf(["workers", "versions", "list", "--worker-id", WORKER], { capture: true });
const parsed = parseJsonOutput(out);
Expand Down