Files
github-action-setup-xmake/src/index.ts
T
2025-01-14 22:52:45 +08:00

44 lines
1.2 KiB
TypeScript

import * as core from '@actions/core';
import { exec } from '@actions/exec';
import * as os from 'os';
import { selectVersion } from './versions';
import * as stateHelper from './state-helper';
import { winInstall } from './win-install';
import { unixInstall } from './unix-install';
async function cacheBuild(): Promise<void> {}
async function cachePackages(): Promise<void> {}
async function run(): Promise<void> {
try {
const version = await selectVersion();
if (os.platform() === 'win32' || os.platform() === 'cygwin') {
const latest = await selectVersion('latest');
await winInstall(version, latest);
} else {
await unixInstall(version);
}
await exec('xmake --root --version');
} catch (error) {
const ex = error as Error;
core.setFailed(ex.message);
}
}
async function cleanup(): Promise<void> {
try {
core.info(`cleanup`);
await cacheBuild();
} catch (error) {
const ex = error as Error;
core.setFailed(ex.message);
}
}
if (!stateHelper.IsPost) {
run().catch((e: Error) => core.error(e));
} else {
cleanup().catch((e: Error) => core.error(e));
}