diff --git a/README.md b/README.md index 79884f3..1f6cc90 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ jobs: ## Version Support -**GHC on Mac/Ubuntu:** +**GHC:** - `latest` (default, recommended) - `8.10.1` `8.10` @@ -141,15 +141,6 @@ jobs: - `8.0.2` `8.0` - `7.10.3` `7.10` -**GHC on Windows:** - -- `latest` (default, recommended) -- `8.10.2.2` -- `8.10.1.1` -- `8.8.4.1` -- `8.8.3.2` -- `8.8.2.1` - Suggestion: Try to support the three latest major versions of GHC. **Cabal:** diff --git a/dist/index.js b/dist/index.js index 579ed8a..0f6f063 100644 --- a/dist/index.js +++ b/dist/index.js @@ -877,7 +877,7 @@ const supported_versions = __importStar(__webpack_require__(447)); function getDefaults() { const inpts = js_yaml_1.safeLoad(fs_1.readFileSync(__webpack_require__.ab + "action.yml", 'utf8')).inputs; const mkVersion = (v, vs) => ({ - version: resolve(inpts[v].default, vs, v), + version: resolve(inpts[v].default, vs), supported: vs }); return { @@ -887,12 +887,8 @@ function getDefaults() { }; } exports.getDefaults = getDefaults; -function resolve(version, supported, type) { +function resolve(version, supported) { var _a; - // Hard code default windows version to get around ghc-choco using the old add-path commands. Other cli tools don't have this issue and don't have the 8.10.2.2 version - if (process.platform === 'win32' && type === 'ghc-version') { - return '8.10.2.2'; - } return version === 'latest' ? supported[0] : (_a = supported.find(v => v.startsWith(version))) !== null && _a !== void 0 ? _a : version; @@ -919,17 +915,17 @@ function getOpts({ ghc, cabal, stack }) { const opts = { ghc: { raw: verInpt.ghc, - resolved: resolve(verInpt.ghc, ghc.supported, 'ghc-version'), + resolved: resolve(verInpt.ghc, ghc.supported), enable: !stackNoGlobal }, cabal: { raw: verInpt.cabal, - resolved: resolve(verInpt.cabal, cabal.supported, 'cabal-version'), + resolved: resolve(verInpt.cabal, cabal.supported), enable: !stackNoGlobal }, stack: { raw: verInpt.stack, - resolved: resolve(verInpt.stack, stack.supported, 'stack-version)'), + resolved: resolve(verInpt.stack, stack.supported), enable: stackEnable, setup: core.getInput('stack-setup-ghc') !== '' } @@ -4291,7 +4287,7 @@ function escapeProperty(s) { /***/ 447: /***/ (function(module) { -module.exports = {"ghc":["8.10.2","8.10.2.2","8.10.1","8.10.1.1","8.8.4","8.8.4.1","8.8.3","8.8.3.2","8.8.2","8.8.2.1","8.8.1","8.6.5","8.6.4","8.6.3","8.6.2","8.6.1","8.4.4","8.4.3","8.4.2","8.4.1","8.2.2","8.0.2","7.10.3"],"cabal":["3.2.0.0","3.0.0.0","2.4.1.0","2.4.0.0","2.2.0.0"],"stack":["2.3.1","2.1.3","2.1.1","1.9.3","1.9.1","1.7.1","1.6.5","1.6.3","1.6.1","1.5.1","1.5.0","1.4.0","1.3.2","1.3.0","1.2.0"]}; +module.exports = {"ghc":["8.10.2","8.10.1","8.8.4","8.8.3","8.8.2","8.8.1","8.6.5","8.6.4","8.6.3","8.6.2","8.6.1","8.4.4","8.4.3","8.4.2","8.4.1","8.2.2","8.0.2","7.10.3"],"cabal":["3.2.0.0","3.0.0.0","2.4.1.0","2.4.0.0","2.2.0.0"],"stack":["2.3.1","2.1.3","2.1.1","1.9.3","1.9.1","1.7.1","1.6.5","1.6.3","1.6.1","1.5.1","1.5.0","1.4.0","1.3.2","1.3.0","1.2.0"]}; /***/ }), @@ -11171,6 +11167,8 @@ async function apt(tool, version) { } async function choco(tool, version) { core.info(`Attempting to install ${tool} ${version} using chocolatey`); + // Choco tries to invoke `add-path` command on earlier versions of ghc, which has been deprecated and fails the step, so disable command execution during this. + console.log('::stop-commands::SetupHaskellStopCommands'); await exec_1.exec('powershell', [ 'choco', 'install', @@ -11183,8 +11181,11 @@ async function choco(tool, version) { ], { ignoreReturnCode: true }); - // Add to path automatically because it does not add until the end of the step. - core.addPath(getChocoPath(tool, version)); + console.log('::SetupHaskellStopCommands::'); // Re-enable command execution + // Add GHC to path automatically because it does not add until the end of the step and we check the path. + if (tool == 'ghc') { + core.addPath(getChocoPath(tool, version)); + } } async function ghcupBin(os) { const v = '0.1.8'; diff --git a/src/installer.ts b/src/installer.ts index f1cb85f..e7b4400 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -162,7 +162,8 @@ async function apt(tool: Tool, version: string): Promise { async function choco(tool: Tool, version: string): Promise { core.info(`Attempting to install ${tool} ${version} using chocolatey`); - + // Choco tries to invoke `add-path` command on earlier versions of ghc, which has been deprecated and fails the step, so disable command execution during this. + console.log('::stop-commands::SetupHaskellStopCommands'); await exec( 'powershell', [ @@ -179,8 +180,11 @@ async function choco(tool: Tool, version: string): Promise { ignoreReturnCode: true } ); - // Add to path automatically because it does not add until the end of the step. - core.addPath(getChocoPath(tool, version)); + console.log('::SetupHaskellStopCommands::'); // Re-enable command execution + // Add GHC to path automatically because it does not add until the end of the step and we check the path. + if (tool == 'ghc') { + core.addPath(getChocoPath(tool, version)); + } } async function ghcupBin(os: OS): Promise { diff --git a/src/opts.ts b/src/opts.ts index ed4a06e..24ee1eb 100644 --- a/src/opts.ts +++ b/src/opts.ts @@ -28,7 +28,7 @@ export function getDefaults(): Defaults { ).inputs; const mkVersion = (v: string, vs: string[]): Version => ({ - version: resolve(inpts[v].default, vs, v), + version: resolve(inpts[v].default, vs), supported: vs }); @@ -39,11 +39,7 @@ export function getDefaults(): Defaults { }; } -function resolve(version: string, supported: string[], type: string): string { - // Hard code default windows version to get around ghc-choco using the old add-path commands. Other cli tools don't have this issue and don't have the 8.10.2.2 version - if (process.platform === 'win32' && type === 'ghc-version') { - return '8.10.2.2'; - } +function resolve(version: string, supported: string[]): string { return version === 'latest' ? supported[0] : supported.find(v => v.startsWith(version)) ?? version; @@ -75,17 +71,17 @@ export function getOpts({ghc, cabal, stack}: Defaults): Options { const opts: Options = { ghc: { raw: verInpt.ghc, - resolved: resolve(verInpt.ghc, ghc.supported, 'ghc-version'), + resolved: resolve(verInpt.ghc, ghc.supported), enable: !stackNoGlobal }, cabal: { raw: verInpt.cabal, - resolved: resolve(verInpt.cabal, cabal.supported, 'cabal-version'), + resolved: resolve(verInpt.cabal, cabal.supported), enable: !stackNoGlobal }, stack: { raw: verInpt.stack, - resolved: resolve(verInpt.stack, stack.supported, 'stack-version)'), + resolved: resolve(verInpt.stack, stack.supported), enable: stackEnable, setup: core.getInput('stack-setup-ghc') !== '' } diff --git a/src/versions.json b/src/versions.json index 57282fc..8219fd3 100644 --- a/src/versions.json +++ b/src/versions.json @@ -1,15 +1,10 @@ { "ghc": [ "8.10.2", - "8.10.2.2", "8.10.1", - "8.10.1.1", "8.8.4", - "8.8.4.1", "8.8.3", - "8.8.3.2", "8.8.2", - "8.8.2.1", "8.8.1", "8.6.5", "8.6.4",