Skip to content

Commit

Permalink
Cannot reuse IGoVersionInfo from dist for manifest
Browse files Browse the repository at this point in the history
...and vice versa.

While here, also free versionInfo and versionSpec so we don't
(un)intentionally overwrite them somewhere down below.
  • Loading branch information
bdd committed Sep 16, 2020
1 parent 9333ae6 commit 98cb48b
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export async function getGo(

if (versionInfo && versionInfo.resolvedVersion.length > 0) {
versionSpec = versionInfo.resolvedVersion;

// Freeze these to protect (un)intentional overwrites.
Object.freeze(versionInfo);
Object.freeze(versionSpec);
}

// check cache
Expand All @@ -71,8 +75,18 @@ export async function getGo(
// Try download from internal distribution (popular versions only)
//
try {
info =
versionInfo ?? (await getInfoFromManifest(versionSpec, stable, auth));
if (versionInfo?.type == 'manifest') {
info = versionInfo;
} else {
// The version search in the cache was a miss. We either have no previous
// explicit version resolution attempt or it came from 'dist' version registry
// and have an `downloadUrl` pointing to an external resource.
//
// Check the @actions/go-versions manifest with current `versionSpec`; either
// an explicit one or a semver range.
info = await getInfoFromManifest(versionSpec, stable, auth);
}

if (info) {
downloadPath = await installGoVersion(info, auth);
} else {
Expand All @@ -99,7 +113,15 @@ export async function getGo(
// Download from storage.googleapis.com
//
if (!downloadPath) {
info = versionInfo ?? (await getInfoFromDist(versionSpec, stable));
if (versionInfo?.type == 'dist') {
info = versionInfo;
} else {
// Version search didn't match anything available in the cache or @actions/go-versions.
// We either have no previous explicit version resolution attempt or downloading from
// @actions/go-versions manifest specified URL somehow failed.
info = await getInfoFromDist(versionSpec, stable);
}

if (!info) {
let osPlat: string = os.platform();
let osArch: string = os.arch();
Expand Down

0 comments on commit 98cb48b

Please sign in to comment.