V2 upload by default, --server-url option when building

This commit is contained in:
Michael Snoyman 2015-03-18 15:17:03 +02:00
parent 52580761e7
commit d0138fae7a
4 changed files with 23 additions and 7 deletions

View File

@ -1,3 +1,7 @@
## 0.6.1
* Switch to V2 upload by default
## 0.6.0
* Upload bundle V2 stuff

View File

@ -40,7 +40,8 @@ data BuildFlags = BuildFlags
, bfEnableExecDyn :: !Bool
, bfVerbose :: !Bool
, bfSkipCheck :: !Bool
, bfUploadV2 :: !Bool
, bfUploadV1 :: !Bool
, bfServer :: !StackageServer
} deriving (Show)
data BuildType = Nightly | LTS BumpType
@ -253,7 +254,11 @@ completeBuild buildType buildFlags = withManager tlsManagerSettings $ \man -> do
}
when (bfDoUpload buildFlags) $
finallyUpload (bfUploadV2 buildFlags) settings man
finallyUpload
(not $ bfUploadV1 buildFlags)
(bfServer buildFlags)
settings
man
justUploadNightly
:: Text -- ^ nightly date
@ -261,7 +266,7 @@ justUploadNightly
justUploadNightly day = do
plan <- decodeFileEither (fpToString $ nightlyPlanFile day)
>>= either throwM return
withManager tlsManagerSettings $ finallyUpload False $ nightlySettings day plan
withManager tlsManagerSettings $ finallyUpload False def $ nightlySettings day plan
getStackageAuthToken :: IO Text
getStackageAuthToken = do
@ -273,8 +278,9 @@ getStackageAuthToken = do
-- | The final part of the complete build process: uploading a bundle,
-- docs and a distro to hackage.
finallyUpload :: Bool -- ^ use v2 upload
-> StackageServer
-> Settings -> Manager -> IO ()
finallyUpload useV2 settings@Settings{..} man = do
finallyUpload useV2 server settings@Settings{..} man = do
putStrLn "Uploading bundle to Stackage Server"
token <- getStackageAuthToken
@ -282,7 +288,7 @@ finallyUpload useV2 settings@Settings{..} man = do
if useV2
then do
res <- flip uploadBundleV2 man UploadBundleV2
{ ub2Server = def
{ ub2Server = server
, ub2AuthToken = token
, ub2Bundle = bundleDest
}

View File

@ -17,6 +17,7 @@ module Stackage.Upload
, uploadBundleV2
, UploadBundleV2 (..)
, def
, StackageServer
, unStackageServer
) where

View File

@ -110,8 +110,13 @@ main =
(long "skip-check" <>
help "Skip the check phase, and pass --allow-newer to cabal configure") <*>
switch
(long "upload-v2" <>
help "Use the V2 upload code")
(long "upload-v1" <>
help "Use the V1 upload code") <*>
(fmap fromString (strOption
(long "server-url" <>
metavar "SERVER-URL" <>
showDefault <> value (T.unpack $ unStackageServer def) <>
help "Server to upload bundle to")))
nightlyUploadFlags = fromString <$> strArgument
(metavar "DATE" <>