From 6c66b2857c2314e5e1edb413598e9ee8164c75be Mon Sep 17 00:00:00 2001 From: xvzc Date: Wed, 7 Aug 2024 07:32:35 +0900 Subject: [PATCH] add version module --- .version | 1 + cmd/spoof-dpi/main.go | 7 +++---- make-releases.sh | 2 -- version.go | 12 ++++++++++++ 4 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 .version create mode 100644 version.go diff --git a/.version b/.version new file mode 100644 index 0000000..b434d4c --- /dev/null +++ b/.version @@ -0,0 +1 @@ +v0.10.6 diff --git a/cmd/spoof-dpi/main.go b/cmd/spoof-dpi/main.go index 0398897..234e749 100644 --- a/cmd/spoof-dpi/main.go +++ b/cmd/spoof-dpi/main.go @@ -4,21 +4,20 @@ import ( "os" "os/signal" "syscall" + _ "embed" "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus" "github.com/xvzc/SpoofDPI/proxy" "github.com/xvzc/SpoofDPI/util" + "github.com/xvzc/SpoofDPI/version" ) -var VERSION = "v0.0.0(dev)" func main() { util.ParseArgs() config := util.GetConfig() if *config.Version { - println("spoog-dpi", VERSION) - println("\nA simple and fast anti-censorship tool written in Go.") - println("https://github.com/xvzc/SpoofDPI") + PrintVersion() os.Exit(0) } diff --git a/make-releases.sh b/make-releases.sh index fff1e42..50f0b84 100644 --- a/make-releases.sh +++ b/make-releases.sh @@ -1,7 +1,5 @@ #!/bin/bash -VERSION="v0.10.6" - for osarch in 'darwin/amd64' 'darwin/arm64' 'linux/amd64' 'linux/arm' 'linux/arm64' 'linux/mips' 'linux/mipsle'; do GOOS=${osarch%/*} GOARCH=${osarch#*/} go build -ldflags="-w -s -X main.VERSION=${VERSION}" github.com/xvzc/SpoofDPI/cmd/spoof-dpi && tar -zcvf spoof-dpi-${osarch%/*}-${osarch#*/}.tar.gz ./spoof-dpi && diff --git a/version.go b/version.go new file mode 100644 index 0000000..fa8029b --- /dev/null +++ b/version.go @@ -0,0 +1,12 @@ +package version + +import _ "embed" + +//go:embed .version +var VERSION string + +func PrintVersion() { + println("spoof-dpi", VERSION) + println("A simple and fast anti-censorship tool written in Go.") + println("https://github.com/xvzc/SpoofDPI") +}