Skip to content

Commit

Permalink
fix: macos version detection (#25)
Browse files Browse the repository at this point in the history
- Fix macOS version detection (RUNNER_OS is `macOS`, not `MacOS`)
- Add the runner arch to the cache key.

Closes #24
  • Loading branch information
baptiste0928 committed Apr 10, 2024
1 parent 94e1849 commit 27f4605
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Runner arch is included in the cache key.

### Fixed

- Fix runner os version resolution on macOS runners. (issue #24)

## [3.0.1] - 2024-03-08

### Fixed
Expand Down
9 changes: 5 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function getOsVersion(): Promise<string | undefined> {
return match?.[1];
}

if (runnerOs === 'MacOS') {
if (runnerOs === 'macOS') {
const output = await exec.getExecOutput('sw_vers', ['-productVersion'], {
silent: true,
});
Expand All @@ -77,15 +77,20 @@ async function getCacheKey(
version: ResolvedVersion,
): Promise<string> {
const runnerOs = process.env.RUNNER_OS;
const runnerArch = process.env.RUNNER_ARCH;
const jobId = process.env.GITHUB_JOB;
const osVersion = await getOsVersion();

if (runnerOs === undefined || jobId === undefined) {
core.setFailed('Could not determine runner OS or job ID');
if (
runnerOs === undefined ||
runnerArch === undefined ||
jobId === undefined
) {
core.setFailed('Could not determine runner OS, runner arch or job ID');
process.exit(1);
}

let hashKey = jobId + runnerOs + (osVersion ?? '');
let hashKey = jobId + runnerOs + runnerArch + (osVersion ?? '');

hashKey += input.source.type;
if (input.source.type === 'registry') {
Expand Down

0 comments on commit 27f4605

Please sign in to comment.