Skip to content

Commit d57bb2f

Browse files
committed
new: Install in workspace root.
1 parent b544ee3 commit d57bb2f

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.3.2
2+
3+
- Auto-install will now run in the `workspace-root` if defined.
4+
15
# 0.3.1
26

37
- moon can be forced installed by setting `moon-version`, instead of relying on file detection.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
3030
## Inputs
3131
32-
- `auto-install` - Auto-install tools on setup. Defaults to `false`.
32+
- `auto-install` - Auto-install tools from the root `.prototools` on setup. Defaults to `false`.
3333
- `cache` - Toggle caching of the toolchain directory. Defaults to `true`.
3434
- `cache-base` - Base branch/ref to save a warmup cache on. Other branches/refs will restore from
3535
this base.

helpers.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,18 @@ export function getWorkingDir() {
4646
return process.env.GITHUB_WORKSPACE ?? process.cwd();
4747
}
4848

49+
export function getWorkspaceRoot() {
50+
return path.join(getWorkingDir(), core.getInput('workspace-root'));
51+
}
52+
4953
export function isCacheEnabled() {
5054
return core.getBooleanInput('cache') && cache.isFeatureAvailable();
5155
}
5256

5357
export function isUsingMoon() {
5458
return (
5559
!!core.getInput('moon-version') ||
56-
fs.existsSync(path.join(getWorkingDir(), core.getInput('workspace-root'), '.moon'))
60+
fs.existsSync(path.join(getWorkspaceRoot(), '.moon'))
5761
);
5862
}
5963

index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
getToolchainCacheKey,
1010
getToolsDir,
1111
getUidFile,
12+
getWorkspaceRoot,
1213
installBin,
1314
isCacheEnabled,
1415
isUsingMoon,
@@ -61,7 +62,7 @@ async function run() {
6162
if (core.getBooleanInput('auto-install')) {
6263
core.info('Auto-installing tools');
6364

64-
await execa('proto', ['use'], { stdio: 'inherit' });
65+
await execa('proto', ['use'], { cwd: getWorkspaceRoot(), stdio: 'inherit' });
6566
}
6667
} catch (error: unknown) {
6768
core.setFailed(error as Error);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@moonrepo/setup-toolchain",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"description": "A GitHub action to setup and cache the proto and moon toolchains.",
55
"main": "dist/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)