Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
aef5ea64d0 |
@@ -142,7 +142,7 @@ describe('setup-go', () => {
|
|||||||
os.platform = 'darwin';
|
os.platform = 'darwin';
|
||||||
os.arch = 'x64';
|
os.arch = 'x64';
|
||||||
|
|
||||||
const match = await im.getInfoFromManifest('1.9.7', true, 'mocktoken');
|
const match = await im.getInfoFromManifest('1.21', true, 'mocktoken');
|
||||||
expect(match).toBeDefined();
|
expect(match).toBeDefined();
|
||||||
expect(match!.resolvedVersion).toBe('1.9.7');
|
expect(match!.resolvedVersion).toBe('1.9.7');
|
||||||
expect(match!.type).toBe('manifest');
|
expect(match!.type).toBe('manifest');
|
||||||
|
43
dist/setup/index.js
vendored
43
dist/setup/index.js
vendored
@@ -61385,7 +61385,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.resolveStableVersionInput = exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.getManifest = exports.extractGoArchive = exports.getGo = void 0;
|
exports.resolveStableVersionInput = exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.getManifestFromRepo = exports.getManifest = exports.extractGoArchive = exports.getGo = void 0;
|
||||||
const tc = __importStar(__nccwpck_require__(7784));
|
const tc = __importStar(__nccwpck_require__(7784));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const path = __importStar(__nccwpck_require__(1017));
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
@@ -61568,10 +61568,49 @@ function extractGoArchive(archivePath) {
|
|||||||
exports.extractGoArchive = extractGoArchive;
|
exports.extractGoArchive = extractGoArchive;
|
||||||
function getManifest(auth) {
|
function getManifest(auth) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return tc.getManifestFromRepo('actions', 'go-versions', auth, 'main');
|
return getManifestFromRepo('actions', 'go-versions', auth, 'main');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getManifest = getManifest;
|
exports.getManifest = getManifest;
|
||||||
|
function getManifestFromRepo(owner, repo, auth, branch = 'master') {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let releases = [];
|
||||||
|
const treeUrl = `https://gitea.icodef.com/api/v1/repos/${owner}/${repo}/git/trees/${branch}`;
|
||||||
|
const http = new httpm.HttpClient('tool-cache');
|
||||||
|
const headers = {};
|
||||||
|
if (auth) {
|
||||||
|
core.debug('set auth');
|
||||||
|
headers.authorization = auth;
|
||||||
|
}
|
||||||
|
const response = yield http.getJson(treeUrl, headers);
|
||||||
|
if (!response.result) {
|
||||||
|
return releases;
|
||||||
|
}
|
||||||
|
let manifestUrl = '';
|
||||||
|
for (const item of response.result.tree) {
|
||||||
|
if (item.path === 'versions-manifest.json') {
|
||||||
|
manifestUrl = item.url;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
headers['accept'] = 'application/vnd.github.VERSION.raw';
|
||||||
|
const versionsRaw = yield (yield http.get(manifestUrl, headers)).readBody();
|
||||||
|
const base64 = JSON.parse(versionsRaw);
|
||||||
|
let tmp = Buffer.from(base64['content'], 'base64').toString('ascii');
|
||||||
|
if (tmp) {
|
||||||
|
// shouldn't be needed but protects against invalid json saved with BOM
|
||||||
|
tmp = tmp.replace(/^\uFEFF/, '');
|
||||||
|
try {
|
||||||
|
releases = JSON.parse(tmp);
|
||||||
|
}
|
||||||
|
catch (_a) {
|
||||||
|
core.debug('Invalid json');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return releases;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.getManifestFromRepo = getManifestFromRepo;
|
||||||
function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch(), manifest) {
|
function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch(), manifest) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let info = null;
|
let info = null;
|
||||||
|
@@ -7,6 +7,8 @@ import * as sys from './system';
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import {StableReleaseAlias} from './utils';
|
import {StableReleaseAlias} from './utils';
|
||||||
|
import {IToolRelease} from '@actions/tool-cache';
|
||||||
|
import {OutgoingHttpHeaders} from 'http';
|
||||||
|
|
||||||
type InstallationType = 'dist' | 'manifest';
|
type InstallationType = 'dist' | 'manifest';
|
||||||
|
|
||||||
@@ -275,7 +277,67 @@ export async function extractGoArchive(archivePath: string): Promise<string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getManifest(auth: string | undefined) {
|
export async function getManifest(auth: string | undefined) {
|
||||||
return tc.getManifestFromRepo('actions', 'go-versions', auth, 'main');
|
return getManifestFromRepo('actions', 'go-versions', auth, 'main');
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GitHubTreeItem {
|
||||||
|
path: string;
|
||||||
|
size: string;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GitHubTree {
|
||||||
|
tree: GitHubTreeItem[];
|
||||||
|
truncated: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getManifestFromRepo(
|
||||||
|
owner: string,
|
||||||
|
repo: string,
|
||||||
|
auth?: string,
|
||||||
|
branch = 'master'
|
||||||
|
): Promise<IToolRelease[]> {
|
||||||
|
let releases: IToolRelease[] = [];
|
||||||
|
const treeUrl = `https://gitea.icodef.com/api/v1/repos/${owner}/${repo}/git/trees/${branch}`;
|
||||||
|
|
||||||
|
const http: httpm.HttpClient = new httpm.HttpClient('tool-cache');
|
||||||
|
const headers: OutgoingHttpHeaders = {};
|
||||||
|
if (auth) {
|
||||||
|
core.debug('set auth');
|
||||||
|
headers.authorization = auth;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await http.getJson<GitHubTree>(treeUrl, headers);
|
||||||
|
if (!response.result) {
|
||||||
|
return releases;
|
||||||
|
}
|
||||||
|
|
||||||
|
let manifestUrl = '';
|
||||||
|
for (const item of response.result.tree) {
|
||||||
|
if (item.path === 'versions-manifest.json') {
|
||||||
|
manifestUrl = item.url;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
headers['accept'] = 'application/vnd.github.VERSION.raw';
|
||||||
|
const versionsRaw = await (await http.get(manifestUrl, headers)).readBody();
|
||||||
|
|
||||||
|
const base64 = JSON.parse(versionsRaw);
|
||||||
|
|
||||||
|
let tmp = Buffer.from(base64['content'], 'base64').toString('ascii');
|
||||||
|
|
||||||
|
if (tmp) {
|
||||||
|
// shouldn't be needed but protects against invalid json saved with BOM
|
||||||
|
tmp = tmp.replace(/^\uFEFF/, '');
|
||||||
|
try {
|
||||||
|
releases = JSON.parse(tmp);
|
||||||
|
} catch {
|
||||||
|
core.debug('Invalid json');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return releases;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getInfoFromManifest(
|
export async function getInfoFromManifest(
|
||||||
|
Reference in New Issue
Block a user