;shake: setversion can save a new version number

This commit is contained in:
Simon Michael 2020-09-04 17:45:43 -07:00
parent 465e8cbc51
commit fdd346294f

View File

@ -72,8 +72,8 @@ usage =
,"./Shake webmanuals build web manuals (in site/) for all packages" ,"./Shake webmanuals build web manuals (in site/) for all packages"
,"./Shake PKG build a single hledger package and its embedded docs" ,"./Shake PKG build a single hledger package and its embedded docs"
,"./Shake build build all hledger packages and their embedded docs" ,"./Shake build build all hledger packages and their embedded docs"
,"./Shake setversion update version strings from */.version (& man dates)" ,"./Shake setversion [VER] set version strings from */.version (or VER)"
,"./Shake changelogs update */CHANGES.md with any new non-boring commits" ,"./Shake changelogs add any new non-boring commits to */CHANGES.md"
,"./Shake [PKG/]CHANGES.md-finalise add version/date heading in this changelog" ,"./Shake [PKG/]CHANGES.md-finalise add version/date heading in this changelog"
-- ,"./Shake [PKG/]CHANGES.md[-dry] update (or preview) one changelog" -- ,"./Shake [PKG/]CHANGES.md[-dry] update (or preview) one changelog"
-- ,"./Shake site/doc/VERSION/.snapshot save current web manuals as this snapshot" -- ,"./Shake site/doc/VERSION/.snapshot save current web manuals as this snapshot"
@ -120,8 +120,7 @@ main = do
let sitedir = "site" let sitedir = "site"
pages <- map takeBaseName . filter (".md" `isSuffixOf`) <$> S.getDirectoryContents sitedir pages <- map takeBaseName . filter (".md" `isSuffixOf`) <$> S.getDirectoryContents sitedir
args <- getArgs (target, args) <- splitAt 1 <$> getArgs
let args2 = drop 1 args
-- 2. define the shake rules -- 2. define the shake rules
@ -479,9 +478,17 @@ main = do
let inAllPackages f = map (</> f) packages let inAllPackages f = map (</> f) packages
phony "setversion" $ need $ phony "setversion" $ do
inAllPackages "defs.m4" -- if a version number was provided as first argument, save it in all .version files
++ inAllPackages "package.yaml" case take 1 args of
a@(_:_):_ | all (`elem` "0123456789.") a -> liftIO $
forM ("" : packages) $ \dir -> writeFile (dir </> ".version") (a++"\n")
_ -> return []
-- XXX any problems from laziness here ? seems not
-- liftIO $ forM ("" : packages) $ \dir -> readFileStrictly (dir </> ".version") >>= putStr
-- update all files depending on .version
need $ inAllPackages "defs.m4" ++ inAllPackages "package.yaml"
-- PKG/defs.m4 <- PKG/.version -- PKG/defs.m4 <- PKG/.version
"hledger*/defs.m4" %> \out -> do "hledger*/defs.m4" %> \out -> do