feat(standard-version): complete release workflow
BREAKING CHANGE: Start of new versioning schema
This commit is contained in:
parent
0f02a00053
commit
605e62f445
12
package.json
12
package.json
@ -18,7 +18,7 @@
|
||||
"frontend:test:watch": "karma start --conf karma.conf.js --single-run false",
|
||||
"frontend:build": "webpack",
|
||||
"frontend:build:watch": "webpack --watch",
|
||||
"release": "standard-version"
|
||||
"release": "git reset && standard-version -a"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
@ -34,12 +34,12 @@
|
||||
},
|
||||
"standard-version": {
|
||||
"scripts": {
|
||||
"postbump": "echo add any shell command here..."
|
||||
"postbump": "./sync-versions.hs && git add -- package.yaml"
|
||||
},
|
||||
"skip": {
|
||||
"tag": true,
|
||||
"commit": true
|
||||
}
|
||||
"commitUrlFormat": "https://gitlab.cip.ifi.lmu.de/jost/UniWorX/commit/{{hash}}",
|
||||
"compareUrlFormat": "https://gitlab.cip.ifi.lmu.de/jost/UniWorX/compare/{{previousTag}}...{{currentTag}}",
|
||||
"issueUrlFormat": "https://gitlab.cip.ifi.lmu.de/jost/UniWorX/issues/{{id}}",
|
||||
"userUrlFormat": "https://gitlab.cip.ifi.lmu.de/{{user}}"
|
||||
},
|
||||
"browserslist": [
|
||||
"defaults"
|
||||
|
||||
81
sync-versions.hs
Executable file
81
sync-versions.hs
Executable file
@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env stack
|
||||
-- stack runghc --package libyaml
|
||||
|
||||
{-# LANGUAGE OverloadedStrings
|
||||
, LambdaCase
|
||||
, PackageImports
|
||||
, NamedFieldPuns
|
||||
, RecordWildCards
|
||||
#-}
|
||||
|
||||
import "libyaml" Text.Libyaml
|
||||
import Control.Monad.Trans.Resource
|
||||
import Data.Conduit
|
||||
import qualified Data.Conduit.List as C
|
||||
|
||||
import qualified Data.Aeson as JSON
|
||||
|
||||
import qualified Data.ByteString as BS
|
||||
import qualified Data.ByteString.Char8 as CBS
|
||||
import qualified Data.ByteString.Lazy as LBS
|
||||
|
||||
import qualified Data.HashMap.Lazy as HashMap
|
||||
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as Text
|
||||
import qualified Data.Text.IO as Text
|
||||
import qualified Data.Text.Encoding as Text
|
||||
|
||||
import Text.Printf
|
||||
import System.IO (stderr)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
Just packageJSON <- JSON.decode <$> LBS.readFile "package.json"
|
||||
let
|
||||
newVersion :: Text
|
||||
Just (JSON.String newVersion) = HashMap.lookup ("version" :: Text) packageJSON
|
||||
|
||||
updatePackageYaml newVersion
|
||||
|
||||
|
||||
updatePackageYaml :: Text -> IO ()
|
||||
updatePackageYaml newVersion = do
|
||||
(oldVersion, start, end) <- runResourceT . runConduit . (.|) (decodeFileMarked "package.yaml") $ do
|
||||
awaitUntil $ \case
|
||||
MarkedEvent{ yamlEvent = EventMappingStart _ _ _ } -> True
|
||||
_ -> False
|
||||
awaitUntil $ \case
|
||||
MarkedEvent{ yamlEvent = EventScalar s _ _ _ }
|
||||
| s == "version" -> True
|
||||
_ -> False
|
||||
_ <- await -- Throw away "version: "
|
||||
Just MarkedEvent{ yamlEvent = EventScalar oldVersion' _ _ _, .. } <- await
|
||||
let oldVersion = Text.decodeUtf8 oldVersion'
|
||||
return (oldVersion, yamlStartMark, yamlEndMark)
|
||||
|
||||
encNewVersion <- runResourceT . runConduit . (.| encode) $ C.sourceList
|
||||
[ EventStreamStart
|
||||
, EventDocumentStart
|
||||
, EventScalar (Text.encodeUtf8 newVersion) NoTag Any Nothing
|
||||
, EventDocumentEnd
|
||||
, EventStreamEnd
|
||||
]
|
||||
|
||||
hPrintf stderr "package.yaml: %s -> %s\n" oldVersion newVersion
|
||||
|
||||
packageYaml <- BS.readFile "package.yaml"
|
||||
BS.writeFile "package.yaml" . mconcat $
|
||||
[ BS.take (fromIntegral $ yamlIndex start) packageYaml
|
||||
, Text.encodeUtf8 . Text.strip $ Text.decodeUtf8 encNewVersion
|
||||
, BS.drop (fromIntegral $ yamlIndex end) packageYaml
|
||||
]
|
||||
where
|
||||
awaitUntil :: Monad m => (i -> Bool) -> ConduitM i o m ()
|
||||
awaitUntil pred = do
|
||||
nextIn <- await
|
||||
case nextIn of
|
||||
Nothing -> error "Ran out of input in awaitUntil"
|
||||
Just inp
|
||||
| pred inp -> leftover inp
|
||||
Just _ -> awaitUntil pred
|
||||
Loading…
Reference in New Issue
Block a user