2021-06-29 19:39:57 +03:00
|
|
|
module Hasura.Server.Version.TH (getVersionFromEnvironment) where
|
|
|
|
|
2021-09-24 01:56:37 +03:00
|
|
|
import Data.FileEmbed (makeRelativeToProject)
|
|
|
|
import Data.Text qualified as T
|
|
|
|
import Data.Text.Conversions (FromText (..))
|
|
|
|
import Hasura.Prelude
|
|
|
|
import Hasura.Server.Utils (getValFromEnvOrScript)
|
|
|
|
import Hasura.Server.Version
|
|
|
|
import Language.Haskell.TH.Syntax qualified as TH
|
2021-06-29 19:39:57 +03:00
|
|
|
|
|
|
|
getVersionFromEnvironment :: TH.Q (TH.TExp Version)
|
|
|
|
getVersionFromEnvironment = do
|
|
|
|
txt <- getValFromEnvOrScript "VERSION" <$> makeRelativeToProject "../scripts/get-version.sh"
|
2021-09-24 01:56:37 +03:00
|
|
|
[||fromText $ T.dropWhileEnd (== '\n') $ T.pack $$(txt)||]
|