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
-20
View File
@@ -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
-6
View File
@@ -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'
+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));
}