cache packages

This commit is contained in:
ruki
2025-01-15 22:52:03 +08:00
Unverified
parent 34c67d4e2d
commit 0bcef0bc62
2 changed files with 87762 additions and 17 deletions
+87747
View File
File diff suppressed because one or more lines are too long
+11 -13
View File
@@ -1,5 +1,5 @@
import * as core from '@actions/core';
import { exec } from '@actions/exec';
import { exec, ExecOptions } from '@actions/exec';
import * as io from '@actions/io';
import * as cache from '@actions/cache';
import * as os from 'os';
@@ -12,20 +12,19 @@ function getPackageCacheKey(): string {
if (!packageCacheKey) {
packageCacheKey = '';
}
return `xmake-package-cache-${packageCacheKey}-${os.arch()}-${os.platform()}-${
process.env.RUNNER_OS ?? 'unknown'
}`;
return `xmake-package-cache-${packageCacheKey}-${os.arch()}-${os.platform()}-${process.env.RUNNER_OS ?? 'unknown'}`;
}
async function getPackageCachePath(): Promise<string> {
let packageCachePath = "";
await exec('xmake l core.package.package.installdir', (error: Error | null, stdout: string, stderr: string) => {
if (error) {
core.info(`exec error: ${error}`);
return;
}
packageCachePath = stdout;
});
let packageCachePath = '';
const options: ExecOptions = {};
options.listeners = {
stdout: (data: Buffer) => {
packageCachePath += data.toString();
},
stderr: (data: Buffer) => {},
};
await exec('xmake', ['l', 'core.package.package.installdir'], options);
core.info(`packageCachePath: ${packageCachePath}`);
return packageCachePath;
}
@@ -88,4 +87,3 @@ export async function savePackageCache(): Promise<void> {
await cache.saveCache([packageCacheFolder], packageCacheKey);
}
}