mirror of
https://gitea.com/kongxiangyiren/gitea-tool-cache.git
synced 2025-10-23 03:44:44 +08:00
添加mac环境
This commit is contained in:
@ -4,9 +4,7 @@
|
||||
|
||||
1、go 和 dotnet 需要指定具体版本号
|
||||
|
||||
2、因为我没有 mac,所以没有 mac 环境
|
||||
|
||||
3、如果你想让 go 和 dotnet 支持版本号别名,欢迎 [pr](https://github.com/kongxiangyiren/version-alias)
|
||||
2、如果你想让 go 和 dotnet 支持版本号别名,欢迎 [pr](https://github.com/kongxiangyiren/version-alias)
|
||||
|
||||
## Usage
|
||||
|
||||
|
@ -47,20 +47,20 @@ describe('gitea-tool-cache', () => {
|
||||
}, 200000);
|
||||
|
||||
// 测试时需要把别的注释掉
|
||||
it('installs windows', async () => {
|
||||
// rmSync('./cache', { recursive: true, force: true });
|
||||
os['platform'] = 'win32';
|
||||
os['arch'] = 'x64';
|
||||
// node
|
||||
inputs['node-version'] = '18';
|
||||
await nodeInstall();
|
||||
// // go
|
||||
// inputs['go-version'] = '1.21.1';
|
||||
// await goInstall();
|
||||
// dotnet
|
||||
// inputs['dotnet-version'] = '6.0.100';
|
||||
// await dotnetInstall();
|
||||
});
|
||||
// it('installs windows', async () => {
|
||||
// // rmSync('./cache', { recursive: true, force: true });
|
||||
// os['platform'] = 'win32';
|
||||
// os['arch'] = 'x64';
|
||||
// // node
|
||||
// inputs['node-version'] = '18';
|
||||
// await nodeInstall();
|
||||
// // // go
|
||||
// // inputs['go-version'] = '1.21.1';
|
||||
// // await goInstall();
|
||||
// // dotnet
|
||||
// // inputs['dotnet-version'] = '6.0.100';
|
||||
// // await dotnetInstall();
|
||||
// });
|
||||
|
||||
// it('installs linux', async () => {
|
||||
// // rmSync('./cache', { recursive: true, force: true });
|
||||
@ -74,14 +74,27 @@ describe('gitea-tool-cache', () => {
|
||||
// await dotnetInstall();
|
||||
// });
|
||||
|
||||
// it('installs darwin', async () => {
|
||||
// it('installs darwin x64', async () => {
|
||||
// // rmSync('./cache', { recursive: true, force: true });
|
||||
// os['platform'] = 'darwin';
|
||||
// os['arch'] = 'x64';
|
||||
// inputs['node-version'] = '18.18.0';
|
||||
// await nodeInstall();
|
||||
// inputs['go-version'] = '1.21.1';
|
||||
// await goInstall();
|
||||
// // inputs['node-version'] = '18.18.0';
|
||||
// // await nodeInstall();
|
||||
// // inputs['go-version'] = '1.21.1';
|
||||
// // await goInstall();
|
||||
// inputs['dotnet-version'] = '5.0.401';
|
||||
// await dotnetInstall();
|
||||
// });
|
||||
|
||||
it('installs darwin arm64', async () => {
|
||||
rmSync('./cache', { recursive: true, force: true });
|
||||
os['platform'] = 'darwin';
|
||||
os['arch'] = 'arm64';
|
||||
// inputs['node-version'] = '18.18.0';
|
||||
// await nodeInstall();
|
||||
// inputs['go-version'] = '1.21.1';
|
||||
// await goInstall();
|
||||
inputs['dotnet-version'] = '6.0.422';
|
||||
await dotnetInstall();
|
||||
});
|
||||
});
|
||||
|
33
dist/index.js
vendored
33
dist/index.js
vendored
@ -49507,7 +49507,7 @@ async function dotnetInstall() {
|
||||
return item.rid === 'win-' + (0, os_1.arch)() && item.url.endsWith('.zip');
|
||||
}
|
||||
else if (platform === 'darwin') {
|
||||
return item.rid === 'osx-' + (0, os_1.arch)() && item.url.endsWith('.pkg');
|
||||
return item.rid === 'osx-' + (0, os_1.arch)() && item.url.endsWith('.tar.gz');
|
||||
}
|
||||
else {
|
||||
return item.rid === 'linux-' + (0, os_1.arch)() && item.url.endsWith('.tar.gz');
|
||||
@ -49527,7 +49527,10 @@ async function dotnetInstall() {
|
||||
(0, core_1.setOutput)('dotnet-path', cachedPath);
|
||||
}
|
||||
else if (platform === 'darwin') {
|
||||
(0, core_1.info)('没有mac,暂未测试');
|
||||
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 {
|
||||
const dotnetExtractedFolder = await (0, tool_cache_1.extractTar)(dotnetPath, './cache/dotnet');
|
||||
@ -49570,21 +49573,26 @@ async function goInstall() {
|
||||
(0, core_1.info)('go已经安装过了');
|
||||
return;
|
||||
}
|
||||
const archD = (0, os_1.arch)() === 'x64' ? 'amd64' : (0, os_1.arch)();
|
||||
try {
|
||||
if (platform === 'win32') {
|
||||
(0, core_1.info)(`https://golang.google.cn/dl/go${goVersion}.windows-amd64.zip`);
|
||||
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-${archD}.zip`);
|
||||
const goPath = await (0, tool_cache_1.downloadTool)(`https://golang.google.cn/dl/go${goVersion}.windows-${archD}.zip`);
|
||||
(0, fs_1.renameSync)(goPath, goPath + '.zip');
|
||||
const goExtractedFolder = await (0, tool_cache_1.extractZip)(goPath + '.zip', './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') {
|
||||
(0, core_1.info)('没有mac,暂未测试');
|
||||
(0, core_1.info)(`https://golang.google.cn/dl/go${goVersion}.darwin-${archD}.tar.gz`);
|
||||
const goPath = await (0, tool_cache_1.downloadTool)(`https://golang.google.cn/dl/go${goVersion}.darwin-${archD}.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 {
|
||||
(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`);
|
||||
(0, core_1.info)(`https://golang.google.cn/dl/go${goVersion}.linux-${archD}.tar.gz`);
|
||||
const goPath = await (0, tool_cache_1.downloadTool)(`https://golang.google.cn/dl/go${goVersion}.linux-${archD}.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);
|
||||
@ -49671,11 +49679,12 @@ async function nodeInstall() {
|
||||
(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');
|
||||
(0, core_1.info)(`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-darwin-${(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}-darwin-${(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}-darwin-${(0, os_1.arch)()}`), 'node', version);
|
||||
(0, core_1.addPath)(cachedPath);
|
||||
(0, core_1.setOutput)('node-version', version);
|
||||
}
|
||||
else {
|
||||
(0, core_1.info)(`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-linux-${(0, os_1.arch)()}.tar.gz`);
|
||||
|
@ -1,11 +1,4 @@
|
||||
import {
|
||||
downloadTool,
|
||||
extractZip,
|
||||
extractTar,
|
||||
extractXar,
|
||||
cacheDir,
|
||||
find
|
||||
} from '@actions/tool-cache';
|
||||
import { downloadTool, extractZip, extractTar, cacheDir, find } from '@actions/tool-cache';
|
||||
import { addPath, getInput, setOutput, info, setFailed, error } from '@actions/core';
|
||||
import { arch, platform as Platform } from 'os';
|
||||
import { renameSync } from 'fs';
|
||||
@ -49,7 +42,7 @@ export async function dotnetInstall() {
|
||||
if (platform === 'win32') {
|
||||
return item.rid === 'win-' + arch() && item.url.endsWith('.zip');
|
||||
} else if (platform === 'darwin') {
|
||||
return item.rid === 'osx-' + arch() && item.url.endsWith('.pkg');
|
||||
return item.rid === 'osx-' + arch() && item.url.endsWith('.tar.gz');
|
||||
} else {
|
||||
return item.rid === 'linux-' + arch() && item.url.endsWith('.tar.gz');
|
||||
}
|
||||
@ -69,7 +62,10 @@ export async function dotnetInstall() {
|
||||
addPath(cachedPath);
|
||||
setOutput('dotnet-path', cachedPath);
|
||||
} else if (platform === 'darwin') {
|
||||
info('没有mac,暂未测试');
|
||||
const dotnetExtractedFolder = await extractTar(dotnetPath, './cache/dotnet');
|
||||
const cachedPath = await cacheDir(dotnetExtractedFolder, 'dotnet', dotnetVersion);
|
||||
addPath(cachedPath);
|
||||
setOutput('dotnet-path', cachedPath);
|
||||
} else {
|
||||
const dotnetExtractedFolder = await extractTar(dotnetPath, './cache/dotnet');
|
||||
const cachedPath = await cacheDir(dotnetExtractedFolder, 'dotnet', dotnetVersion);
|
||||
|
@ -1,12 +1,5 @@
|
||||
import { join } from 'path';
|
||||
import {
|
||||
downloadTool,
|
||||
extractZip,
|
||||
extractTar,
|
||||
extractXar,
|
||||
cacheDir,
|
||||
find
|
||||
} from '@actions/tool-cache';
|
||||
import { downloadTool, extractZip, extractTar, cacheDir, find } from '@actions/tool-cache';
|
||||
import { addPath, getInput, info, setFailed } from '@actions/core';
|
||||
import { arch, platform as Platform } from 'os';
|
||||
import { renameSync } from 'fs';
|
||||
@ -26,25 +19,34 @@ export async function goInstall() {
|
||||
info('go已经安装过了');
|
||||
return;
|
||||
}
|
||||
const archD = arch() === 'x64' ? 'amd64' : arch();
|
||||
|
||||
try {
|
||||
if (platform === 'win32') {
|
||||
info(`https://golang.google.cn/dl/go${goVersion}.windows-amd64.zip`);
|
||||
info(`https://golang.google.cn/dl/go${goVersion}.windows-${archD}.zip`);
|
||||
|
||||
const goPath = await downloadTool(
|
||||
`https://golang.google.cn/dl/go${goVersion}.windows-amd64.zip`
|
||||
`https://golang.google.cn/dl/go${goVersion}.windows-${archD}.zip`
|
||||
);
|
||||
renameSync(goPath, goPath + '.zip');
|
||||
const goExtractedFolder = await extractZip(goPath + '.zip', './cache/go');
|
||||
const cachedPath = await cacheDir(join(goExtractedFolder, 'go'), 'go', goVersion);
|
||||
addPath(cachedPath);
|
||||
} else if (platform === 'darwin') {
|
||||
info('没有mac,暂未测试');
|
||||
} else {
|
||||
info(`https://golang.google.cn/dl/go${goVersion}.linux-amd64.tar.gz`);
|
||||
info(`https://golang.google.cn/dl/go${goVersion}.darwin-${archD}.tar.gz`);
|
||||
|
||||
const goPath = await downloadTool(
|
||||
`https://golang.google.cn/dl/go${goVersion}.linux-amd64.tar.gz`
|
||||
`https://golang.google.cn/dl/go${goVersion}.darwin-${archD}.tar.gz`
|
||||
);
|
||||
const goExtractedFolder = await extractTar(goPath, './cache/go');
|
||||
|
||||
const cachedPath = await cacheDir(join(goExtractedFolder, 'go'), 'go', goVersion);
|
||||
addPath(cachedPath);
|
||||
} else {
|
||||
info(`https://golang.google.cn/dl/go${goVersion}.linux-${archD}.tar.gz`);
|
||||
|
||||
const goPath = await downloadTool(
|
||||
`https://golang.google.cn/dl/go${goVersion}.linux-${archD}.tar.gz`
|
||||
);
|
||||
const goExtractedFolder = await extractTar(goPath, './cache/go');
|
||||
|
||||
|
@ -1,12 +1,5 @@
|
||||
import { join } from 'path';
|
||||
import {
|
||||
downloadTool,
|
||||
extractZip,
|
||||
extractTar,
|
||||
extractXar,
|
||||
cacheDir,
|
||||
find
|
||||
} from '@actions/tool-cache';
|
||||
import { downloadTool, extractZip, extractTar, cacheDir, find } from '@actions/tool-cache';
|
||||
import { addPath, getInput, setOutput, setFailed, info } from '@actions/core';
|
||||
import { arch, platform as Platform } from 'os';
|
||||
import { renameSync } from 'fs';
|
||||
@ -58,12 +51,22 @@ export async function nodeInstall() {
|
||||
addPath(cachedPath);
|
||||
setOutput('node-version', version);
|
||||
} else if (platform === 'darwin') {
|
||||
info('没有mac,暂未测试');
|
||||
info(
|
||||
`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-darwin-${arch()}.tar.gz`
|
||||
);
|
||||
|
||||
// const nodePath = await downloadTool(
|
||||
// `https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}.pkg`
|
||||
// );
|
||||
// const nodeExtractedFolder = await extractXar(nodePath, './cache/node');
|
||||
const nodePath = await downloadTool(
|
||||
`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-darwin-${arch()}.tar.gz`
|
||||
);
|
||||
const nodeExtractedFolder = await extractTar(nodePath, './cache/node');
|
||||
|
||||
const cachedPath = await cacheDir(
|
||||
join(nodeExtractedFolder, `node-v${version}-darwin-${arch()}`),
|
||||
'node',
|
||||
version
|
||||
);
|
||||
addPath(cachedPath);
|
||||
setOutput('node-version', version);
|
||||
} else {
|
||||
info(
|
||||
`https://registry.npmmirror.com/-/binary/node/v${version}/node-v${version}-linux-${arch()}.tar.gz`
|
||||
|
Reference in New Issue
Block a user