Skip to content

Commit

Permalink
Add an entry to the registry once the Cygwin cache is restored
Browse files Browse the repository at this point in the history
Signed-off-by: Sora Morimoto <[email protected]>
  • Loading branch information
smorimoto committed Jun 22, 2024
1 parent a5b9017 commit 2e1591d
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ and this project adheres to

## [unreleased]

### Fixed

- Add an entry to the registry once the Cygwin cache is restored.

## [3.0.0-alpha]

### Added
Expand Down
21 changes: 21 additions & 0 deletions dist/index.js

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

3 changes: 3 additions & 0 deletions dist/post/index.js

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

5 changes: 4 additions & 1 deletion packages/setup-ocaml/src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from "./constants.js";
import { getLatestOpamRelease } from "./opam.js";
import { resolveCompiler } from "./version.js";
import { getCygwinVersion } from "./windows.js";
import { addCygwinReg, getCygwinVersion } from "./windows.js";

async function composeCygwinCacheKeys() {
const cygwinVersion = await getCygwinVersion();
Expand Down Expand Up @@ -151,6 +151,9 @@ async function restoreCygwinCache() {
const { key, restoreKeys } = await composeCygwinCacheKeys();
const paths = composeCygwinCachePaths();
const cacheKey = await restoreCache(key, restoreKeys, paths);
if (cacheKey) {
await addCygwinReg();
}
return cacheKey;
}

Expand Down
19 changes: 19 additions & 0 deletions packages/setup-ocaml/src/windows.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as path from "node:path";
import * as core from "@actions/core";
import { exec } from "@actions/exec";
import { HttpClient } from "@actions/http-client";
Expand Down Expand Up @@ -74,3 +75,21 @@ export async function setupCygwin() {
await io.cp(setup, CYGWIN_ROOT);
});
}

export async function addCygwinReg() {
const keyname = path.join("HKLM", "SOFTWARE", "Cygwin", "setup");
const valuename = "rootdir";
const datatype = "REG_SZ";
const data = CYGWIN_ROOT;
await exec("reg", [
"add",
keyname,
"/v",
valuename,
"/t",
datatype,
"/d",
data,
"/f",
]);
}

0 comments on commit 2e1591d

Please sign in to comment.