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