Automated uploads

This commit is contained in:
Michael Snoyman 2014-06-16 12:49:08 +03:00
parent c7668737f2
commit 52ca2cc6e8
4 changed files with 66 additions and 6 deletions

View File

@ -129,6 +129,8 @@ getInstallInfo settings = do
, ghcVer
, ", "
, date
, ", "
, incexc
, "\nGenerated on "
, show now
]

View File

@ -23,18 +23,29 @@ createHackageFile :: Bool -- ^ inclusive?
-> Handle -- ^ tarballs
-> IO ()
createHackageFile isInc ii ghcVer date hackageH tarballH = do
let stackageFP = concat
[ "../ghc-"
, ghcVer
, "-"
, date
, if isInc then "-inclusive" else "-exclusive"
, ".stackage"
hPutStr tarballH $ concat
[ "#!/bin/bash -ex\n\ntar czfv ../ghc-"
, ghcVer
, "-"
, date
, if isInc then "-inclusive" else "-exclusive"
, ".stackage hackage desc"
[ "#!/bin/bash -ex\n\ntar czfv "
, stackageFP
, " hackage desc"
]
indextargz <- getTarballName
indexLBS <- L.readFile indextargz
loop $ Tar.read indexLBS
hPutStrLn tarballH ""
hPutStrLn tarballH $ concat
[ "runghc ../stackage-upload.hs "
, stackageFP
, " unstable-ghc"
, filter (/= '.') ghcVer
, if isInc then "-inclusive" else "-exclusive"
]
where
selected = Map.fromList . map toStrs . Map.toList $
fmap spiVersion (iiPackages ii)

View File

@ -9,6 +9,8 @@ cabal install Cabal-$(cabal --version | sed -n 's@using version \(.*\) of the Ca
./dist/build/stackage/stackage build
./dist/build/stackage/stackage test
cabal install http-client
for f in inclusive exclusive
do
cd $f

45
stackage-upload.hs Normal file
View File

@ -0,0 +1,45 @@
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Char8 as S8
import Network.HTTP.Client
import Network.HTTP.Client.MultipartFormData
import System.Environment (getArgs, getEnv,
getProgName)
import System.Exit (exitFailure)
main :: IO ()
main = withManager defaultManagerSettings $ \m -> do
args <- getArgs
token <- getEnv "STACKAGE_AUTH_TOKEN"
(filepath, alias) <-
case args of
[x, y] -> return (x, y)
_ -> do
pn <- getProgName
putStrLn $ concat
[ "Usage: "
, pn
, " <filepath> <alias name>"
]
exitFailure
putStrLn $ concat
[ "Uploading "
, filepath
, " as "
, alias
]
req1 <- parseUrl "http://www.stackage.org/upload"
let formData =
[ partBS "alias" $ S8.pack alias
, partFileSource "stackage" filepath
]
req2 <- formDataBody formData req1
let req3 = req2
{ method = "PUT"
, requestHeaders =
[ ("Authorization", S8.pack token)
, ("Accept", "application/json")
] ++ requestHeaders req2
}
httpLbs req3 m >>= print