Skip to content

Commit ae992b9

Browse files
committed
fix(upgrade): check GHCR for nightly version existence instead of GitHub Releases
Fixes CLI-B5 When a user pins a specific nightly version (e.g. `sentry cli upgrade 0.14.0-dev.1772661724`), the `versionExists()` function was checking GitHub Releases (which only has stable releases). Nightly builds are published to GHCR with tags like `nightly-0.14.0-dev.1772661724`. The fix routes nightly version checks to GHCR via `fetchManifest()` instead of GitHub Releases, so pinned nightly upgrades no longer fail with a false "Version X not found" error.
1 parent 0da9cc9 commit ae992b9

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/lib/upgrade.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { attemptDeltaUpgrade, type DeltaResult } from "./delta-upgrade.js";
3131
import { AbortError, UpgradeError } from "./errors.js";
3232
import {
3333
downloadNightlyBlob,
34+
fetchManifest,
3435
fetchNightlyManifest,
3536
findLayerByFilename,
3637
getAnonymousToken,
@@ -384,9 +385,31 @@ export function fetchLatestVersion(
384385
: fetchLatestFromNpm();
385386
}
386387

388+
/**
389+
* Check if a versioned nightly tag exists in GHCR.
390+
*
391+
* Nightly builds are published to GHCR with tags like `nightly-0.14.0-dev.1772661724`.
392+
* This performs an anonymous token exchange + manifest HEAD check (2 HTTP requests).
393+
*
394+
* @param version - Nightly version string (e.g., "0.14.0-dev.1772661724")
395+
* @returns true if the nightly tag exists in GHCR
396+
*/
397+
async function nightlyVersionExists(version: string): Promise<boolean> {
398+
try {
399+
const token = await getAnonymousToken();
400+
await fetchManifest(token, `nightly-${version}`);
401+
return true;
402+
} catch {
403+
return false;
404+
}
405+
}
406+
387407
/**
388408
* Check if a specific version exists in the appropriate registry.
389-
* curl installations check GitHub releases; package managers check npm.
409+
*
410+
* Nightly versions are checked against GHCR (where they are published as
411+
* versioned tags like `nightly-0.14.0-dev.1772661724`). Stable versions
412+
* are checked against GitHub Releases (curl/brew) or npm (package managers).
390413
*
391414
* @param method - How the CLI was installed
392415
* @param version - Version to check (without 'v' prefix)
@@ -397,6 +420,11 @@ export async function versionExists(
397420
method: InstallationMethod,
398421
version: string
399422
): Promise<boolean> {
423+
// Nightly versions are published to GHCR, not GitHub Releases or npm
424+
if (isNightlyVersion(version)) {
425+
return nightlyVersionExists(version);
426+
}
427+
400428
if (method === "curl" || method === "brew") {
401429
const response = await fetchWithUpgradeError(
402430
`${GITHUB_RELEASES_URL}/tags/${version}`,

0 commit comments

Comments
 (0)