packages feed

hkgr 0.1 → 0.2

raw patch · 4 files changed

+38/−36 lines, 4 files

Files

CHANGELOG.md view
@@ -1,6 +1,11 @@ # Changelog -## 0.1 (2019-06-??)+## 0.2 (2019-06-24)+- merge tag and dist commands into tagdist+- if sdist fails then reset tag+- drop push-tags command++## 0.1 (2019-06-24) - add published lock file: prevents tagging/dist/upload after publish - tag before sdist if no tag - push tag after publishing
Main.hs view
@@ -9,6 +9,7 @@  import Control.Exception (bracket_) import Control.Monad+import Data.Maybe #if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,11,0)) #else import Data.Semigroup ((<>))@@ -26,29 +27,35 @@   simpleCmdArgs (Just version) "HacKaGe Release workflow"   "A tool to help Hackage maintainers with releasing packages" $   subcommands-  [ Subcommand "tag" "'git tag' version" $-    gitTagCmd <$> forceOpt "Move existing tag"-  , Subcommand "dist" "Make tarball from latest tag ('cabal sdist')" $-    sdistCmd <$> forceOpt "Overwrite existing dist tarball"-  , Subcommand "version" "Show the package version from .cabal file" $-    pure showVersionCmd-  , Subcommand "upload" "'cabal upload' tarball to Hackage" $ pure $ uploadCmd False+  [ 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 "publish" "Publish to Hackage ('cabal upload --publish')" $     pure $ uploadCmd True-  , Subcommand "upload-haddock" "Upload documentation to Hackage" $ pure $ upHaddockCmd False-  , Subcommand "publish-haddock" "Upload documentation to Hackage" $ pure $ upHaddockCmd True-  , Subcommand "push-tags" "'git push --tags' to origin" $ pure pushCmd+  , 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   ]   where     forceOpt = switchWith 'f' "force" -gitTagCmd :: Bool -> IO ()-gitTagCmd force = do+tagDistCmd :: Bool -> IO ()+tagDistCmd force = do   pkgid <- getPackageId   checkNotPublished pkgid   let tag = packageVersion pkgid+  tagHash <- cmdMaybe "git" ["rev-parse", tag]+  when (isJust tagHash && not force) $+    error' "tag exists: use --force to override"   git_ "tag" $ ["--force" | force] ++ [tag]   unless force $ putStrLn tag+  distOk <- sdist force pkgid+  unless distOk $ do+    putStrLn "Resetting tag"+    if force+    then git_ "tag" ["--force", tag, fromJust tagHash]+    else git_ "tag" ["--delete", tag]  checkNotPublished :: PackageIdentifier -> IO () checkNotPublished pkgid = do@@ -56,20 +63,16 @@   exists <- doesFileExist published   when exists $ error' $ showPkgId pkgid <> " was already published!!" -sdistCmd :: Bool -> IO ()-sdistCmd force = do-  pkgid <- getPackageId+sdist :: Bool -> PackageIdentifier -> IO Bool+sdist force pkgid = do   let ver = packageVersion pkgid   let target = "dist" </> showPkgId pkgid <.> ".tar.gz"-  checkNotPublished pkgid   haveTarget <- doesFileExist target   if haveTarget     then if force          then removeFile target          else error' $ target <> " exists already!"     else when force $ error' "Target does not exist, please use 'dist' command"-  haveTag <- pipeBool ("git", ["tag"]) ("grep",["-q",ver])-  unless haveTag $ gitTagCmd False   cwd <- getCurrentDirectory   withTempDirectory "tmp-sdist" $ do     git_ "clone" ["-q", "--no-checkout", "..", "."]@@ -78,8 +81,9 @@     cabal_ "configure" []     -- cabal_ "build" []     cmd_ "hlint" ["."]-    cabal_ "sdist" []-    renameFile target (cwd </> target)+    distOk <- cmdBool "cabal" ["sdist"]+    when distOk $ renameFile target (cwd </> target)+    return distOk  showVersionCmd :: IO () showVersionCmd = do@@ -93,13 +97,9 @@   let file = "dist" </> showPkgId pkgid <.> ".tar.gz"   cabal_ "upload" $ ["--publish" | publish] ++ [file]   when publish $ do+    createFileLink file (takeFileName file <.> "published")     let tag = packageVersion pkgid     git_ "push" ["origin", tag]-    createFileLink file (takeFileName file <.> "published")--pushCmd :: IO ()-pushCmd =-  git_ "push" ["--tags"]  upHaddockCmd :: Bool -> IO () upHaddockCmd publish =
README.md view
@@ -21,22 +21,19 @@   --version                Show version  Available commands:-  tag                      'git tag' version-  dist                     Make tarball from latest tag ('cabal sdist')-  version                  Show the package version from .cabal file-  upload                   'cabal upload' tarball to Hackage+  tagdist                  'git tag' version and 'cabal sdist' tarball+  upload                   'cabal upload' candidate tarball to Hackage   publish                  Publish to Hackage ('cabal upload --publish')-  upload-haddock           Upload documentation to Hackage-  publish-haddock          Upload documentation to Hackage-  push-tags                'git push --tags' to origin+  upload-haddock           Upload candidate documentation to Hackage+  publish-haddock          Publish documentation to Hackage+  version                  Show the package version from .cabal file ```  ## Example ``` $ git commit -m "new release" $ git push-$ hkgr tag-$ hkgr dist+$ hkgr tagdist $ hkgr upload $ hkgr upload-haddock $ hkgr publish
hkgr.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.0 name:                hkgr-version:             0.1+version:             0.2 synopsis:            Simple Hackage release workflow for package maintainers description:             Hkgr (pronouced "Hackager") is a tool to help make new releases of