diff --git a/README.md b/README.md index dfcf30d..c0fbc29 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,16 @@ with: actions-cache-folder: '.xmake-cache' ``` +Use action cache with cachekey: + +```yml +uses: xmake-io/github-action-setup-xmake@v1 +with: + xmake-version: '2.7.2' + actions-cache-folder: '.xmake-cache' + actions-cache-key: 'archlinux-ci' +``` + ## Contributing ### Prepare development environment diff --git a/action.yml b/action.yml index 64873f3..d604a01 100644 --- a/action.yml +++ b/action.yml @@ -13,6 +13,9 @@ inputs: actions-cache-folder: description: 'Directory to cache xmake in. This folder will go under $GITHUB_HOME (I.e. build dir) and be cached using @actions/cache.' default: '' + actions-cache-key: + description: 'Actions cache key.' + default: '' runs: using: 'node16' main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index a5844e6..620bb77 100644 --- a/dist/index.js +++ b/dist/index.js @@ -70848,10 +70848,14 @@ async function unixInstall(version) { var _a; let toolDir = ''; const actionsCacheFolder = core.getInput('actions-cache-folder'); + let actionsCacheKey = core.getInput('actions-cache-key'); + if (!actionsCacheKey) { + actionsCacheKey = ''; + } if (version.type !== 'local') { const ver = version.version; const sha = version.sha; - const cacheKey = `xmake-cache-${ver}-${sha}-${os.arch()}-${os.platform()}-${(_a = process.env.RUNNER_OS) !== null && _a !== void 0 ? _a : 'unknown'}`; + const cacheKey = `xmake-cache-${actionsCacheKey}-${ver}-${sha}-${os.arch()}-${os.platform()}-${(_a = process.env.RUNNER_OS) !== null && _a !== void 0 ? _a : 'unknown'}`; if (actionsCacheFolder && process.env.GITHUB_WORKSPACE) { const fullCachePath = path.join(process.env.GITHUB_WORKSPACE, actionsCacheFolder); try { diff --git a/src/unix-install.ts b/src/unix-install.ts index 0379a6d..2364915 100644 --- a/src/unix-install.ts +++ b/src/unix-install.ts @@ -18,11 +18,15 @@ async function install(sourceDir: string, binDir: string): Promise { export async function unixInstall(version: Version): Promise { let toolDir = ''; const actionsCacheFolder = core.getInput('actions-cache-folder'); + let actionsCacheKey = core.getInput('actions-cache-key'); + if (!actionsCacheKey) { + actionsCacheKey = ''; + } if (version.type !== 'local') { const ver = version.version; const sha = version.sha; - const cacheKey = `xmake-cache-${ver}-${sha}-${os.arch()}-${os.platform()}-${ + const cacheKey = `xmake-cache-${actionsCacheKey}-${ver}-${sha}-${os.arch()}-${os.platform()}-${ process.env.RUNNER_OS ?? 'unknown' }`;