mirror of
https://github.com/actions/setup-go.git
synced 2025-05-04 14:14:34 +00:00
Add support for arm32 go arch (#253)
This commit is contained in:
50
dist/setup/index.js
vendored
50
dist/setup/index.js
vendored
@ -62858,13 +62858,12 @@ const httpm = __importStar(__nccwpck_require__(6255));
|
||||
const sys = __importStar(__nccwpck_require__(4300));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||
const os_1 = __importDefault(__nccwpck_require__(2037));
|
||||
function getGo(versionSpec, checkLatest, auth) {
|
||||
function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let osPlat = os_1.default.platform();
|
||||
let osArch = os_1.default.arch();
|
||||
if (checkLatest) {
|
||||
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) {
|
||||
versionSpec = resolvedVersion;
|
||||
core.info(`Resolved as '${versionSpec}'`);
|
||||
@ -62875,7 +62874,7 @@ function getGo(versionSpec, checkLatest, auth) {
|
||||
}
|
||||
// check cache
|
||||
let toolPath;
|
||||
toolPath = tc.find('go', versionSpec);
|
||||
toolPath = tc.find('go', versionSpec, arch);
|
||||
// If not found in cache, download
|
||||
if (toolPath) {
|
||||
core.info(`Found in cache @ ${toolPath}`);
|
||||
@ -62888,9 +62887,9 @@ function getGo(versionSpec, checkLatest, auth) {
|
||||
// Try download from internal distribution (popular versions only)
|
||||
//
|
||||
try {
|
||||
info = yield getInfoFromManifest(versionSpec, true, auth);
|
||||
info = yield getInfoFromManifest(versionSpec, true, auth, arch);
|
||||
if (info) {
|
||||
downloadPath = yield installGoVersion(info, auth);
|
||||
downloadPath = yield installGoVersion(info, auth, arch);
|
||||
}
|
||||
else {
|
||||
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
|
||||
//
|
||||
if (!downloadPath) {
|
||||
info = yield getInfoFromDist(versionSpec);
|
||||
info = yield getInfoFromDist(versionSpec, arch);
|
||||
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 {
|
||||
core.info('Install from dist');
|
||||
downloadPath = yield installGoVersion(info, undefined);
|
||||
downloadPath = yield installGoVersion(info, undefined, arch);
|
||||
}
|
||||
catch (err) {
|
||||
throw new Error(`Failed to download version ${versionSpec}: ${err}`);
|
||||
@ -62927,10 +62926,10 @@ function getGo(versionSpec, checkLatest, auth) {
|
||||
});
|
||||
}
|
||||
exports.getGo = getGo;
|
||||
function resolveVersionFromManifest(versionSpec, stable, auth) {
|
||||
function resolveVersionFromManifest(versionSpec, stable, auth, arch) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
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;
|
||||
}
|
||||
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* () {
|
||||
core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
|
||||
// Windows requires that we keep the extension (.zip) for extraction
|
||||
@ -62954,7 +62953,7 @@ function installGoVersion(info, auth) {
|
||||
extPath = path.join(extPath, 'go');
|
||||
}
|
||||
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}`);
|
||||
return cachedDir;
|
||||
});
|
||||
@ -62973,12 +62972,12 @@ function extractGoArchive(archivePath) {
|
||||
});
|
||||
}
|
||||
exports.extractGoArchive = extractGoArchive;
|
||||
function getInfoFromManifest(versionSpec, stable, auth) {
|
||||
function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch()) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let info = null;
|
||||
const releases = yield tc.getManifestFromRepo('actions', 'go-versions', auth, 'main');
|
||||
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) {
|
||||
info = {};
|
||||
info.type = 'manifest';
|
||||
@ -62990,10 +62989,10 @@ function getInfoFromManifest(versionSpec, stable, auth) {
|
||||
});
|
||||
}
|
||||
exports.getInfoFromManifest = getInfoFromManifest;
|
||||
function getInfoFromDist(versionSpec) {
|
||||
function getInfoFromDist(versionSpec, arch) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let version;
|
||||
version = yield findMatch(versionSpec);
|
||||
version = yield findMatch(versionSpec, arch);
|
||||
if (!version) {
|
||||
return null;
|
||||
}
|
||||
@ -63006,9 +63005,9 @@ function getInfoFromDist(versionSpec) {
|
||||
};
|
||||
});
|
||||
}
|
||||
function findMatch(versionSpec) {
|
||||
function findMatch(versionSpec, arch = os_1.default.arch()) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let archFilter = sys.getArch();
|
||||
let archFilter = sys.getArch(arch);
|
||||
let platFilter = sys.getPlatform();
|
||||
let result;
|
||||
let match;
|
||||
@ -63139,6 +63138,7 @@ const cache_restore_1 = __nccwpck_require__(9517);
|
||||
const cache_utils_1 = __nccwpck_require__(1678);
|
||||
const child_process_1 = __importDefault(__nccwpck_require__(2081));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||
const os_1 = __importDefault(__nccwpck_require__(2037));
|
||||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
@ -63149,11 +63149,15 @@ function run() {
|
||||
const versionSpec = resolveVersionInput();
|
||||
const cache = core.getBooleanInput('cache');
|
||||
core.info(`Setup go version spec ${versionSpec}`);
|
||||
let arch = core.getInput('architecture');
|
||||
if (!arch) {
|
||||
arch = os_1.default.arch();
|
||||
}
|
||||
if (versionSpec) {
|
||||
let token = core.getInput('token');
|
||||
let auth = !token || cache_utils_1.isGhes() ? undefined : `token ${token}`;
|
||||
const checkLatest = core.getBooleanInput('check-latest');
|
||||
const installDir = yield installer.getGo(versionSpec, checkLatest, auth);
|
||||
const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch);
|
||||
core.addPath(path_1.default.join(installDir, 'bin'));
|
||||
core.info('Added go to the path');
|
||||
const version = installer.makeSemver(versionSpec);
|
||||
@ -63286,9 +63290,8 @@ function getPlatform() {
|
||||
return plat;
|
||||
}
|
||||
exports.getPlatform = getPlatform;
|
||||
function getArch() {
|
||||
function getArch(arch) {
|
||||
// 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'.
|
||||
let arch = os.arch();
|
||||
// wants amd64, 386, arm64, armv61, ppc641e, s390x
|
||||
// currently not supported by runner but future proofed mapping
|
||||
switch (arch) {
|
||||
@ -63301,6 +63304,9 @@ function getArch() {
|
||||
case 'x32':
|
||||
arch = '386';
|
||||
break;
|
||||
case 'arm':
|
||||
arch = 'armv6l';
|
||||
break;
|
||||
}
|
||||
return arch;
|
||||
}
|
||||
|
Reference in New Issue
Block a user