hapistrano 0.3.5.10 → 0.3.6.0
raw patch · 4 files changed
+89/−72 lines, 4 filesdep ~stmdep ~yamlPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: stm, yaml
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- README.md +17/−0
- app/Main.hs +62/−67
- hapistrano.cabal +5/−5
CHANGELOG.md view
@@ -1,3 +1,8 @@+## 0.3.6.0+* Add support to interpolate ENV variables in a configuration file.+* Add support for GHC 8.6.1+* Loose constraint for stm-2.5.0.0+ ## 0.3.5.10 * Updated upper bound for yaml 0.10
README.md view
@@ -101,6 +101,23 @@ $ hap rollback -n 2 # go two deploys back in time, etc. ``` +### Environment Variables++Configuration files are parsed using+[loadYamlSettings](http://hackage.haskell.org/package/yaml-0.10.2.0/docs/Data-Yaml-Config.html#v:loadYamlSettings),+therefore, variable substitution is supported. Considering the following configuration file:++```yaml+revision: "_env:HAPISTRANO_REVISION:origin/master+...+```++The `revision` value could be overwritten as follows:++```sh+HAPISTRANO_REVISION=origin/feature_branch hap deploy+```+ ## What to do when compiling on server is not viable Sometimes the target machine (server) is not capable of compiling your
app/Main.hs view
@@ -10,7 +10,7 @@ import Control.Monad import Data.Monoid ((<>)) import Data.Version (showVersion)-import qualified Data.Yaml as Yaml+import qualified Data.Yaml.Config as Yaml import Development.GitRev import Formatting import Numeric.Natural@@ -119,69 +119,64 @@ main :: IO () main = do Opts {..} <- execParser parserInfo- econfig <- Yaml.decodeFileEither optsConfigFile- case econfig of- Left err -> do- putStrLn (Yaml.prettyPrintParseException err)- exitFailure- Right C.Config {..} -> do- chan <- newTChanIO- let task rf = Task { taskDeployPath = configDeployPath- , taskRepository = configRepo- , taskRevision = configRevision- , taskReleaseFormat = rf }- let printFnc dest str = atomically $- writeTChan chan (PrintMsg dest str)- hap sshOpts = do- r <- Hap.runHapistrano sshOpts printFnc $- case optsCommand of- Deploy releaseFormat n -> do- forM_ configRunLocally Hap.playScriptLocally- release <- case configVcAction of- True -> Hap.pushRelease (task releaseFormat)- False -> Hap.pushReleaseWithoutVc (task releaseFormat)- rpath <- Hap.releasePath configDeployPath release- forM_ configCopyFiles $ \(C.CopyThing src dest) -> do- srcPath <- resolveFile' src- destPath <- parseRelFile dest- let dpath = rpath </> destPath- (Hap.exec . Hap.MkDir . parent) dpath- Hap.scpFile srcPath dpath- forM_ configCopyDirs $ \(C.CopyThing src dest) -> do- srcPath <- resolveDir' src- destPath <- parseRelDir dest- let dpath = rpath </> destPath- (Hap.exec . Hap.MkDir . parent) dpath- Hap.scpDir srcPath dpath- forM_ configBuildScript (Hap.playScript configDeployPath release)- Hap.registerReleaseAsComplete configDeployPath release- Hap.activateRelease configTargetSystem configDeployPath release- Hap.dropOldReleases configDeployPath n- forM_ configRestartCommand Hap.exec- Rollback n -> do- Hap.rollback configTargetSystem configDeployPath n- forM_ configRestartCommand Hap.exec- atomically (writeTChan chan FinishMsg)- return r- printer :: Int -> IO ()- printer n = when (n > 0) $ do- msg <- atomically (readTChan chan)- case msg of- PrintMsg StdoutDest str ->- putStr str >> printer n- PrintMsg StderrDest str ->- hPutStr stderr str >> printer n- FinishMsg ->- printer (n - 1)- haps :: [IO (Either Int ())]- haps =- case configHosts of- [] -> [hap Nothing] -- localhost, no SSH- xs ->- let f (host, port) = SshOptions host port- in hap . Just . f <$> xs- results <- (runConcurrently . traverse Concurrently)- ((Right () <$ printer (length haps)) : haps)- case sequence_ results of- Left n -> exitWith (ExitFailure n)- Right () -> putStrLn "Success."+ C.Config{..} <- Yaml.loadYamlSettings [optsConfigFile] [] Yaml.useEnv+ chan <- newTChanIO+ let task rf = Task { taskDeployPath = configDeployPath+ , taskRepository = configRepo+ , taskRevision = configRevision+ , taskReleaseFormat = rf }+ let printFnc dest str = atomically $+ writeTChan chan (PrintMsg dest str)+ hap sshOpts = do+ r <- Hap.runHapistrano sshOpts printFnc $+ case optsCommand of+ Deploy releaseFormat n -> do+ forM_ configRunLocally Hap.playScriptLocally+ release <- case configVcAction of+ True -> Hap.pushRelease (task releaseFormat)+ False -> Hap.pushReleaseWithoutVc (task releaseFormat)+ rpath <- Hap.releasePath configDeployPath release+ forM_ configCopyFiles $ \(C.CopyThing src dest) -> do+ srcPath <- resolveFile' src+ destPath <- parseRelFile dest+ let dpath = rpath </> destPath+ (Hap.exec . Hap.MkDir . parent) dpath+ Hap.scpFile srcPath dpath+ forM_ configCopyDirs $ \(C.CopyThing src dest) -> do+ srcPath <- resolveDir' src+ destPath <- parseRelDir dest+ let dpath = rpath </> destPath+ (Hap.exec . Hap.MkDir . parent) dpath+ Hap.scpDir srcPath dpath+ forM_ configBuildScript (Hap.playScript configDeployPath release)+ Hap.registerReleaseAsComplete configDeployPath release+ Hap.activateRelease configTargetSystem configDeployPath release+ Hap.dropOldReleases configDeployPath n+ forM_ configRestartCommand Hap.exec+ Rollback n -> do+ Hap.rollback configTargetSystem configDeployPath n+ forM_ configRestartCommand Hap.exec+ atomically (writeTChan chan FinishMsg)+ return r+ printer :: Int -> IO ()+ printer n = when (n > 0) $ do+ msg <- atomically (readTChan chan)+ case msg of+ PrintMsg StdoutDest str ->+ putStr str >> printer n+ PrintMsg StderrDest str ->+ hPutStr stderr str >> printer n+ FinishMsg ->+ printer (n - 1)+ haps :: [IO (Either Int ())]+ haps =+ case configHosts of+ [] -> [hap Nothing] -- localhost, no SSH+ xs ->+ let f (host, port) = SshOptions host port+ in hap . Just . f <$> xs+ results <- (runConcurrently . traverse Concurrently)+ ((Right () <$ printer (length haps)) : haps)+ case sequence_ results of+ Left n -> exitWith (ExitFailure n)+ Right () -> putStrLn "Success."
hapistrano.cabal view
@@ -1,5 +1,5 @@ name: hapistrano-version: 0.3.5.10+version: 0.3.6.0 synopsis: A deployment library for Haskell applications description: .@@ -21,14 +21,14 @@ license: MIT license-file: LICENSE author: Justin Leitgeb-maintainer: justin@stackbuilders.com+maintainer: jpaucar@stackbuilders.com copyright: 2015-2018 Stack Builders Inc. category: System homepage: https://github.com/stackbuilders/hapistrano bug-reports: https://github.com/stackbuilders/hapistrano/issues build-type: Simple cabal-version: >=1.18-tested-with: GHC==7.10.3, GHC==8.0.2, GHC==8.2.2, GHC==8.4.3+tested-with: GHC==7.10.3, GHC==8.0.2, GHC==8.2.2, GHC==8.4.3, GHC==8.6.1 extra-source-files: CHANGELOG.md , README.md , Dockerfile@@ -79,8 +79,8 @@ , optparse-applicative >= 0.11 && < 0.15 , path >= 0.5 && < 0.7 , path-io >= 1.2 && < 1.5- , stm >= 2.4 && < 2.5- , yaml >= 0.8 && < 0.11+ , stm >= 2.4 && < 2.6+ , yaml >= 0.8.16 && < 0.11 if flag(dev) ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -Werror else