@@ -13302,20 +13302,7 @@ async function configureOutputs(tool, version, path, os) {
1330213302 // can't put this in resolve() because it might run before ghcup is installed
1330313303 let resolvedVersion = version ;
1330413304 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- }
13305+ resolvedVersion = ( await getLatestNightlyFromGhcup ( os ) ) ?? version ;
1331913306 }
1332013307 core . setOutput ( `${ tool } -version` , resolvedVersion ) ;
1332113308}
@@ -13548,6 +13535,34 @@ async function addGhcupReleaseChannel(channel, os) {
1354813535 await exec ( bin , [ 'config' , 'add-release-channel' , channel . toString ( ) ] ) ;
1354913536}
1355013537exports . addGhcupReleaseChannel = addGhcupReleaseChannel ;
13538+ /**
13539+ * Get the resolved version of the `latest-nightly` GHC tag from ghcup,
13540+ * e.g. '9.9.20230711'
13541+ */
13542+ async function getLatestNightlyFromGhcup ( os ) {
13543+ try {
13544+ const ghcupExe = await ghcupBin ( os ) ;
13545+ /* Example output:
13546+
13547+ ghc 9.0.2 base-4.15.1.0
13548+ ghc 9.7.20230526 nightly 2023-06-27
13549+ ghc 9.9.20230711 latest-nightly 2023-07-12
13550+ cabal 2.4.1.0 no-bindist
13551+ cabal 3.6.2.0 recommended
13552+ */
13553+ const out = await new Promise ( ( resolve , reject ) => child_process . execFile ( ghcupExe , [ 'list' , '-nr' ] , { encoding : 'utf-8' } , ( error , stdout ) => ( error ? reject ( error ) : resolve ( stdout ) ) ) ) ;
13554+ return ( out
13555+ . split ( '\n' )
13556+ . map ( line => line . split ( ' ' ) )
13557+ . filter ( line => line [ 2 ] === 'latest-nightly' )
13558+ . map ( line => line [ 1 ] )
13559+ . at ( 0 ) ?? null ) ;
13560+ }
13561+ catch ( error ) {
13562+ // swallow failures, just return null
13563+ return null ;
13564+ }
13565+ }
1355113566async function ghcup ( tool , version , os ) {
1355213567 core . info ( `Attempting to install ${ tool } ${ version } using ghcup` ) ;
1355313568 const bin = await ghcupBin ( os ) ;
0 commit comments