11import { addPath , debug , exportVariable , info } from "@actions/core" ;
22import { cmd } from "../core" ;
3- import { mkdtempSync } from "fs" ;
3+ import { existsSync , mkdtempSync } from "fs" ;
44import { join } from "path" ;
55import { tmpdir } from "os" ;
66
@@ -21,14 +21,16 @@ function setupPaths() {
2121
2222 debug ( `Using Swiftly home dir: ${ homeDir } ` ) ;
2323 debug ( `Using Swiftly bin dir: ${ binDir } ` ) ;
24+
25+ return tmpPath ;
2426}
2527
2628/**
2729 * Install Swift using Swiftly
2830 * @param version Version to install
2931 */
3032export async function installSwift ( version : string ) {
31- setupPaths ( ) ;
33+ const tmpPath = setupPaths ( ) ;
3234
3335 info ( "Initializing Swiftly" ) ;
3436 await swiftly (
@@ -39,8 +41,24 @@ export async function installSwift(version: string) {
3941 "--no-modify-profile" ,
4042 ) ;
4143
44+ // Sometimes Swiftly needs to perform additional actions after installation
45+ const postInstallScriptPath = join ( tmpPath , "post-install.sh" ) ;
46+
4247 info ( `Installing Swift ${ version } ` ) ;
43- await swiftly ( "install" , "--use" , version , "--assume-yes" ) ;
48+ await swiftly (
49+ "install" ,
50+ "--use" ,
51+ version ,
52+ "--assume-yes" ,
53+ "--post-install-script" ,
54+ postInstallScriptPath ,
55+ ) ;
56+
57+ // Run the post-install script if it exists
58+ if ( existsSync ( postInstallScriptPath ) ) {
59+ info ( "Running post-install script" ) ;
60+ await cmd ( "bash" , postInstallScriptPath ) ;
61+ }
4462
4563 const location = await swiftly ( "use" , "--print-location" ) ;
4664 debug ( `Swiftly installed Swift to ${ location } ` ) ;
0 commit comments