mirror of
https://git.studyfor.work/actions/gitea-tool-cache.git
synced 2026-01-14 01:06:02 +08:00
更新错误处理
This commit is contained in:
parent
c847c25fe2
commit
b93c3b2ef3
@ -11,6 +11,7 @@ describe('gitea-tool-cache', () => {
|
|||||||
let inSpy: jest.SpyInstance;
|
let inSpy: jest.SpyInstance;
|
||||||
let platSpy: jest.SpyInstance;
|
let platSpy: jest.SpyInstance;
|
||||||
let archSpy: jest.SpyInstance;
|
let archSpy: jest.SpyInstance;
|
||||||
|
let logSpy: jest.SpyInstance;
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
process.env['RUNNER_TOOL_CACHE'] = join(process.cwd(), './cache/toolcache');
|
process.env['RUNNER_TOOL_CACHE'] = join(process.cwd(), './cache/toolcache');
|
||||||
@ -30,6 +31,9 @@ describe('gitea-tool-cache', () => {
|
|||||||
platSpy.mockImplementation(() => os['platform']);
|
platSpy.mockImplementation(() => os['platform']);
|
||||||
archSpy = jest.spyOn(osm, 'arch');
|
archSpy = jest.spyOn(osm, 'arch');
|
||||||
archSpy.mockImplementation(() => os['arch']);
|
archSpy.mockImplementation(() => os['arch']);
|
||||||
|
|
||||||
|
// writes
|
||||||
|
logSpy = jest.spyOn(core, 'info');
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -59,9 +63,10 @@ describe('gitea-tool-cache', () => {
|
|||||||
// });
|
// });
|
||||||
|
|
||||||
it('installs linux', async () => {
|
it('installs linux', async () => {
|
||||||
|
rmSync('./cache', { recursive: true, force: true });
|
||||||
os['platform'] = 'linux';
|
os['platform'] = 'linux';
|
||||||
os['arch'] = 'x64';
|
os['arch'] = 'x64';
|
||||||
inputs['node-version'] = '18 ';
|
inputs['node-version'] = '18';
|
||||||
await nodeInstall();
|
await nodeInstall();
|
||||||
// inputs['go-version'] = '1.21.1';
|
// inputs['go-version'] = '1.21.1';
|
||||||
// await goInstall();
|
// await goInstall();
|
||||||
|
|||||||
150
dist/index.js
vendored
150
dist/index.js
vendored
@ -49480,30 +49480,28 @@ async function dotnetInstall() {
|
|||||||
const platform = (0, os_1.platform)();
|
const platform = (0, os_1.platform)();
|
||||||
const dotnetVersion = (0, core_1.getInput)('dotnet-version');
|
const dotnetVersion = (0, core_1.getInput)('dotnet-version');
|
||||||
if (!dotnetVersion) {
|
if (!dotnetVersion) {
|
||||||
console.log('没有dotnet-version,跳过dotnet安装');
|
(0, core_1.info)('没有dotnet-version,跳过dotnet安装');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (process.env['RUNNER_TOOL_CACHE'] &&
|
if (process.env['RUNNER_TOOL_CACHE'] &&
|
||||||
(0, fs_1.existsSync)((0, path_1.join)(process.env['RUNNER_TOOL_CACHE'], 'dotnet', dotnetVersion, (0, os_1.arch)()))) {
|
(0, fs_1.existsSync)((0, path_1.join)(process.env['RUNNER_TOOL_CACHE'], 'dotnet', dotnetVersion, (0, os_1.arch)()))) {
|
||||||
console.log('dotnet已经安装过了');
|
(0, core_1.info)('dotnet已经安装过了');
|
||||||
return (0, core_1.setOutput)('dotnet-path', (0, path_1.join)(process.env['RUNNER_TOOL_CACHE'], 'dotnet', dotnetVersion, (0, os_1.arch)()));
|
return (0, core_1.setOutput)('dotnet-path', (0, path_1.join)(process.env['RUNNER_TOOL_CACHE'], 'dotnet', dotnetVersion, (0, os_1.arch)()));
|
||||||
}
|
}
|
||||||
const versionList = dotnetVersion.split('.');
|
const versionList = dotnetVersion.split('.');
|
||||||
const channelVersion = `${versionList[0]}.${versionList[1]}`;
|
const channelVersion = `${versionList[0]}.${versionList[1]}`;
|
||||||
const releasesUrl = `https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/${channelVersion}/releases.json`;
|
const releasesUrl = `https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/${channelVersion}/releases.json`;
|
||||||
const releases = await (0, axios_1.get)(releasesUrl).catch(err => {
|
const releases = await (0, axios_1.get)(releasesUrl).catch(err => {
|
||||||
console.log(err);
|
(0, core_1.error)(err);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
if (!releases || !releases.data) {
|
if (!releases || !releases.data) {
|
||||||
console.log('获取dotnet版本失败');
|
return (0, core_1.setFailed)('获取dotnet版本失败');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const releasesList = releases.data.releases;
|
const releasesList = releases.data.releases;
|
||||||
const release = releasesList.find((item) => item.sdk.version === dotnetVersion);
|
const release = releasesList.find((item) => item.sdk.version === dotnetVersion);
|
||||||
if (!release) {
|
if (!release) {
|
||||||
console.log('没有找到dotnet版本');
|
return (0, core_1.setFailed)('没有找到dotnet版本');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const list = release.sdk.files.find((item) => {
|
const list = release.sdk.files.find((item) => {
|
||||||
if (platform === 'win32') {
|
if (platform === 'win32') {
|
||||||
@ -49517,27 +49515,30 @@ async function dotnetInstall() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!list) {
|
if (!list) {
|
||||||
console.log('没有找到dotnet版本');
|
return (0, core_1.setFailed)('没有找到dotnet版本');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
// console.log(list);
|
(0, core_1.info)(list.url);
|
||||||
console.log(list.url);
|
try {
|
||||||
const dotnetPath = await (0, tool_cache_1.downloadTool)(list.url);
|
const dotnetPath = await (0, tool_cache_1.downloadTool)(list.url);
|
||||||
if (platform === 'win32') {
|
if (platform === 'win32') {
|
||||||
(0, fs_1.renameSync)(dotnetPath, dotnetPath + '.zip');
|
(0, fs_1.renameSync)(dotnetPath, dotnetPath + '.zip');
|
||||||
const dotnetExtractedFolder = await (0, tool_cache_1.extractZip)(dotnetPath + '.zip', './cache/dotnet');
|
const dotnetExtractedFolder = await (0, tool_cache_1.extractZip)(dotnetPath + '.zip', './cache/dotnet');
|
||||||
const cachedPath = await (0, tool_cache_1.cacheDir)(dotnetExtractedFolder, 'dotnet', dotnetVersion);
|
const cachedPath = await (0, tool_cache_1.cacheDir)(dotnetExtractedFolder, 'dotnet', dotnetVersion);
|
||||||
(0, core_1.addPath)(cachedPath);
|
(0, core_1.addPath)(cachedPath);
|
||||||
(0, core_1.setOutput)('dotnet-path', cachedPath);
|
(0, core_1.setOutput)('dotnet-path', cachedPath);
|
||||||
|
}
|
||||||
|
else if (platform === 'darwin') {
|
||||||
|
(0, core_1.info)('没有mac,暂未测试');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const dotnetExtractedFolder = await (0, tool_cache_1.extractTar)(dotnetPath, './cache/dotnet');
|
||||||
|
const cachedPath = await (0, tool_cache_1.cacheDir)(dotnetExtractedFolder, 'dotnet', dotnetVersion);
|
||||||
|
(0, core_1.addPath)(cachedPath);
|
||||||
|
(0, core_1.setOutput)('dotnet-path', cachedPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (platform === 'darwin') {
|
catch (error) {
|
||||||
console.log('没有mac,暂未测试');
|
(0, core_1.setFailed)(JSON.stringify(error));
|
||||||
}
|
|
||||||
else {
|
|
||||||
const dotnetExtractedFolder = await (0, tool_cache_1.extractTar)(dotnetPath, './cache/dotnet');
|
|
||||||
const cachedPath = await (0, tool_cache_1.cacheDir)(dotnetExtractedFolder, 'dotnet', dotnetVersion);
|
|
||||||
(0, core_1.addPath)(cachedPath);
|
|
||||||
(0, core_1.setOutput)('dotnet-path', cachedPath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.dotnetInstall = dotnetInstall;
|
exports.dotnetInstall = dotnetInstall;
|
||||||
@ -49562,31 +49563,36 @@ async function goInstall() {
|
|||||||
const platform = (0, os_1.platform)();
|
const platform = (0, os_1.platform)();
|
||||||
const goVersion = (0, core_1.getInput)('go-version');
|
const goVersion = (0, core_1.getInput)('go-version');
|
||||||
if (!goVersion) {
|
if (!goVersion) {
|
||||||
console.log('没有go-version,跳过go安装');
|
(0, core_1.info)('没有go-version,跳过go安装');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (process.env['RUNNER_TOOL_CACHE'] &&
|
if (process.env['RUNNER_TOOL_CACHE'] &&
|
||||||
(0, fs_1.existsSync)((0, path_1.join)(process.env['RUNNER_TOOL_CACHE'], 'go', goVersion, (0, os_1.arch)()))) {
|
(0, fs_1.existsSync)((0, path_1.join)(process.env['RUNNER_TOOL_CACHE'], 'go', goVersion, (0, os_1.arch)()))) {
|
||||||
console.log('go已经安装过了');
|
(0, core_1.info)('go已经安装过了');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (platform === 'win32') {
|
try {
|
||||||
console.log(`https://golang.google.cn/dl/go${goVersion}.windows-amd64.zip`);
|
if (platform === 'win32') {
|
||||||
const goPath = await (0, tool_cache_1.downloadTool)(`https://golang.google.cn/dl/go${goVersion}.windows-amd64.zip`);
|
(0, core_1.info)(`https://golang.google.cn/dl/go${goVersion}.windows-amd64.zip`);
|
||||||
(0, fs_1.renameSync)(goPath, goPath + '.zip');
|
const goPath = await (0, tool_cache_1.downloadTool)(`https://golang.google.cn/dl/go${goVersion}.windows-amd64.zip`);
|
||||||
const goExtractedFolder = await (0, tool_cache_1.extractZip)(goPath + '.zip', './cache/go');
|
(0, fs_1.renameSync)(goPath, goPath + '.zip');
|
||||||
const cachedPath = await (0, tool_cache_1.cacheDir)((0, path_1.join)(goExtractedFolder, 'go'), 'go', goVersion);
|
const goExtractedFolder = await (0, tool_cache_1.extractZip)(goPath + '.zip', './cache/go');
|
||||||
(0, core_1.addPath)(cachedPath);
|
const cachedPath = await (0, tool_cache_1.cacheDir)((0, path_1.join)(goExtractedFolder, 'go'), 'go', goVersion);
|
||||||
|
(0, core_1.addPath)(cachedPath);
|
||||||
|
}
|
||||||
|
else if (platform === 'darwin') {
|
||||||
|
(0, core_1.info)('没有mac,暂未测试');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
(0, core_1.info)(`https://golang.google.cn/dl/go${goVersion}.linux-amd64.tar.gz`);
|
||||||
|
const goPath = await (0, tool_cache_1.downloadTool)(`https://golang.google.cn/dl/go${goVersion}.linux-amd64.tar.gz`);
|
||||||
|
const goExtractedFolder = await (0, tool_cache_1.extractTar)(goPath, './cache/go');
|
||||||
|
const cachedPath = await (0, tool_cache_1.cacheDir)((0, path_1.join)(goExtractedFolder, 'go'), 'go', goVersion);
|
||||||
|
(0, core_1.addPath)(cachedPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (platform === 'darwin') {
|
catch (error) {
|
||||||
console.log('没有mac,暂未测试');
|
(0, core_1.setFailed)(JSON.stringify(error));
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log(`https://golang.google.cn/dl/go${goVersion}.linux-amd64.tar.gz`);
|
|
||||||
const goPath = await (0, tool_cache_1.downloadTool)(`https://golang.google.cn/dl/go${goVersion}.linux-amd64.tar.gz`);
|
|
||||||
const goExtractedFolder = await (0, tool_cache_1.extractTar)(goPath, './cache/go');
|
|
||||||
const cachedPath = await (0, tool_cache_1.cacheDir)((0, path_1.join)(goExtractedFolder, 'go'), 'go', goVersion);
|
|
||||||
(0, core_1.addPath)(cachedPath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.goInstall = goInstall;
|
exports.goInstall = goInstall;
|
||||||
@ -49639,44 +49645,50 @@ async function nodeInstall() {
|
|||||||
const platform = (0, os_1.platform)();
|
const platform = (0, os_1.platform)();
|
||||||
const nodeVersion = (0, core_1.getInput)('node-version');
|
const nodeVersion = (0, core_1.getInput)('node-version');
|
||||||
if (!nodeVersion) {
|
if (!nodeVersion) {
|
||||||
console.log('没有node-version,跳过node安装');
|
(0, core_1.info)('没有node-version,跳过node安装');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const version = await (0, gitea_tool_cache_version_alias_1.nodeVersionAlias)(nodeVersion, {
|
const version = await (0, gitea_tool_cache_version_alias_1.nodeVersionAlias)(nodeVersion, {
|
||||||
mirror: 'https://npmmirror.com/mirrors/node'
|
mirror: 'https://npmmirror.com/mirrors/node'
|
||||||
}).catch(err => err);
|
}).catch(err => err);
|
||||||
if (version instanceof Error) {
|
if (version instanceof Error) {
|
||||||
console.log('node版本错误', version);
|
// console.error('node版本错误', version);
|
||||||
|
(0, core_1.setFailed)('node版本错误: ' + version);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (process.env['RUNNER_TOOL_CACHE'] &&
|
if (process.env['RUNNER_TOOL_CACHE'] &&
|
||||||
(0, fs_1.existsSync)((0, path_1.join)(process.env['RUNNER_TOOL_CACHE'], 'node', version, (0, os_1.arch)()))) {
|
(0, fs_1.existsSync)((0, path_1.join)(process.env['RUNNER_TOOL_CACHE'], 'node', version, (0, os_1.arch)()))) {
|
||||||
console.log('node已经安装过了');
|
(0, core_1.info)('node已经安装过了');
|
||||||
return (0, core_1.setOutput)('node-version', version);
|
return (0, core_1.setOutput)('node-version', version);
|
||||||
}
|
}
|
||||||
if (platform === 'win32') {
|
try {
|
||||||
console.log(`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-win-${(0, os_1.arch)()}.zip`);
|
if (platform === 'win32') {
|
||||||
const nodePath = await (0, tool_cache_1.downloadTool)(`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-win-${(0, os_1.arch)()}.zip`);
|
(0, core_1.info)(`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-win-${(0, os_1.arch)()}.zip`);
|
||||||
(0, fs_1.renameSync)(nodePath, nodePath + '.zip');
|
const nodePath = await (0, tool_cache_1.downloadTool)(`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-win-${(0, os_1.arch)()}.zip`);
|
||||||
const nodeExtractedFolder = await (0, tool_cache_1.extractZip)(nodePath + '.zip', './cache/node');
|
(0, fs_1.renameSync)(nodePath, nodePath + '.zip');
|
||||||
const cachedPath = await (0, tool_cache_1.cacheDir)((0, path_1.join)(nodeExtractedFolder, `node-v${version}-win-${(0, os_1.arch)()}`), 'node', version);
|
const nodeExtractedFolder = await (0, tool_cache_1.extractZip)(nodePath + '.zip', './cache/node');
|
||||||
(0, core_1.addPath)(cachedPath);
|
const cachedPath = await (0, tool_cache_1.cacheDir)((0, path_1.join)(nodeExtractedFolder, `node-v${version}-win-${(0, os_1.arch)()}`), 'node', version);
|
||||||
(0, core_1.setOutput)('node-version', version);
|
(0, core_1.addPath)(cachedPath);
|
||||||
|
(0, core_1.setOutput)('node-version', version);
|
||||||
|
}
|
||||||
|
else if (platform === 'darwin') {
|
||||||
|
(0, core_1.info)('没有mac,暂未测试');
|
||||||
|
// const nodePath = await downloadTool(
|
||||||
|
// `https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}.pkg`
|
||||||
|
// );
|
||||||
|
// const nodeExtractedFolder = await extractXar(nodePath, './cache/node');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
(0, core_1.info)(`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-linux-${(0, os_1.arch)()}.tar.gz`);
|
||||||
|
const nodePath = await (0, tool_cache_1.downloadTool)(`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-linux-${(0, os_1.arch)()}.tar.gz`);
|
||||||
|
const nodeExtractedFolder = await (0, tool_cache_1.extractTar)(nodePath, './cache/node');
|
||||||
|
const cachedPath = await (0, tool_cache_1.cacheDir)((0, path_1.join)(nodeExtractedFolder, `node-v${version}-linux-${(0, os_1.arch)()}`), 'node', version);
|
||||||
|
(0, core_1.addPath)(cachedPath);
|
||||||
|
(0, core_1.setOutput)('node-version', version);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (platform === 'darwin') {
|
catch (error) {
|
||||||
console.log('没有mac,暂未测试');
|
(0, core_1.setFailed)(JSON.stringify(error));
|
||||||
// const nodePath = await downloadTool(
|
|
||||||
// `https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}.pkg`
|
|
||||||
// );
|
|
||||||
// const nodeExtractedFolder = await extractXar(nodePath, './cache/node');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log(`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-linux-${(0, os_1.arch)()}.tar.gz`);
|
|
||||||
const nodePath = await (0, tool_cache_1.downloadTool)(`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-linux-${(0, os_1.arch)()}.tar.gz`);
|
|
||||||
const nodeExtractedFolder = await (0, tool_cache_1.extractTar)(nodePath, './cache/node');
|
|
||||||
const cachedPath = await (0, tool_cache_1.cacheDir)((0, path_1.join)(nodeExtractedFolder, `node-v${version}-linux-${(0, os_1.arch)()}`), 'node', version);
|
|
||||||
(0, core_1.addPath)(cachedPath);
|
|
||||||
(0, core_1.setOutput)('node-version', version);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.nodeInstall = nodeInstall;
|
exports.nodeInstall = nodeInstall;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { downloadTool, extractZip, extractTar, extractXar, cacheDir } from '@actions/tool-cache';
|
import { downloadTool, extractZip, extractTar, extractXar, cacheDir } from '@actions/tool-cache';
|
||||||
import { addPath, getInput, setOutput } from '@actions/core';
|
import { addPath, getInput, setOutput, info, setFailed, error } from '@actions/core';
|
||||||
import { arch, platform as Platform } from 'os';
|
import { arch, platform as Platform } from 'os';
|
||||||
import { existsSync, renameSync } from 'fs';
|
import { existsSync, renameSync } from 'fs';
|
||||||
import { get } from 'axios';
|
import { get } from 'axios';
|
||||||
@ -10,7 +10,7 @@ export async function dotnetInstall() {
|
|||||||
const platform = Platform();
|
const platform = Platform();
|
||||||
const dotnetVersion = getInput('dotnet-version');
|
const dotnetVersion = getInput('dotnet-version');
|
||||||
if (!dotnetVersion) {
|
if (!dotnetVersion) {
|
||||||
console.log('没有dotnet-version,跳过dotnet安装');
|
info('没有dotnet-version,跳过dotnet安装');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ export async function dotnetInstall() {
|
|||||||
process.env['RUNNER_TOOL_CACHE'] &&
|
process.env['RUNNER_TOOL_CACHE'] &&
|
||||||
existsSync(join(process.env['RUNNER_TOOL_CACHE'], 'dotnet', dotnetVersion, arch()))
|
existsSync(join(process.env['RUNNER_TOOL_CACHE'], 'dotnet', dotnetVersion, arch()))
|
||||||
) {
|
) {
|
||||||
console.log('dotnet已经安装过了');
|
info('dotnet已经安装过了');
|
||||||
return setOutput(
|
return setOutput(
|
||||||
'dotnet-path',
|
'dotnet-path',
|
||||||
join(process.env['RUNNER_TOOL_CACHE'], 'dotnet', dotnetVersion, arch())
|
join(process.env['RUNNER_TOOL_CACHE'], 'dotnet', dotnetVersion, arch())
|
||||||
@ -28,21 +28,19 @@ export async function dotnetInstall() {
|
|||||||
const channelVersion = `${versionList[0]}.${versionList[1]}`;
|
const channelVersion = `${versionList[0]}.${versionList[1]}`;
|
||||||
const releasesUrl = `https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/${channelVersion}/releases.json`;
|
const releasesUrl = `https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/${channelVersion}/releases.json`;
|
||||||
const releases = await get(releasesUrl).catch(err => {
|
const releases = await get(releasesUrl).catch(err => {
|
||||||
console.log(err);
|
error(err);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!releases || !releases.data) {
|
if (!releases || !releases.data) {
|
||||||
console.log('获取dotnet版本失败');
|
return setFailed('获取dotnet版本失败');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
const releasesList = (releases.data as Record<string, any>).releases;
|
const releasesList = (releases.data as Record<string, any>).releases;
|
||||||
const release = releasesList.find(
|
const release = releasesList.find(
|
||||||
(item: Record<string, any>) => item.sdk.version === dotnetVersion
|
(item: Record<string, any>) => item.sdk.version === dotnetVersion
|
||||||
);
|
);
|
||||||
if (!release) {
|
if (!release) {
|
||||||
console.log('没有找到dotnet版本');
|
return setFailed('没有找到dotnet版本');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const list = release.sdk.files.find((item: Record<string, any>) => {
|
const list = release.sdk.files.find((item: Record<string, any>) => {
|
||||||
@ -55,26 +53,28 @@ export async function dotnetInstall() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!list) {
|
if (!list) {
|
||||||
console.log('没有找到dotnet版本');
|
return setFailed('没有找到dotnet版本');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
// console.log(list);
|
|
||||||
|
|
||||||
console.log(list.url);
|
info(list.url);
|
||||||
|
|
||||||
const dotnetPath = await downloadTool(list.url);
|
try {
|
||||||
if (platform === 'win32') {
|
const dotnetPath = await downloadTool(list.url);
|
||||||
renameSync(dotnetPath, dotnetPath + '.zip');
|
if (platform === 'win32') {
|
||||||
const dotnetExtractedFolder = await extractZip(dotnetPath + '.zip', './cache/dotnet');
|
renameSync(dotnetPath, dotnetPath + '.zip');
|
||||||
const cachedPath = await cacheDir(dotnetExtractedFolder, 'dotnet', dotnetVersion);
|
const dotnetExtractedFolder = await extractZip(dotnetPath + '.zip', './cache/dotnet');
|
||||||
addPath(cachedPath);
|
const cachedPath = await cacheDir(dotnetExtractedFolder, 'dotnet', dotnetVersion);
|
||||||
setOutput('dotnet-path', cachedPath);
|
addPath(cachedPath);
|
||||||
} else if (platform === 'darwin') {
|
setOutput('dotnet-path', cachedPath);
|
||||||
console.log('没有mac,暂未测试');
|
} else if (platform === 'darwin') {
|
||||||
} else {
|
info('没有mac,暂未测试');
|
||||||
const dotnetExtractedFolder = await extractTar(dotnetPath, './cache/dotnet');
|
} else {
|
||||||
const cachedPath = await cacheDir(dotnetExtractedFolder, 'dotnet', dotnetVersion);
|
const dotnetExtractedFolder = await extractTar(dotnetPath, './cache/dotnet');
|
||||||
addPath(cachedPath);
|
const cachedPath = await cacheDir(dotnetExtractedFolder, 'dotnet', dotnetVersion);
|
||||||
setOutput('dotnet-path', cachedPath);
|
addPath(cachedPath);
|
||||||
|
setOutput('dotnet-path', cachedPath);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
setFailed(JSON.stringify(error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { downloadTool, extractZip, extractTar, extractXar, cacheDir } from '@actions/tool-cache';
|
import { downloadTool, extractZip, extractTar, extractXar, cacheDir } from '@actions/tool-cache';
|
||||||
import { addPath, getInput } from '@actions/core';
|
import { addPath, getInput, info, setFailed } from '@actions/core';
|
||||||
import { arch, platform as Platform } from 'os';
|
import { arch, platform as Platform } from 'os';
|
||||||
import { existsSync, renameSync } from 'fs';
|
import { existsSync, renameSync } from 'fs';
|
||||||
|
|
||||||
@ -9,39 +9,43 @@ export async function goInstall() {
|
|||||||
const platform = Platform();
|
const platform = Platform();
|
||||||
const goVersion = getInput('go-version');
|
const goVersion = getInput('go-version');
|
||||||
if (!goVersion) {
|
if (!goVersion) {
|
||||||
console.log('没有go-version,跳过go安装');
|
info('没有go-version,跳过go安装');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
process.env['RUNNER_TOOL_CACHE'] &&
|
process.env['RUNNER_TOOL_CACHE'] &&
|
||||||
existsSync(join(process.env['RUNNER_TOOL_CACHE'], 'go', goVersion, arch()))
|
existsSync(join(process.env['RUNNER_TOOL_CACHE'], 'go', goVersion, arch()))
|
||||||
) {
|
) {
|
||||||
console.log('go已经安装过了');
|
info('go已经安装过了');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (platform === 'win32') {
|
try {
|
||||||
console.log(`https://golang.google.cn/dl/go${goVersion}.windows-amd64.zip`);
|
if (platform === 'win32') {
|
||||||
|
info(`https://golang.google.cn/dl/go${goVersion}.windows-amd64.zip`);
|
||||||
|
|
||||||
const goPath = await downloadTool(
|
const goPath = await downloadTool(
|
||||||
`https://golang.google.cn/dl/go${goVersion}.windows-amd64.zip`
|
`https://golang.google.cn/dl/go${goVersion}.windows-amd64.zip`
|
||||||
);
|
);
|
||||||
renameSync(goPath, goPath + '.zip');
|
renameSync(goPath, goPath + '.zip');
|
||||||
const goExtractedFolder = await extractZip(goPath + '.zip', './cache/go');
|
const goExtractedFolder = await extractZip(goPath + '.zip', './cache/go');
|
||||||
const cachedPath = await cacheDir(join(goExtractedFolder, 'go'), 'go', goVersion);
|
const cachedPath = await cacheDir(join(goExtractedFolder, 'go'), 'go', goVersion);
|
||||||
addPath(cachedPath);
|
addPath(cachedPath);
|
||||||
} else if (platform === 'darwin') {
|
} else if (platform === 'darwin') {
|
||||||
console.log('没有mac,暂未测试');
|
info('没有mac,暂未测试');
|
||||||
} else {
|
} else {
|
||||||
console.log(`https://golang.google.cn/dl/go${goVersion}.linux-amd64.tar.gz`);
|
info(`https://golang.google.cn/dl/go${goVersion}.linux-amd64.tar.gz`);
|
||||||
|
|
||||||
const goPath = await downloadTool(
|
const goPath = await downloadTool(
|
||||||
`https://golang.google.cn/dl/go${goVersion}.linux-amd64.tar.gz`
|
`https://golang.google.cn/dl/go${goVersion}.linux-amd64.tar.gz`
|
||||||
);
|
);
|
||||||
const goExtractedFolder = await extractTar(goPath, './cache/go');
|
const goExtractedFolder = await extractTar(goPath, './cache/go');
|
||||||
|
|
||||||
const cachedPath = await cacheDir(join(goExtractedFolder, 'go'), 'go', goVersion);
|
const cachedPath = await cacheDir(join(goExtractedFolder, 'go'), 'go', goVersion);
|
||||||
addPath(cachedPath);
|
addPath(cachedPath);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
setFailed(JSON.stringify(error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { downloadTool, extractZip, extractTar, extractXar, cacheDir } from '@actions/tool-cache';
|
import { downloadTool, extractZip, extractTar, extractXar, cacheDir } from '@actions/tool-cache';
|
||||||
import { addPath, getInput, setOutput } from '@actions/core';
|
import { addPath, getInput, setOutput, setFailed, info } from '@actions/core';
|
||||||
import { arch, platform as Platform } from 'os';
|
import { arch, platform as Platform } from 'os';
|
||||||
import { existsSync, renameSync } from 'fs';
|
import { existsSync, renameSync } from 'fs';
|
||||||
import { nodeVersionAlias } from 'gitea-tool-cache-version-alias';
|
import { nodeVersionAlias } from 'gitea-tool-cache-version-alias';
|
||||||
@ -10,7 +10,7 @@ export async function nodeInstall() {
|
|||||||
const platform = Platform();
|
const platform = Platform();
|
||||||
const nodeVersion = getInput('node-version');
|
const nodeVersion = getInput('node-version');
|
||||||
if (!nodeVersion) {
|
if (!nodeVersion) {
|
||||||
console.log('没有node-version,跳过node安装');
|
info('没有node-version,跳过node安装');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const version = await nodeVersionAlias(nodeVersion, {
|
const version = await nodeVersionAlias(nodeVersion, {
|
||||||
@ -18,7 +18,8 @@ export async function nodeInstall() {
|
|||||||
}).catch(err => err);
|
}).catch(err => err);
|
||||||
|
|
||||||
if (version instanceof Error) {
|
if (version instanceof Error) {
|
||||||
console.log('node版本错误', version);
|
// console.error('node版本错误', version);
|
||||||
|
setFailed('node版本错误: ' + version);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,53 +27,57 @@ export async function nodeInstall() {
|
|||||||
process.env['RUNNER_TOOL_CACHE'] &&
|
process.env['RUNNER_TOOL_CACHE'] &&
|
||||||
existsSync(join(process.env['RUNNER_TOOL_CACHE'], 'node', version, arch()))
|
existsSync(join(process.env['RUNNER_TOOL_CACHE'], 'node', version, arch()))
|
||||||
) {
|
) {
|
||||||
console.log('node已经安装过了');
|
info('node已经安装过了');
|
||||||
|
|
||||||
return setOutput('node-version', version);
|
return setOutput('node-version', version);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (platform === 'win32') {
|
try {
|
||||||
console.log(
|
if (platform === 'win32') {
|
||||||
`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-win-${arch()}.zip`
|
info(
|
||||||
);
|
`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-win-${arch()}.zip`
|
||||||
|
);
|
||||||
|
|
||||||
const nodePath = await downloadTool(
|
const nodePath = await downloadTool(
|
||||||
`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-win-${arch()}.zip`
|
`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-win-${arch()}.zip`
|
||||||
);
|
);
|
||||||
|
|
||||||
renameSync(nodePath, nodePath + '.zip');
|
renameSync(nodePath, nodePath + '.zip');
|
||||||
|
|
||||||
const nodeExtractedFolder = await extractZip(nodePath + '.zip', './cache/node');
|
const nodeExtractedFolder = await extractZip(nodePath + '.zip', './cache/node');
|
||||||
const cachedPath = await cacheDir(
|
const cachedPath = await cacheDir(
|
||||||
join(nodeExtractedFolder, `node-v${version}-win-${arch()}`),
|
join(nodeExtractedFolder, `node-v${version}-win-${arch()}`),
|
||||||
'node',
|
'node',
|
||||||
version
|
version
|
||||||
);
|
);
|
||||||
addPath(cachedPath);
|
addPath(cachedPath);
|
||||||
setOutput('node-version', version);
|
setOutput('node-version', version);
|
||||||
} else if (platform === 'darwin') {
|
} else if (platform === 'darwin') {
|
||||||
console.log('没有mac,暂未测试');
|
info('没有mac,暂未测试');
|
||||||
|
|
||||||
// const nodePath = await downloadTool(
|
// const nodePath = await downloadTool(
|
||||||
// `https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}.pkg`
|
// `https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}.pkg`
|
||||||
// );
|
// );
|
||||||
// const nodeExtractedFolder = await extractXar(nodePath, './cache/node');
|
// const nodeExtractedFolder = await extractXar(nodePath, './cache/node');
|
||||||
} else {
|
} else {
|
||||||
console.log(
|
info(
|
||||||
`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-linux-${arch()}.tar.gz`
|
`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-linux-${arch()}.tar.gz`
|
||||||
);
|
);
|
||||||
|
|
||||||
const nodePath = await downloadTool(
|
const nodePath = await downloadTool(
|
||||||
`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-linux-${arch()}.tar.gz`
|
`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-linux-${arch()}.tar.gz`
|
||||||
);
|
);
|
||||||
const nodeExtractedFolder = await extractTar(nodePath, './cache/node');
|
const nodeExtractedFolder = await extractTar(nodePath, './cache/node');
|
||||||
|
|
||||||
const cachedPath = await cacheDir(
|
const cachedPath = await cacheDir(
|
||||||
join(nodeExtractedFolder, `node-v${version}-linux-${arch()}`),
|
join(nodeExtractedFolder, `node-v${version}-linux-${arch()}`),
|
||||||
'node',
|
'node',
|
||||||
version
|
version
|
||||||
);
|
);
|
||||||
addPath(cachedPath);
|
addPath(cachedPath);
|
||||||
setOutput('node-version', version);
|
setOutput('node-version', version);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
setFailed(JSON.stringify(error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user