@@ -13276,6 +13276,7 @@ const core = __importStar(__nccwpck_require__(2186));
1327613276const exec_1 = __nccwpck_require__ ( 1514 ) ;
1327713277const io_1 = __nccwpck_require__ ( 7436 ) ;
1327813278const tc = __importStar ( __nccwpck_require__ ( 7784 ) ) ;
13279+ const child_process = __importStar ( __nccwpck_require__ ( 2081 ) ) ;
1327913280const fs_1 = __nccwpck_require__ ( 7147 ) ;
1328013281const path_1 = __nccwpck_require__ ( 1017 ) ;
1328113282const opts_1 = __nccwpck_require__ ( 8131 ) ;
@@ -13298,7 +13299,25 @@ async function configureOutputs(tool, version, path, os) {
1329813299 if ( os === 'win32' )
1329913300 core . exportVariable ( 'STACK_ROOT' , sr ) ;
1330013301 }
13301- core . setOutput ( `${ tool } -version` , version ) ;
13302+ // can't put this in resolve() because it might run before ghcup is installed
13303+ let resolvedVersion = version ;
13304+ if ( version === 'latest-nightly' ) {
13305+ try {
13306+ const ghcupExe = await ghcupBin ( os ) ;
13307+ const out = await new Promise ( ( resolve , reject ) => child_process . execFile ( ghcupExe , [ 'list' , '-nr' ] , { encoding : 'utf-8' } , ( error , stdout ) => ( error ? reject ( error ) : resolve ( stdout ) ) ) ) ;
13308+ resolvedVersion =
13309+ out
13310+ . split ( '\n' )
13311+ . map ( line => line . split ( ' ' ) )
13312+ . filter ( line => line [ 2 ] === 'latest-nightly' )
13313+ . map ( line => line [ 1 ] )
13314+ . at ( 0 ) ?? version ;
13315+ }
13316+ catch ( error ) {
13317+ // swallow failures, just leave version as 'latest-nightly'
13318+ }
13319+ }
13320+ core . setOutput ( `${ tool } -version` , resolvedVersion ) ;
1330213321}
1330313322async function success ( tool , version , path , os ) {
1330413323 core . addPath ( path ) ;
@@ -13400,12 +13419,14 @@ async function installTool(tool, version, os) {
1340013419 }
1340113420 switch ( os ) {
1340213421 case 'linux' :
13403- if ( tool === 'ghc' && ( 0 , compare_versions_1 . compareVersions ) ( '8.3' , version ) ) {
13404- // Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
13405- // Atm, I do not know how to check whether we are on ubuntu-20.04.
13406- // So, ignore the error.
13407- // if (!(await aptLibCurses5())) break;
13408- await aptLibNCurses5 ( ) ;
13422+ if ( tool === 'ghc' ) {
13423+ if ( version !== 'latest-nightly' && ( 0 , compare_versions_1 . compareVersions ) ( '8.3' , version ) ) {
13424+ // Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
13425+ // Atm, I do not know how to check whether we are on ubuntu-20.04.
13426+ // So, ignore the error.
13427+ // if (!(await aptLibCurses5())) break;
13428+ await aptLibNCurses5 ( ) ;
13429+ }
1340913430 }
1341013431 await ghcup ( tool , version , os ) ;
1341113432 if ( await isInstalled ( tool , version , os ) )
@@ -13862,8 +13883,18 @@ async function run(inputs) {
1386213883 core . debug ( `run: inputs = ${ JSON . stringify ( inputs ) } ` ) ;
1386313884 core . debug ( `run: os = ${ JSON . stringify ( os ) } ` ) ;
1386413885 core . debug ( `run: opts = ${ JSON . stringify ( opts ) } ` ) ;
13865- if ( opts . ghcup . releaseChannel ) {
13866- await core . group ( `Preparing ghcup environment` , async ( ) => ( 0 , installer_1 . addGhcupReleaseChannel ) ( opts . ghcup . releaseChannel , os ) ) ;
13886+ const releaseChannels = [
13887+ opts . ghcup . releaseChannel ,
13888+ opts . ghc . raw === 'latest-nightly'
13889+ ? new URL ( 'https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml' )
13890+ : null
13891+ ] . filter ( ( v ) => v !== null ) ;
13892+ if ( releaseChannels . length > 0 ) {
13893+ await core . group ( `Setting release channels` , async ( ) => {
13894+ for ( const channel of releaseChannels ) {
13895+ await ( 0 , installer_1 . addGhcupReleaseChannel ) ( channel , os ) ;
13896+ }
13897+ } ) ;
1386713898 }
1386813899 for ( const [ t , { resolved } ] of Object . entries ( opts ) . filter ( o => o [ 1 ] . enable ) ) {
1386913900 await core . group ( `Preparing ${ t } environment` , async ( ) => ( 0 , installer_1 . resetTool ) ( t , resolved , os ) ) ;
0 commit comments