mirror of
https://github.com/Snawoot/opera-proxy.git
synced 2026-04-28 11:59:31 +00:00
use buildinfo for version information
This commit is contained in:
parent
d50d7a41f9
commit
158243ea14
4 changed files with 13 additions and 22 deletions
11
.github/workflows/docker-ci.yml
vendored
11
.github/workflows/docker-ci.yml
vendored
|
|
@ -14,16 +14,6 @@ jobs:
|
|||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
-
|
||||
name: Find Git Tag
|
||||
id: tagger
|
||||
uses: jimschubert/query-tag-action@v2
|
||||
with:
|
||||
include: 'v*'
|
||||
exclude: '*-rc*'
|
||||
commit-ish: 'HEAD'
|
||||
skip-unshallow: 'true'
|
||||
abbrev: 7
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
|
|
@ -59,4 +49,3 @@ jobs:
|
|||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: 'GIT_DESC=${{steps.tagger.outputs.tag}}'
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
FROM --platform=$BUILDPLATFORM golang:1 AS build
|
||||
|
||||
ARG GIT_DESC=undefined
|
||||
|
||||
WORKDIR /go/src/github.com/Snawoot/opera-proxy
|
||||
COPY . .
|
||||
ARG TARGETOS TARGETARCH
|
||||
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -a -tags netgo -ldflags '-s -w -extldflags "-static" -X main.version='"$GIT_DESC"
|
||||
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -a -tags netgo -ldflags '-s -w -extldflags "-static"'
|
||||
ADD https://curl.haxx.se/ca/cacert.pem /certs.crt
|
||||
RUN chmod 0644 /certs.crt
|
||||
|
||||
|
|
|
|||
5
Makefile
5
Makefile
|
|
@ -1,9 +1,8 @@
|
|||
PROGNAME = opera-proxy
|
||||
OUTSUFFIX = bin/$(PROGNAME)
|
||||
VERSION := $(shell git describe)
|
||||
BUILDOPTS = -a -tags netgo -trimpath -asmflags -trimpath
|
||||
LDFLAGS = -ldflags '-s -w -extldflags "-static" -X main.version=$(VERSION)'
|
||||
LDFLAGS_NATIVE = -ldflags '-s -w -X main.version=$(VERSION)'
|
||||
LDFLAGS = -ldflags '-s -w -extldflags "-static"'
|
||||
LDFLAGS_NATIVE = -ldflags '-s -w'
|
||||
|
||||
NDK_CC_ARM = $(abspath ../../ndk-toolchain-arm/bin/arm-linux-androideabi-gcc)
|
||||
NDK_CC_ARM64 = $(abspath ../../ndk-toolchain-arm64/bin/aarch64-linux-android21-clang)
|
||||
|
|
|
|||
15
main.go
15
main.go
|
|
@ -16,6 +16,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -35,10 +36,6 @@ const (
|
|||
PROXY_SUFFIX = "sec-tunnel.com"
|
||||
)
|
||||
|
||||
var (
|
||||
version = "undefined"
|
||||
)
|
||||
|
||||
func perror(msg string) {
|
||||
fmt.Fprintln(os.Stderr, "")
|
||||
fmt.Fprintln(os.Stderr, msg)
|
||||
|
|
@ -209,7 +206,7 @@ func proxyFromURLWrapper(u *url.URL, next xproxy.Dialer) (xproxy.Dialer, error)
|
|||
func run() int {
|
||||
args := parse_args()
|
||||
if args.showVersion {
|
||||
fmt.Println(version)
|
||||
fmt.Println(version())
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
@ -588,3 +585,11 @@ func retryPolicy(retries int, retryInterval time.Duration, logger *clog.CondLogg
|
|||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func version() string {
|
||||
bi, ok := debug.ReadBuildInfo()
|
||||
if !ok {
|
||||
return "unknown"
|
||||
}
|
||||
return bi.Main.Version
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue