diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6ff2d6e..bbdb793 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,7 @@ jobs: steps: - uses: actions/checkout@v1 - - uses: xmake-io/github-action-setup-xmake@test + - uses: xmake-io/github-action-setup-xmake@cache with: xmake-version: ${{ matrix.version }} actions-cache-folder: '.xmake-cache' diff --git a/action.yml b/action.yml index ed962c1..1197cc9 100644 --- a/action.yml +++ b/action.yml @@ -32,3 +32,4 @@ inputs: runs: using: 'node20' main: 'dist/index.js' + post: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index 99d2222..dcdb80f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -87473,29 +87473,36 @@ const versions_1 = __nccwpck_require__(406); const stateHelper = __nccwpck_require__(8387); const win_install_1 = __nccwpck_require__(1612); const unix_install_1 = __nccwpck_require__(6689); -async function cacheBuild() { } -async function cachePackages() { } +async function installXmake() { + const version = await (0, versions_1.selectVersion)(); + if (os.platform() === 'win32' || os.platform() === 'cygwin') { + const latest = await (0, versions_1.selectVersion)('latest'); + await (0, win_install_1.winInstall)(version, latest); + } + else { + await (0, unix_install_1.unixInstall)(version); + } + await (0, exec_1.exec)('xmake --root --version'); +} +async function loadBuildCache() { } +async function loadPackagesCache() { } +async function saveBuildCache() { } +async function savePackagesCache() { } async function run() { try { - const version = await (0, versions_1.selectVersion)(); - if (os.platform() === 'win32' || os.platform() === 'cygwin') { - const latest = await (0, versions_1.selectVersion)('latest'); - await (0, win_install_1.winInstall)(version, latest); - } - else { - await (0, unix_install_1.unixInstall)(version); - } - await (0, exec_1.exec)('xmake --root --version'); + await installXmake(); + await loadBuildCache(); + await loadPackagesCache(); } catch (error) { const ex = error; core.setFailed(ex.message); } } -async function cleanup() { +async function saveCache() { try { - core.info(`cleanup`); - await cacheBuild(); + await saveBuildCache(); + await savePackagesCache(); } catch (error) { const ex = error; @@ -87506,7 +87513,7 @@ if (!stateHelper.IsPost) { run().catch((e) => core.error(e)); } else { - cleanup().catch((e) => core.error(e)); + saveCache().catch((e) => core.error(e)); } })(); diff --git a/src/index.ts b/src/index.ts index 72be8bc..ced2b33 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,30 +6,40 @@ import * as stateHelper from './state-helper'; import { winInstall } from './win-install'; import { unixInstall } from './unix-install'; -async function cacheBuild(): Promise {} +async function installXmake(): Promise { + 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'); +} -async function cachePackages(): Promise {} +async function loadBuildCache(): Promise {} + +async function loadPackagesCache(): Promise {} + +async function saveBuildCache(): Promise {} + +async function savePackagesCache(): Promise {} async function run(): Promise { 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'); + await installXmake(); + await loadBuildCache(); + await loadPackagesCache(); } catch (error) { const ex = error as Error; core.setFailed(ex.message); } } -async function cleanup(): Promise { +async function saveCache(): Promise { try { - core.info(`cleanup`); - await cacheBuild(); + await saveBuildCache(); + await savePackagesCache(); } catch (error) { const ex = error as Error; core.setFailed(ex.message); @@ -39,5 +49,5 @@ async function cleanup(): Promise { if (!stateHelper.IsPost) { run().catch((e: Error) => core.error(e)); } else { - cleanup().catch((e: Error) => core.error(e)); + saveCache().catch((e: Error) => core.error(e)); }