From 918480eba1466f325367060fc3753c8b3b5b6b3a Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Thu, 9 Mar 2023 12:51:45 +0800 Subject: [PATCH] feat: get version info from git describe --- Dockerfile | 7 ++++--- cmd/xproxy.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 30aebf0..a3819d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,16 +21,17 @@ RUN git clone https://github.com/XTLS/Xray-core.git WORKDIR ./Xray-core/main/ RUN git checkout 4c8ee0af50bbabd29e6766f0d9509add6fc0b2e7 -RUN go get -d +RUN go get RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w" && mv main /tmp/xray COPY --from=upx /tmp/upx /usr/bin/ RUN upx -9 /tmp/xray FROM ${GOLANG} AS xproxy +RUN apk add git COPY ./ /XProxy/ WORKDIR /XProxy/cmd/ -RUN go get -d -RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w" && mv cmd /tmp/xproxy +RUN go get +RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.version=$(git describe --tag) -s -w" && mv cmd /tmp/xproxy COPY --from=upx /tmp/upx /usr/bin/ RUN upx -9 /tmp/xproxy diff --git a/cmd/xproxy.go b/cmd/xproxy.go index 40edffb..6d08b08 100644 --- a/cmd/xproxy.go +++ b/cmd/xproxy.go @@ -15,7 +15,7 @@ import ( "strconv" ) -var version = "1.0.2" +var version = "dev" var v4RouteTable = 104 var v6RouteTable = 106 var v4TProxyPort = 7288