Skip to content

Commit

Permalink
new: Install in workspace root.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Oct 16, 2024
1 parent b544ee3 commit d57bb2f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.3.2

- Auto-install will now run in the `workspace-root` if defined.

# 0.3.1

- moon can be forced installed by setting `moon-version`, instead of relying on file detection.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
## Inputs
- `auto-install` - Auto-install tools on setup. Defaults to `false`.
- `auto-install` - Auto-install tools from the root `.prototools` on setup. Defaults to `false`.
- `cache` - Toggle caching of the toolchain directory. Defaults to `true`.
- `cache-base` - Base branch/ref to save a warmup cache on. Other branches/refs will restore from
this base.
Expand Down
6 changes: 5 additions & 1 deletion helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ export function getWorkingDir() {
return process.env.GITHUB_WORKSPACE ?? process.cwd();
}

export function getWorkspaceRoot() {
return path.join(getWorkingDir(), core.getInput('workspace-root'));
}

export function isCacheEnabled() {
return core.getBooleanInput('cache') && cache.isFeatureAvailable();
}

export function isUsingMoon() {
return (
!!core.getInput('moon-version') ||
fs.existsSync(path.join(getWorkingDir(), core.getInput('workspace-root'), '.moon'))
fs.existsSync(path.join(getWorkspaceRoot(), '.moon'))
);
}

Expand Down
3 changes: 2 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
getToolchainCacheKey,
getToolsDir,
getUidFile,
getWorkspaceRoot,
installBin,
isCacheEnabled,
isUsingMoon,
Expand Down Expand Up @@ -61,7 +62,7 @@ async function run() {
if (core.getBooleanInput('auto-install')) {
core.info('Auto-installing tools');

await execa('proto', ['use'], { stdio: 'inherit' });
await execa('proto', ['use'], { cwd: getWorkspaceRoot(), stdio: 'inherit' });
}
} catch (error: unknown) {
core.setFailed(error as Error);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@moonrepo/setup-toolchain",
"version": "0.3.1",
"version": "0.3.2",
"description": "A GitHub action to setup and cache the proto and moon toolchains.",
"main": "dist/index.js",
"scripts": {
Expand Down

0 comments on commit d57bb2f

Please sign in to comment.