hkgr 0.4.1 → 0.4.2
raw patch · 4 files changed
+55/−6 lines, 4 files
Files
- CHANGELOG.md +4/−0
- README.md +30/−1
- hkgr.cabal +1/−1
- src/Main.hs +20/−4
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Changelog +## 0.4.2 (2022-06-24)+- 'new': need cabal init --license option, otherwise no LICENSE file is created+- 'github': new command to add github remote for project+ ## 0.4.1 (2022-06-23) - 'rename' improvements - 'new': avoid error on cabal >= 3.4 by not passing --license to cabal init
README.md view
@@ -67,6 +67,33 @@ Published at https://hackage.haskell.org/package/hkgr-0.4 ``` +## Help++```shellsession+$ hkgr --version+0.4.2+$ hkgr --help+Hackage Release tool++Usage: hkgr [--version] COMMAND+ 'Hackager' is a package release tool for easy Hackage workflow++Available options:+ -h,--help Show this help text+ --version Show version++Available commands:+ new setup a new project+ 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 candidate documentation to Hackage+ publish-haddock Publish documentation to Hackage+ version Show the package version from .cabal file+ rename Rename the Cabal package+ github Add github repo+```+ ## Details ### tagdist@@ -127,7 +154,9 @@ A `stack.yaml` file and git repo is also set up. -One can use `gh repo create` etc to create the project repo on Github.+### github+(One can use `gh repo create` etc to create the project repo on Github)+and then `hkgr github` to add the github remote to your project. ## Requirements hkgr uses `cabal-install` >=2, `git`, and also `hlint` if available.
hkgr.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.0 name: hkgr-version: 0.4.1+version: 0.4.2 synopsis: Simple Hackage release workflow for package maintainers description: Hkgr (Hackager) is a tool to help make new releases of
src/Main.hs view
@@ -15,6 +15,7 @@ #if !MIN_VERSION_base(4,11,0) import Data.Monoid ((<>)) #endif+import Data.Version.Extra import SimpleCabal import SimpleCmdArgs import System.Directory@@ -56,6 +57,8 @@ , Subcommand "rename" "Rename the Cabal package" $ renameCmd <$> strArg "NEWNAME"+ , Subcommand "github" "Add github repo" $+ pure githubCmd ] where forceOpt = switchWith 'f' "force"@@ -84,9 +87,9 @@ then B.init bs else bs --- cmd :: String -> [String] -> IO String--- cmd c args =--- B.unpack . removeTrailingNewline <$> P.readProcessStdout_ (P.proc c args)+cmd :: String -> [String] -> IO String+cmd c args =+ B.unpack . removeTrailingNewline <$> P.readProcessStdout_ (P.proc c args) cmd_ :: String -> [String] -> IO () cmd_ c args = P.runProcess_ $ P.proc c args@@ -342,7 +345,11 @@ Nothing -> do let setupFile = "Setup.hs" origsetup <- doesFileExist setupFile- cabal_ "init" ["--quiet", "--no-comments", "--non-interactive", "--is-libandexe", "--cabal-version=1.18", "--package-name=" ++ name, "--version=0.1.0", "--dependency=base<5", "--source-dir=src"]+ cabalversion <- readVersion <$> cmd "cabal" ["--numeric-version"]+ let license = if cabalversion > makeVersion [3,4]+ then "BSD-3-Clause"+ else "BSD3"+ in cabal_ "init" ["--quiet", "--no-comments", "--non-interactive", "--is-libandexe", "--cabal-version=1.18", "--license=" ++ license, "--package-name=" ++ name, "--version=0.1.0", "--dependency=base<5", "--source-dir=src"] whenJustM (cmdMaybe $ P.proc "find" ["-name", "Main.hs"]) $ \ file -> do sed ["1s/^module Main where/-- SPDX-License-Identifier: BSD-3-Clause\\n\\nmodule Main (main) where/"] file unless (file == "src/Main.hs") $ renameFile file "src/Main.hs"@@ -437,3 +444,12 @@ sed ["s/" ++ oldname ++ "/" ++ newname ++ "/g"] "README.md" sed ["s/" ++ oldname ++ "/" ++ newname ++ "/g"] "ChangeLog.md" renameDirectory (".." </> oldname) (".." </> newname)++githubCmd :: IO ()+githubCmd = do+ ghuser <- cmdOut $ git "config" ["--global", "github.user"]+ pkgid <- getPackageId+ let name = unPackageName (pkgName pkgid)+ git_ "remote" ["add", "origin", "git@github.com:" ++ ghuser </> name <.> "git"]+ git_ "branch" ["-M", "main"]+-- git_ "push" ["-u", "origin", "main"]