mirror of
https://github.com/actions/setup-go.git
synced 2025-04-23 17:40:50 +00:00
Add support for arm32 go arch
This commit is contained in:
parent
f279813975
commit
2c62681dc9
4 changed files with 107 additions and 44 deletions
|
@ -7,6 +7,7 @@ import osm from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import * as main from '../src/main';
|
import * as main from '../src/main';
|
||||||
import * as im from '../src/installer';
|
import * as im from '../src/installer';
|
||||||
|
import * as sys from '../src/system';
|
||||||
|
|
||||||
let goJsonData = require('./data/golang-dl.json');
|
let goJsonData = require('./data/golang-dl.json');
|
||||||
let matchers = require('../matchers.json');
|
let matchers = require('../matchers.json');
|
||||||
|
@ -41,6 +42,7 @@ describe('setup-go', () => {
|
||||||
let mkdirpSpy: jest.SpyInstance;
|
let mkdirpSpy: jest.SpyInstance;
|
||||||
let execSpy: jest.SpyInstance;
|
let execSpy: jest.SpyInstance;
|
||||||
let getManifestSpy: jest.SpyInstance;
|
let getManifestSpy: jest.SpyInstance;
|
||||||
|
let sysGetArchSpy: jest.SpyInstance;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
process.env['GITHUB_ENV'] = ''; // Stub out Environment file functionality so we can verify it writes to standard out (toolkit is backwards compatible)
|
process.env['GITHUB_ENV'] = ''; // Stub out Environment file functionality so we can verify it writes to standard out (toolkit is backwards compatible)
|
||||||
|
@ -64,6 +66,7 @@ describe('setup-go', () => {
|
||||||
archSpy = jest.spyOn(osm, 'arch');
|
archSpy = jest.spyOn(osm, 'arch');
|
||||||
archSpy.mockImplementation(() => os['arch']);
|
archSpy.mockImplementation(() => os['arch']);
|
||||||
execSpy = jest.spyOn(cp, 'execSync');
|
execSpy = jest.spyOn(cp, 'execSync');
|
||||||
|
sysGetArchSpy = jest.spyOn(sys, 'getArch');
|
||||||
|
|
||||||
// switch path join behaviour based on set os.platform
|
// switch path join behaviour based on set os.platform
|
||||||
joinSpy = jest.spyOn(path, 'join');
|
joinSpy = jest.spyOn(path, 'join');
|
||||||
|
@ -129,7 +132,7 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
it('can find 1.9.7 from manifest on osx', async () => {
|
it('can find 1.9.7 from manifest on osx', async () => {
|
||||||
os.platform = 'darwin';
|
os.platform = 'darwin';
|
||||||
os.arch = 'x64';
|
sysGetArchSpy.mockImplementationOnce(() => 'x64');
|
||||||
|
|
||||||
let match = await im.getInfoFromManifest('1.9.7', true, 'mocktoken');
|
let match = await im.getInfoFromManifest('1.9.7', true, 'mocktoken');
|
||||||
expect(match).toBeDefined();
|
expect(match).toBeDefined();
|
||||||
|
@ -142,7 +145,7 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
it('can find 1.9 from manifest on linux', async () => {
|
it('can find 1.9 from manifest on linux', async () => {
|
||||||
os.platform = 'linux';
|
os.platform = 'linux';
|
||||||
os.arch = 'x64';
|
sysGetArchSpy.mockImplementationOnce(() => 'x64');
|
||||||
|
|
||||||
let match = await im.getInfoFromManifest('1.9.7', true, 'mocktoken');
|
let match = await im.getInfoFromManifest('1.9.7', true, 'mocktoken');
|
||||||
expect(match).toBeDefined();
|
expect(match).toBeDefined();
|
||||||
|
@ -155,7 +158,7 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
it('can find 1.9 from manifest on windows', async () => {
|
it('can find 1.9 from manifest on windows', async () => {
|
||||||
os.platform = 'win32';
|
os.platform = 'win32';
|
||||||
os.arch = 'x64';
|
sysGetArchSpy.mockImplementationOnce(() => 'x64');
|
||||||
|
|
||||||
let match = await im.getInfoFromManifest('1.9.7', true, 'mocktoken');
|
let match = await im.getInfoFromManifest('1.9.7', true, 'mocktoken');
|
||||||
expect(match).toBeDefined();
|
expect(match).toBeDefined();
|
||||||
|
@ -367,7 +370,7 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
it('does not find a version that does not exist', async () => {
|
it('does not find a version that does not exist', async () => {
|
||||||
os.platform = 'linux';
|
os.platform = 'linux';
|
||||||
os.arch = 'x64';
|
sysGetArchSpy.mockImplementationOnce(() => 'x64');
|
||||||
|
|
||||||
inputs['go-version'] = '9.99.9';
|
inputs['go-version'] = '9.99.9';
|
||||||
|
|
||||||
|
@ -381,7 +384,7 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
it('downloads a version from a manifest match', async () => {
|
it('downloads a version from a manifest match', async () => {
|
||||||
os.platform = 'linux';
|
os.platform = 'linux';
|
||||||
os.arch = 'x64';
|
sysGetArchSpy.mockImplementationOnce(() => 'x64');
|
||||||
|
|
||||||
let versionSpec = '1.12.16';
|
let versionSpec = '1.12.16';
|
||||||
|
|
||||||
|
@ -418,7 +421,7 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
it('downloads a major and minor from a manifest match', async () => {
|
it('downloads a major and minor from a manifest match', async () => {
|
||||||
os.platform = 'linux';
|
os.platform = 'linux';
|
||||||
os.arch = 'x64';
|
sysGetArchSpy.mockImplementationOnce(() => 'x64');
|
||||||
|
|
||||||
let versionSpec = '1.12';
|
let versionSpec = '1.12';
|
||||||
|
|
||||||
|
@ -453,7 +456,7 @@ describe('setup-go', () => {
|
||||||
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('falls back to a version from node dist', async () => {
|
it('falls back to a version from go dist', async () => {
|
||||||
os.platform = 'linux';
|
os.platform = 'linux';
|
||||||
os.arch = 'x64';
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
@ -694,7 +697,7 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
it('check latest version and install it from manifest', async () => {
|
it('check latest version and install it from manifest', async () => {
|
||||||
os.platform = 'linux';
|
os.platform = 'linux';
|
||||||
os.arch = 'x64';
|
sysGetArchSpy.mockImplementationOnce(() => 'x64');
|
||||||
|
|
||||||
const versionSpec = '1.17';
|
const versionSpec = '1.17';
|
||||||
const patchVersion = '1.17.6';
|
const patchVersion = '1.17.6';
|
||||||
|
@ -879,5 +882,40 @@ exclude example.com/thismodule v1.3.0
|
||||||
`::error::The specified go version file at: go.mod does not exist${osm.EOL}`
|
`::error::The specified go version file at: go.mod does not exist${osm.EOL}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('acquires specified architecture of go', async () => {
|
||||||
|
for (const {arch, version, osSpec} of [
|
||||||
|
{arch: 'amd64', version: '1.13.7', osSpec: 'linux'},
|
||||||
|
{arch: 'armv6l', version: '1.12.2', osSpec: 'linux'}
|
||||||
|
]) {
|
||||||
|
os.platform = osSpec;
|
||||||
|
os.arch = arch;
|
||||||
|
|
||||||
|
const fileExtension = os.platform === 'win32' ? 'zip' : 'tar.gz';
|
||||||
|
|
||||||
|
const platform = os.platform === 'win32' ? 'win' : os.platform;
|
||||||
|
|
||||||
|
inputs['go-version'] = version;
|
||||||
|
inputs['architecture'] = arch;
|
||||||
|
|
||||||
|
let expectedUrl =
|
||||||
|
platform === 'win32'
|
||||||
|
? `https://github.com/actions/go-versions/releases/download/${version}/go-${version}-${platform}-${arch}.${fileExtension}`
|
||||||
|
: `https://storage.googleapis.com/golang/go${version}.${osSpec}-${arch}.${fileExtension}`;
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
let toolPath = path.normalize(`/cache/go/${version}/${arch}`);
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Acquiring go${version} from ${expectedUrl}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, 100000);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,6 +17,8 @@ inputs:
|
||||||
default: false
|
default: false
|
||||||
cache-dependency-path:
|
cache-dependency-path:
|
||||||
description: 'Used to specify the path to a dependency file - go.sum'
|
description: 'Used to specify the path to a dependency file - go.sum'
|
||||||
|
architecture:
|
||||||
|
description: 'Target architecture for Go to use. Examples: x86, x64. Will use system architecture by default.'
|
||||||
outputs:
|
outputs:
|
||||||
go-version:
|
go-version:
|
||||||
description: 'The installed Go version. Useful when given a version range as input.'
|
description: 'The installed Go version. Useful when given a version range as input.'
|
||||||
|
|
43
dist/setup/index.js
vendored
43
dist/setup/index.js
vendored
|
@ -62858,13 +62858,12 @@ const httpm = __importStar(__nccwpck_require__(6255));
|
||||||
const sys = __importStar(__nccwpck_require__(4300));
|
const sys = __importStar(__nccwpck_require__(4300));
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||||
const os_1 = __importDefault(__nccwpck_require__(2037));
|
const os_1 = __importDefault(__nccwpck_require__(2037));
|
||||||
function getGo(versionSpec, checkLatest, auth) {
|
function getGo(versionSpec, checkLatest, auth, arch = sys.getArch()) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let osPlat = os_1.default.platform();
|
let osPlat = os_1.default.platform();
|
||||||
let osArch = os_1.default.arch();
|
|
||||||
if (checkLatest) {
|
if (checkLatest) {
|
||||||
core.info('Attempting to resolve the latest version from the manifest...');
|
core.info('Attempting to resolve the latest version from the manifest...');
|
||||||
const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth);
|
const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth, arch);
|
||||||
if (resolvedVersion) {
|
if (resolvedVersion) {
|
||||||
versionSpec = resolvedVersion;
|
versionSpec = resolvedVersion;
|
||||||
core.info(`Resolved as '${versionSpec}'`);
|
core.info(`Resolved as '${versionSpec}'`);
|
||||||
|
@ -62888,9 +62887,9 @@ function getGo(versionSpec, checkLatest, auth) {
|
||||||
// Try download from internal distribution (popular versions only)
|
// Try download from internal distribution (popular versions only)
|
||||||
//
|
//
|
||||||
try {
|
try {
|
||||||
info = yield getInfoFromManifest(versionSpec, true, auth);
|
info = yield getInfoFromManifest(versionSpec, true, auth, arch);
|
||||||
if (info) {
|
if (info) {
|
||||||
downloadPath = yield installGoVersion(info, auth);
|
downloadPath = yield installGoVersion(info, auth, arch);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info('Not found in manifest. Falling back to download directly from Go');
|
core.info('Not found in manifest. Falling back to download directly from Go');
|
||||||
|
@ -62911,13 +62910,13 @@ function getGo(versionSpec, checkLatest, auth) {
|
||||||
// Download from storage.googleapis.com
|
// Download from storage.googleapis.com
|
||||||
//
|
//
|
||||||
if (!downloadPath) {
|
if (!downloadPath) {
|
||||||
info = yield getInfoFromDist(versionSpec);
|
info = yield getInfoFromDist(versionSpec, arch);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
|
throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.`);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
core.info('Install from dist');
|
core.info('Install from dist');
|
||||||
downloadPath = yield installGoVersion(info, undefined);
|
downloadPath = yield installGoVersion(info, undefined, arch);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
throw new Error(`Failed to download version ${versionSpec}: ${err}`);
|
throw new Error(`Failed to download version ${versionSpec}: ${err}`);
|
||||||
|
@ -62927,10 +62926,10 @@ function getGo(versionSpec, checkLatest, auth) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getGo = getGo;
|
exports.getGo = getGo;
|
||||||
function resolveVersionFromManifest(versionSpec, stable, auth) {
|
function resolveVersionFromManifest(versionSpec, stable, auth, arch) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const info = yield getInfoFromManifest(versionSpec, stable, auth);
|
const info = yield getInfoFromManifest(versionSpec, stable, auth, arch);
|
||||||
return info === null || info === void 0 ? void 0 : info.resolvedVersion;
|
return info === null || info === void 0 ? void 0 : info.resolvedVersion;
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
@ -62939,7 +62938,7 @@ function resolveVersionFromManifest(versionSpec, stable, auth) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function installGoVersion(info, auth) {
|
function installGoVersion(info, auth, arch) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
|
core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
|
||||||
// Windows requires that we keep the extension (.zip) for extraction
|
// Windows requires that we keep the extension (.zip) for extraction
|
||||||
|
@ -62954,7 +62953,7 @@ function installGoVersion(info, auth) {
|
||||||
extPath = path.join(extPath, 'go');
|
extPath = path.join(extPath, 'go');
|
||||||
}
|
}
|
||||||
core.info('Adding to the cache ...');
|
core.info('Adding to the cache ...');
|
||||||
const cachedDir = yield tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion));
|
const cachedDir = yield tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion), arch);
|
||||||
core.info(`Successfully cached go to ${cachedDir}`);
|
core.info(`Successfully cached go to ${cachedDir}`);
|
||||||
return cachedDir;
|
return cachedDir;
|
||||||
});
|
});
|
||||||
|
@ -62973,12 +62972,12 @@ function extractGoArchive(archivePath) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.extractGoArchive = extractGoArchive;
|
exports.extractGoArchive = extractGoArchive;
|
||||||
function getInfoFromManifest(versionSpec, stable, auth) {
|
function getInfoFromManifest(versionSpec, stable, auth, arch = sys.getArch()) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let info = null;
|
let info = null;
|
||||||
const releases = yield tc.getManifestFromRepo('actions', 'go-versions', auth, 'main');
|
const releases = yield tc.getManifestFromRepo('actions', 'go-versions', auth, 'main');
|
||||||
core.info(`matching ${versionSpec}...`);
|
core.info(`matching ${versionSpec}...`);
|
||||||
const rel = yield tc.findFromManifest(versionSpec, stable, releases);
|
const rel = yield tc.findFromManifest(versionSpec, stable, releases, arch);
|
||||||
if (rel && rel.files.length > 0) {
|
if (rel && rel.files.length > 0) {
|
||||||
info = {};
|
info = {};
|
||||||
info.type = 'manifest';
|
info.type = 'manifest';
|
||||||
|
@ -62990,10 +62989,10 @@ function getInfoFromManifest(versionSpec, stable, auth) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getInfoFromManifest = getInfoFromManifest;
|
exports.getInfoFromManifest = getInfoFromManifest;
|
||||||
function getInfoFromDist(versionSpec) {
|
function getInfoFromDist(versionSpec, arch) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let version;
|
let version;
|
||||||
version = yield findMatch(versionSpec);
|
version = yield findMatch(versionSpec, arch);
|
||||||
if (!version) {
|
if (!version) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -63006,9 +63005,9 @@ function getInfoFromDist(versionSpec) {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function findMatch(versionSpec) {
|
function findMatch(versionSpec, arch = sys.getArch()) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let archFilter = sys.getArch();
|
let archFilter = translateArchToDistUrl(arch);
|
||||||
let platFilter = sys.getPlatform();
|
let platFilter = sys.getPlatform();
|
||||||
let result;
|
let result;
|
||||||
let match;
|
let match;
|
||||||
|
@ -63088,6 +63087,14 @@ function parseGoVersionFile(versionFilePath) {
|
||||||
return contents.trim();
|
return contents.trim();
|
||||||
}
|
}
|
||||||
exports.parseGoVersionFile = parseGoVersionFile;
|
exports.parseGoVersionFile = parseGoVersionFile;
|
||||||
|
function translateArchToDistUrl(arch) {
|
||||||
|
switch (arch) {
|
||||||
|
case 'arm':
|
||||||
|
return 'armv6l';
|
||||||
|
default:
|
||||||
|
return arch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
|
@ -32,17 +32,18 @@ export interface IGoVersionInfo {
|
||||||
export async function getGo(
|
export async function getGo(
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
checkLatest: boolean,
|
checkLatest: boolean,
|
||||||
auth: string | undefined
|
auth: string | undefined,
|
||||||
|
arch = sys.getArch()
|
||||||
) {
|
) {
|
||||||
let osPlat: string = os.platform();
|
let osPlat: string = os.platform();
|
||||||
let osArch: string = os.arch();
|
|
||||||
|
|
||||||
if (checkLatest) {
|
if (checkLatest) {
|
||||||
core.info('Attempting to resolve the latest version from the manifest...');
|
core.info('Attempting to resolve the latest version from the manifest...');
|
||||||
const resolvedVersion = await resolveVersionFromManifest(
|
const resolvedVersion = await resolveVersionFromManifest(
|
||||||
versionSpec,
|
versionSpec,
|
||||||
true,
|
true,
|
||||||
auth
|
auth,
|
||||||
|
arch
|
||||||
);
|
);
|
||||||
if (resolvedVersion) {
|
if (resolvedVersion) {
|
||||||
versionSpec = resolvedVersion;
|
versionSpec = resolvedVersion;
|
||||||
|
@ -68,9 +69,9 @@ export async function getGo(
|
||||||
// Try download from internal distribution (popular versions only)
|
// Try download from internal distribution (popular versions only)
|
||||||
//
|
//
|
||||||
try {
|
try {
|
||||||
info = await getInfoFromManifest(versionSpec, true, auth);
|
info = await getInfoFromManifest(versionSpec, true, auth, arch);
|
||||||
if (info) {
|
if (info) {
|
||||||
downloadPath = await installGoVersion(info, auth);
|
downloadPath = await installGoVersion(info, auth, arch);
|
||||||
} else {
|
} else {
|
||||||
core.info(
|
core.info(
|
||||||
'Not found in manifest. Falling back to download directly from Go'
|
'Not found in manifest. Falling back to download directly from Go'
|
||||||
|
@ -95,16 +96,16 @@ export async function getGo(
|
||||||
// Download from storage.googleapis.com
|
// Download from storage.googleapis.com
|
||||||
//
|
//
|
||||||
if (!downloadPath) {
|
if (!downloadPath) {
|
||||||
info = await getInfoFromDist(versionSpec);
|
info = await getInfoFromDist(versionSpec, arch);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`
|
`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
core.info('Install from dist');
|
core.info('Install from dist');
|
||||||
downloadPath = await installGoVersion(info, undefined);
|
downloadPath = await installGoVersion(info, undefined, arch);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(`Failed to download version ${versionSpec}: ${err}`);
|
throw new Error(`Failed to download version ${versionSpec}: ${err}`);
|
||||||
}
|
}
|
||||||
|
@ -116,10 +117,11 @@ export async function getGo(
|
||||||
async function resolveVersionFromManifest(
|
async function resolveVersionFromManifest(
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
stable: boolean,
|
stable: boolean,
|
||||||
auth: string | undefined
|
auth: string | undefined,
|
||||||
|
arch: string
|
||||||
): Promise<string | undefined> {
|
): Promise<string | undefined> {
|
||||||
try {
|
try {
|
||||||
const info = await getInfoFromManifest(versionSpec, stable, auth);
|
const info = await getInfoFromManifest(versionSpec, stable, auth, arch);
|
||||||
return info?.resolvedVersion;
|
return info?.resolvedVersion;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
core.info('Unable to resolve a version from the manifest...');
|
core.info('Unable to resolve a version from the manifest...');
|
||||||
|
@ -129,7 +131,8 @@ async function resolveVersionFromManifest(
|
||||||
|
|
||||||
async function installGoVersion(
|
async function installGoVersion(
|
||||||
info: IGoVersionInfo,
|
info: IGoVersionInfo,
|
||||||
auth: string | undefined
|
auth: string | undefined,
|
||||||
|
arch: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
|
core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
|
||||||
|
|
||||||
|
@ -151,7 +154,8 @@ async function installGoVersion(
|
||||||
const cachedDir = await tc.cacheDir(
|
const cachedDir = await tc.cacheDir(
|
||||||
extPath,
|
extPath,
|
||||||
'go',
|
'go',
|
||||||
makeSemver(info.resolvedVersion)
|
makeSemver(info.resolvedVersion),
|
||||||
|
arch
|
||||||
);
|
);
|
||||||
core.info(`Successfully cached go to ${cachedDir}`);
|
core.info(`Successfully cached go to ${cachedDir}`);
|
||||||
return cachedDir;
|
return cachedDir;
|
||||||
|
@ -173,7 +177,8 @@ export async function extractGoArchive(archivePath: string): Promise<string> {
|
||||||
export async function getInfoFromManifest(
|
export async function getInfoFromManifest(
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
stable: boolean,
|
stable: boolean,
|
||||||
auth: string | undefined
|
auth: string | undefined,
|
||||||
|
arch = sys.getArch()
|
||||||
): Promise<IGoVersionInfo | null> {
|
): Promise<IGoVersionInfo | null> {
|
||||||
let info: IGoVersionInfo | null = null;
|
let info: IGoVersionInfo | null = null;
|
||||||
const releases = await tc.getManifestFromRepo(
|
const releases = await tc.getManifestFromRepo(
|
||||||
|
@ -183,7 +188,7 @@ export async function getInfoFromManifest(
|
||||||
'main'
|
'main'
|
||||||
);
|
);
|
||||||
core.info(`matching ${versionSpec}...`);
|
core.info(`matching ${versionSpec}...`);
|
||||||
const rel = await tc.findFromManifest(versionSpec, stable, releases);
|
const rel = await tc.findFromManifest(versionSpec, stable, releases, arch);
|
||||||
|
|
||||||
if (rel && rel.files.length > 0) {
|
if (rel && rel.files.length > 0) {
|
||||||
info = <IGoVersionInfo>{};
|
info = <IGoVersionInfo>{};
|
||||||
|
@ -197,10 +202,11 @@ export async function getInfoFromManifest(
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getInfoFromDist(
|
async function getInfoFromDist(
|
||||||
versionSpec: string
|
versionSpec: string,
|
||||||
|
arch: string
|
||||||
): Promise<IGoVersionInfo | null> {
|
): Promise<IGoVersionInfo | null> {
|
||||||
let version: IGoVersion | undefined;
|
let version: IGoVersion | undefined;
|
||||||
version = await findMatch(versionSpec);
|
version = await findMatch(versionSpec, arch);
|
||||||
if (!version) {
|
if (!version) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -216,9 +222,10 @@ async function getInfoFromDist(
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function findMatch(
|
export async function findMatch(
|
||||||
versionSpec: string
|
versionSpec: string,
|
||||||
|
arch = sys.getArch()
|
||||||
): Promise<IGoVersion | undefined> {
|
): Promise<IGoVersion | undefined> {
|
||||||
let archFilter = sys.getArch();
|
let archFilter = translateArchToDistUrl(arch);
|
||||||
let platFilter = sys.getPlatform();
|
let platFilter = sys.getPlatform();
|
||||||
|
|
||||||
let result: IGoVersion | undefined;
|
let result: IGoVersion | undefined;
|
||||||
|
@ -316,3 +323,12 @@ export function parseGoVersionFile(versionFilePath: string): string {
|
||||||
|
|
||||||
return contents.trim();
|
return contents.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function translateArchToDistUrl(arch: string): string {
|
||||||
|
switch (arch) {
|
||||||
|
case 'arm':
|
||||||
|
return 'armv6l';
|
||||||
|
default:
|
||||||
|
return arch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue