From e9d2675405d3e1bf848f8ec1bd56bf0208f72494 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 14 Jan 2025 22:46:17 +0800 Subject: [PATCH] add cleanup --- README.md | 20 -------------------- action.yml | 6 ------ src/index.ts | 18 +++++++++++++++++- 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 5f5f161..6c40ad8 100644 --- a/README.md +++ b/README.md @@ -70,16 +70,6 @@ with: xmake-version: '2.9.7' package-cache-folder: '.xmake-package-cache' package-cache-key: 'archlinux-ci' - package-cache-status: 'load' - -- install packages -... - -uses: xmake-io/github-action-setup-xmake@v1 -with: - package-cache-folder: '.xmake-package-cache' - package-cache-key: 'archlinux-ci' - package-cache-status: 'save' ``` ### Cache build @@ -90,16 +80,6 @@ with: xmake-version: '2.9.7' build-cache-folder: '.xmake-build-cache' build-cache-key: 'archlinux-ci' - build-cache-status: 'load' - -- build project -... - -uses: xmake-io/github-action-setup-xmake@v1 -with: - build-cache-folder: '.xmake-build-cache' - build-cache-key: 'archlinux-ci' - build-cache-status: 'save' ``` ## Contributing diff --git a/action.yml b/action.yml index 2f584ba..ed962c1 100644 --- a/action.yml +++ b/action.yml @@ -22,18 +22,12 @@ inputs: package-cache-key: description: The packages cache key. default: '' - package-cache-status: - description: The packages cache status, e.g. load/save. - default: '' build-cache-folder: description: 'Directory to cache build artifacts in. This folder will go under $GITHUB_HOME (I.e. build dir) and be cached using @actions/cache.' default: '' build-cache-key: description: The build cache key. default: '' - build-cache-status: - description: The build cache status, e.g. load/save. - default: '' runs: using: 'node20' diff --git a/src/index.ts b/src/index.ts index a7bb0ed..ac31877 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 { } } -run().catch((e: Error) => core.error(e)); + +async function cleanup(): Promise { + 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)); +}