From 1b949f3d8eaae8c3c316f13fefcb177d2f877d28 Mon Sep 17 00:00:00 2001 From: Akshett Rai Jindal Date: Sat, 7 Dec 2024 22:43:58 +0530 Subject: [PATCH] refactor: move version to separate file --- nix/pkgs/watgbridge-dev.nix | 2 +- state/state.go | 6 +++++- state/version.txt | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 state/version.txt diff --git a/nix/pkgs/watgbridge-dev.nix b/nix/pkgs/watgbridge-dev.nix index f0f1b90..7e18434 100644 --- a/nix/pkgs/watgbridge-dev.nix +++ b/nix/pkgs/watgbridge-dev.nix @@ -28,7 +28,7 @@ let in buildGoApplication rec { pname = "watgbridge"; - version = "1.11.0"; + version = (lib.trim (builtins.readFile ../../state/version.txt)); pwd = localSrc; src = localSrc; diff --git a/state/state.go b/state/state.go index 35066bf..40a97cf 100644 --- a/state/state.go +++ b/state/state.go @@ -1,6 +1,8 @@ package state import ( + _ "embed" + "strings" "time" "github.com/PaulSonOfLars/gotgbot/v2" @@ -10,7 +12,8 @@ import ( "gorm.io/gorm" ) -const WATGBRIDGE_VERSION = "1.11.0" +//go:embed version.txt +var WATGBRIDGE_VERSION string type state struct { Config *Config @@ -33,5 +36,6 @@ type state struct { var State state func init() { + WATGBRIDGE_VERSION = strings.TrimSpace(WATGBRIDGE_VERSION) State.Config = &Config{Path: "config.yaml"} } diff --git a/state/version.txt b/state/version.txt new file mode 100644 index 0000000..1cac385 --- /dev/null +++ b/state/version.txt @@ -0,0 +1 @@ +1.11.0