@@ -139,8 +139,12 @@ options =
139139 " Label to give the uploaded release asset"
140140 , Option " " [noTestHaddocksOptName] (NoArg $ Right $ \ g -> g{gTestHaddocks = False })
141141 " Disable testing building haddocks."
142- , Option " " [staticOptName] (NoArg $ Right $ \ g -> g{gBuildArgs = gBuildArgs g ++ [" --flag=stack:static" ]})
143- " Build a static binary."
142+ , Option " " [alpineOptName]
143+ (NoArg $ Right $ \ g ->
144+ g{gBuildArgs =
145+ gBuildArgs g ++
146+ [" --flag=stack:static" , " --docker" , " --system-ghc" , " --no-install-ghc" ]})
147+ " Build a static binary using Alpine Docker image."
144148 , Option " " [buildArgsOptName]
145149 (ReqArg
146150 (\ v -> Right $ \ g -> g{gBuildArgs = gBuildArgs g ++ words v})
@@ -196,18 +200,19 @@ rules global@Global{..} args = do
196200 Stdout dirty <- cmd " git status --porcelain"
197201 when (not gAllowDirty && not (null (trim dirty))) $
198202 error (" Working tree is dirty. Use --" ++ allowDirtyOptName ++ " option to continue anyway." )
199- withTempDir $ \ tmpDir -> do
200- let cmd0 c = cmd [gProjectRoot </> releaseBinDir </> binaryName </> stackExeFileName]
201- (stackArgs global)
202- [" --local-bin-path=" ++ tmpDir]
203- c
204- () <- cmd0 " install" gBuildArgs integrationTestFlagArgs $ concat $ concat
205- [[" --pedantic --no-haddock-deps " ]
206- ,[" --haddock" | gTestHaddocks]
207- ,[" stack" ]]
208- let cmd' c = cmd (AddPath [tmpDir] [] ) stackProgName (stackArgs global) c
209- () <- cmd' " test" gBuildArgs integrationTestFlagArgs " --pedantic --exec stack-integration-test stack"
210- return ()
203+ () <- cmd
204+ [gProjectRoot </> releaseBinDir </> binaryName </> stackExeFileName]
205+ (stackArgs global)
206+ [" build" ]
207+ gBuildArgs
208+ integrationTestFlagArgs
209+ [" --pedantic" , " --no-haddock-deps" , " --test" ]
210+ [" --haddock" | gTestHaddocks]
211+ [" stack" ]
212+ () <- cmd
213+ [gProjectRoot </> releaseBinDir </> binaryName </> stackExeFileName]
214+ [" exec" ]
215+ [gProjectRoot </> releaseBinDir </> binaryName </> " stack-integration-test" ]
211216 copyFileChanged (releaseBinDir </> binaryName </> stackExeFileName) out
212217
213218 unless gUploadOnly $ releaseDir </> binaryPkgZipFileName %> \ out -> do
@@ -242,7 +247,7 @@ rules global@Global{..} args = do
242247 unless gUploadOnly $ releaseDir </> binaryExeFileName %> \ out -> do
243248 need [releaseBinDir </> binaryName </> stackExeFileName]
244249 (Stdout versionOut) <- cmd (releaseBinDir </> binaryName </> stackExeFileName) " --version"
245- -- () <- cmd "git diff"
250+ () <- cmd " git diff"
246251 when (not gAllowDirty && " dirty" `isInfixOf` lower versionOut) $
247252 error (" Refusing continue because 'stack --version' reports dirty. Use --" ++
248253 allowDirtyOptName ++ " option to continue anyway." )
@@ -265,8 +270,8 @@ rules global@Global{..} args = do
265270 ,out])
266271 (removeFile out)
267272 Linux ->
268- cmd " strip -p -- strip-unneeded --remove-section=.comment -o "
269- [out, releaseBinDir </> binaryName </> stackExeFileName]
273+ -- Using Ubuntu's strip to strip an Alpine exe doesn't work, so just copy
274+ liftIO $ copyFile ( releaseBinDir </> binaryName </> stackExeFileName) out
270275 _ ->
271276 cmd " strip -o"
272277 [out, releaseBinDir </> binaryName </> stackExeFileName]
@@ -534,9 +539,9 @@ noTestHaddocksOptName = "no-test-haddocks"
534539buildArgsOptName :: String
535540buildArgsOptName = " build-args"
536541
537- -- | @--static @ command-line option name.
538- staticOptName :: String
539- staticOptName = " static "
542+ -- | @--alpine @ command-line option name.
543+ alpineOptName :: String
544+ alpineOptName = " alpine "
540545
541546-- | @--certificate-name@ command-line option name.
542547certificateNameOptName :: String
@@ -548,7 +553,7 @@ uploadOnlyOptName = "upload-only"
548553
549554-- | Arguments to pass to all 'stack' invocations.
550555stackArgs :: Global -> [String ]
551- stackArgs Global {.. } = [" --install-ghc " , " -- arch=" ++ display gArch, " --interleaved-output" ]
556+ stackArgs Global {.. } = [" --arch=" ++ display gArch, " --interleaved-output" ]
552557
553558-- | Name of the 'stack' program.
554559stackProgName :: FilePath
0 commit comments