diff --git a/CHANGELOG.md b/CHANGELOG.md index e2345f3..bbb3da8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/README.md b/README.md index d83bf18..6651368 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/helpers.ts b/helpers.ts index 838851d..aec6b37 100644 --- a/helpers.ts +++ b/helpers.ts @@ -46,6 +46,10 @@ 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(); } @@ -53,7 +57,7 @@ export function isCacheEnabled() { export function isUsingMoon() { return ( !!core.getInput('moon-version') || - fs.existsSync(path.join(getWorkingDir(), core.getInput('workspace-root'), '.moon')) + fs.existsSync(path.join(getWorkspaceRoot(), '.moon')) ); } diff --git a/index.ts b/index.ts index 501b3be..57f561e 100644 --- a/index.ts +++ b/index.ts @@ -9,6 +9,7 @@ import { getToolchainCacheKey, getToolsDir, getUidFile, + getWorkspaceRoot, installBin, isCacheEnabled, isUsingMoon, @@ -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); diff --git a/package.json b/package.json index 6b21444..30b2f4d 100644 --- a/package.json +++ b/package.json @@ -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": {