hkgr 0.2.4.1 → 0.2.5
raw patch · 3 files changed
+35/−12 lines, 3 files
Files
- CHANGELOG.md +5/−0
- Main.hs +28/−10
- hkgr.cabal +2/−2
CHANGELOG.md view
@@ -1,5 +1,10 @@ # Changelog +## 0.2.5 (2020-02-29)+- check that package version is committed+- use quiet cabal v1-configure and v1-sdist commands+- make cabal upload quiet+ ## 0.2.4.1 (2020-02-11) - assert that cabal-install installed - run hlint in git checkout instead of working tree
Main.hs view
@@ -9,6 +9,8 @@ import Control.Exception (bracket_, onException) import Control.Monad+import Data.Char+import Data.List import Data.Maybe #if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,11,0)) #else@@ -29,11 +31,14 @@ subcommands [ Subcommand "tagdist" "'git tag' version and 'cabal sdist' tarball" $ tagDistCmd <$> forceOpt "Move existing tag"- , Subcommand "upload" "'cabal upload' candidate tarball to Hackage" $ pure $ uploadCmd False+ , Subcommand "upload" "'cabal upload' candidate tarball to Hackage" $+ pure $ uploadCmd False , Subcommand "publish" "Publish to Hackage ('cabal upload --publish')" $ pure $ uploadCmd True- , Subcommand "upload-haddock" "Upload candidate documentation to Hackage" $ pure $ upHaddockCmd False- , Subcommand "publish-haddock" "Publish documentation to Hackage" $ pure $ upHaddockCmd True+ , Subcommand "upload-haddock" "Upload candidate documentation to Hackage" $+ pure $ upHaddockCmd False+ , Subcommand "publish-haddock" "Publish documentation to Hackage" $+ pure $ upHaddockCmd True , Subcommand "version" "Show the package version from .cabal file" $ pure showVersionCmd ]@@ -48,8 +53,7 @@ putStrLn "=== start of uncommitted changes ===" putStrLn diff putStrLn "=== end of uncommitted changes ==="- pkgid <- getPackageId- checkNotPublished pkgid+ pkgid <- checkPackage let tag = pkgidTag pkgid tagHash <- cmdMaybe "git" ["rev-parse", tag] when (isJust tagHash && not force) $@@ -65,6 +69,20 @@ pkgidTag :: PackageIdentifier -> String pkgidTag pkgid = "v" ++ packageVersion pkgid +checkPackage :: IO PackageIdentifier+checkPackage = do+ pkgid <- getPackageId+ checkVersionCommitted pkgid+ checkNotPublished pkgid+ return pkgid++checkVersionCommitted :: PackageIdentifier -> IO ()+checkVersionCommitted pkgid = do+ let pkg = packageName pkgid+ diff <- git "diff" ["-U0", unPackageName pkg <.> "cabal"]+ when ("version:" `isInfixOf` map toLower diff) $+ error' "Please commit or revert the package Version first"+ checkNotPublished :: PackageIdentifier -> IO () checkNotPublished pkgid = do let published = "dist" </> showPkgId pkgid <.> ".tar.gz" <.> "published"@@ -87,9 +105,9 @@ cabal_ "check" [] mhlint <- findExecutable "hlint" when (isJust mhlint) $ void $ cmdBool "hlint" ["."]- cabal_ "configure" []+ cabal_ "v1-configure" [] -- cabal_ "build" []- cabal_ "sdist" []+ cabal_ "v1-sdist" [] renameFile target (cwd </> target) showVersionCmd :: IO ()@@ -99,8 +117,7 @@ uploadCmd :: Bool -> IO () uploadCmd publish = do- pkgid <- getPackageId- checkNotPublished pkgid+ pkgid <- checkPackage let file = "dist" </> showPkgId pkgid <.> ".tar.gz" exists <- doesFileExist file unless exists $ tagDistCmd False@@ -110,7 +127,8 @@ branch <- cmd "git" ["branch", "--show-current"] git_ "push" ["origin", tagHash ++ ":" ++ branch] git_ "push" ["origin", tag]- cabal_ "upload" $ ["--publish" | publish] ++ [file]+ cabal_ "upload" $ ["-v0"] ++ ["--publish" | publish] ++ [file]+ putStrLn $ "https://hackage.haskell.org/package/" ++ showPkgId pkgid ++ if publish then "" else "/candidate" when publish $ createFileLink (takeFileName file) (file <.> "published")
hkgr.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.0 name: hkgr-version: 0.2.4.1+version: 0.2.5 synopsis: Simple Hackage release workflow for package maintainers description: Hkgr (pronounced "Hackager") is a tool to help make new releases of@@ -17,7 +17,7 @@ build-type: Simple extra-doc-files: README.md , CHANGELOG.md-tested-with: GHC == 8.8.1, GHC == 8.6.5, GHC == 8.4.4, GHC == 8.2.2,+tested-with: GHC == 8.8.2, GHC == 8.6.5, GHC == 8.4.4, GHC == 8.2.2, GHC == 8.0.2 source-repository head