From be601acec6ea0deb84eeaa832770b6744b3167d0 Mon Sep 17 00:00:00 2001 From: Nick Dumas Date: Sat, 2 Sep 2023 10:14:00 -0400 Subject: [PATCH] first draft at stamping, broken because i'm not using workspaces --- MODULE.bazel | 2 +- cmd/echo/BUILD.bazel | 4 ++++ cmd/echo/main.go | 12 ++++++++++-- git-desc.sh | 6 ++++++ version.go | 6 ++++++ 5 files changed, 27 insertions(+), 3 deletions(-) create mode 100755 git-desc.sh create mode 100644 version.go diff --git a/MODULE.bazel b/MODULE.bazel index 132dea4..4c256e3 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -10,7 +10,7 @@ bazel_dep(name = "rules_pkg", version = "0.9.1") go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps") go_deps.from_file(go_mod = "//:go.mod") -use_repo(go_deps, "com_github_engoengine_engo", "com_github_threedotslabs_watermill") +use_repo(go_deps, "com_github_engoengine_ecs", "com_github_threedotslabs_watermill") oci = use_extension("@rules_oci//oci:extensions.bzl", "oci") oci.pull( diff --git a/cmd/echo/BUILD.bazel b/cmd/echo/BUILD.bazel index 27db034..94dae79 100644 --- a/cmd/echo/BUILD.bazel +++ b/cmd/echo/BUILD.bazel @@ -20,6 +20,10 @@ go_binary( name = "echo", embed = [":echo_lib"], visibility = ["//visibility:public"], + x_defs = { + "code.ndumas.com/ndumas/gomud.Version":"STABLE_GIT_VERSION", + "code.ndumas.com/ndumas/gomud.Build":"STABLE_GIT_COMMIT", + }, ) load("@rules_pkg//:pkg.bzl", "pkg_tar") diff --git a/cmd/echo/main.go b/cmd/echo/main.go index 5ee6d4c..3d5fe20 100644 --- a/cmd/echo/main.go +++ b/cmd/echo/main.go @@ -14,22 +14,30 @@ import ( "github.com/ThreeDotsLabs/watermill/message/router/plugin" "github.com/ThreeDotsLabs/watermill/pubsub/gochannel" + "code.ndumas.com/ndumas/gomud" "code.ndumas.com/ndumas/gomud/engine" "code.ndumas.com/ndumas/gomud/logger" "code.ndumas.com/ndumas/gomud/telnet" ) var ( - port int - verbose int + port int + verbose int + versionFlag bool ) func main() { flag.IntVar(&verbose, "verbose", 0, "-5:Trace, -4:Debug, 0:Info, 4:Warn, 8:Error") flag.IntVar(&port, "port", 5555, "MUD server port") + flag.BoolVar(&versionFlag, "version", false, "print build version") flag.Parse() + if versionFlag { + fmt.Printf("%s@%s\n", gomud.VERSION, gomud.BUILD) + return + } + l, err := net.Listen("tcp", fmt.Sprintf(":%d", port)) if err != nil { log.Fatalf("error binding to port %d\n: %s", port, err) diff --git a/git-desc.sh b/git-desc.sh new file mode 100755 index 0000000..6281632 --- /dev/null +++ b/git-desc.sh @@ -0,0 +1,6 @@ +#! /bin/bash + +tag=$(git describe --tags --dirty=-dev) +commit=$(git rev-parse HEAD | head -c8) +echo "STABLE_GIT_VERSION:$tag" +echo "STABLE_GIT_COMMIT:$commit" diff --git a/version.go b/version.go new file mode 100644 index 0000000..649c90a --- /dev/null +++ b/version.go @@ -0,0 +1,6 @@ +package gomud + +const ( + VERSION = "" + BUILD = "" +)