add cleanup

This commit is contained in:
ruki
2025-01-14 22:46:17 +08:00
Unverified
parent 108ce5c1dc
commit e9d2675405
3 changed files with 17 additions and 27 deletions
+17 -1
View File
@@ -2,6 +2,7 @@ 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';
@@ -27,4 +28,19 @@ async function run(): Promise<void> {
}
}
run().catch((e: Error) => core.error(e));
async function cleanup(): Promise<void> {
try {
core.info(`cleanup`);
} 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));
}