diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 871b51d..0e0182b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,6 +65,7 @@ jobs: crate: cargo-hack version: ^0.4.4 cache-key: test + shared-key: some-job - name: Install cargo-sort (from git) uses: ./ diff --git a/README.md b/README.md index 8aeaec2..a34fe01 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ unexpected dependencies updates. - `args`: Additional arguments to pass to `cargo install`. - `cache-key`: Additional string added to the cache key used to manually invalidate the cache. -- `shared-key`: A cache key that is used instead of the automatic `job`-based key, +- `shared-key`: A cache key that is used instead of the automatic `job`-based key, and is stable over multiple jobs. #### Git parameters diff --git a/dist/index.js b/dist/index.js index 49cb557..8d1caf4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -60504,7 +60504,7 @@ async function getCacheKey(input, version2) { core.setFailed("Could not determine runner OS, runner arch or job ID"); process.exit(1); } - let hashKey = jobId + runnerOs + runnerArch + (osVersion ?? ""); + let hashKey = (input.sharedKey || jobId) + runnerOs + runnerArch + (osVersion ?? ""); hashKey += input.source.type; if (input.source.type === "registry") { hashKey += input.source.registry ?? ""; @@ -60594,6 +60594,7 @@ function parseInput() { const locked = core2.getBooleanInput("locked", { required: false }); const args = core2.getInput("args", { required: false }); const cacheKey = core2.getInput("cache-key", { required: false }); + const sharedKey = core2.getInput("shared-key", { required: false }); const parsedArgs = parseArgsStringToArgv(args); const parsedFeatures = features.split(/[ ,]+/).filter(Boolean); if (locked) { @@ -60639,7 +60640,8 @@ function parseInput() { source, features: parsedFeatures, args: parsedArgs, - cacheKey + cacheKey, + sharedKey }; } diff --git a/src/install.ts b/src/install.ts index 58cbb61..62077f9 100644 --- a/src/install.ts +++ b/src/install.ts @@ -90,7 +90,8 @@ async function getCacheKey( process.exit(1); } - let hashKey = (input.sharedKey || jobId) + runnerOs + runnerArch + (osVersion ?? ''); + let hashKey = + (input.sharedKey || jobId) + runnerOs + runnerArch + (osVersion ?? ''); hashKey += input.source.type; if (input.source.type === 'registry') {