Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unpack directly #15

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61447,28 +61447,38 @@ function installGoVersion(info, auth, arch) {
const isWindows = os_1.default.platform() === 'win32';
const tempDir = process.env.RUNNER_TEMP || '.';
const fileName = isWindows ? path.join(tempDir, info.fileName) : undefined;
core.info(`Temporary directory ${os_1.default.tmpdir()}`);
const downloadPath = yield tc.downloadTool(info.downloadUrl, fileName, auth);
core.info('Extracting Go...');
let extPath = yield extractGoArchive(downloadPath);
const cachedDir = path.join(process.env['RUNNER_TOOL_CACHE'], 'Go', makeSemver(info.resolvedVersion), arch);
let extPath = yield extractGoArchive(downloadPath, cachedDir);
core.info(`Successfully extracted go to ${extPath}`);
if (info.type === 'dist') {
extPath = path.join(extPath, 'go');
}
core.info('Adding to the cache ...');
const cachedDir = yield tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion), arch);
// core.info('Adding to the cache ...');
// const cachedDir = await tc.cacheDir(
// extPath,
// 'go',
// makeSemver(info.resolvedVersion),
// arch
// );
core.info(`Successfully cached go to ${cachedDir}`);
return cachedDir;
});
}
function extractGoArchive(archivePath) {
function extractGoArchive(archivePath, dest) {
return __awaiter(this, void 0, void 0, function* () {
const platform = os_1.default.platform();
let extPath;
if (!fs_1.default.existsSync(dest)) {
fs_1.default.mkdirSync(dest, { recursive: true });
}
if (platform === 'win32') {
extPath = yield tc.extractZip(archivePath);
extPath = yield tc.extractZip(archivePath, dest);
}
else {
extPath = yield tc.extractTar(archivePath);
extPath = yield tc.extractTar(archivePath, dest);
}
return extPath;
});
Expand Down
37 changes: 25 additions & 12 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,35 +175,48 @@ async function installGoVersion(
const isWindows = os.platform() === 'win32';
const tempDir = process.env.RUNNER_TEMP || '.';
const fileName = isWindows ? path.join(tempDir, info.fileName) : undefined;

core.info(`Temporary directory ${os.tmpdir()}`);
const downloadPath = await tc.downloadTool(info.downloadUrl, fileName, auth);

core.info('Extracting Go...');
let extPath = await extractGoArchive(downloadPath);
const cachedDir = path.join(
process.env['RUNNER_TOOL_CACHE']!,
'Go',
makeSemver(info.resolvedVersion),
arch
);
let extPath = await extractGoArchive(downloadPath, cachedDir);
core.info(`Successfully extracted go to ${extPath}`);
if (info.type === 'dist') {
extPath = path.join(extPath, 'go');
}

core.info('Adding to the cache ...');
const cachedDir = await tc.cacheDir(
extPath,
'go',
makeSemver(info.resolvedVersion),
arch
);
// core.info('Adding to the cache ...');
// const cachedDir = await tc.cacheDir(
// extPath,
// 'go',
// makeSemver(info.resolvedVersion),
// arch
// );
core.info(`Successfully cached go to ${cachedDir}`);
return cachedDir;
}

export async function extractGoArchive(archivePath: string): Promise<string> {
export async function extractGoArchive(
archivePath: string,
dest: string
): Promise<string> {
const platform = os.platform();
let extPath: string;

if (!fs.existsSync(dest)) {
fs.mkdirSync(dest, {recursive: true});
}

if (platform === 'win32') {
extPath = await tc.extractZip(archivePath);
extPath = await tc.extractZip(archivePath, dest);
} else {
extPath = await tc.extractTar(archivePath);
extPath = await tc.extractTar(archivePath, dest);
}

return extPath;
Expand Down