Browse Source

unexport version

pull/169/head
aler9 5 years ago
parent
commit
359a7f0f2f
  1. 4
      Makefile
  2. 9
      main.go

4
Makefile

@ -124,7 +124,7 @@ release:
release-nodocker: release-nodocker:
$(eval export CGO_ENABLED=0) $(eval export CGO_ENABLED=0)
$(eval VERSION := $(shell git describe --tags)) $(eval VERSION := $(shell git describe --tags))
$(eval GOBUILD := go build -ldflags '-X main.Version=$(VERSION)') $(eval GOBUILD := go build -ldflags '-X main.version=$(VERSION)')
rm -rf tmp && mkdir tmp rm -rf tmp && mkdir tmp
rm -rf release && mkdir release rm -rf release && mkdir release
cp rtsp-simple-server.yml tmp/ cp rtsp-simple-server.yml tmp/
@ -157,7 +157,7 @@ COPY . ./
ARG VERSION ARG VERSION
ARG OPTS ARG OPTS
RUN export CGO_ENABLED=0 $${OPTS} \ RUN export CGO_ENABLED=0 $${OPTS} \
&& go build -ldflags "-X main.Version=$$VERSION" -o /rtsp-simple-server && go build -ldflags "-X main.version=$$VERSION" -o /rtsp-simple-server
FROM scratch FROM scratch
COPY --from=build /rtsp-simple-server / COPY --from=build /rtsp-simple-server /

9
main.go

@ -22,8 +22,7 @@ import (
"github.com/aler9/rtsp-simple-server/internal/stats" "github.com/aler9/rtsp-simple-server/internal/stats"
) )
// Version can be overridden by build flags. var version = "v0.0.0"
var Version = "v0.0.0"
type program struct { type program struct {
confPath string confPath string
@ -45,7 +44,7 @@ type program struct {
func newProgram(args []string) (*program, error) { func newProgram(args []string) (*program, error) {
k := kingpin.New("rtsp-simple-server", k := kingpin.New("rtsp-simple-server",
"rtsp-simple-server "+Version+"\n\nRTSP server.") "rtsp-simple-server "+version+"\n\nRTSP server.")
argVersion := k.Flag("version", "print version").Bool() argVersion := k.Flag("version", "print version").Bool()
argConfPath := k.Arg("confpath", "path to a config file. The default is rtsp-simple-server.yml.").Default("rtsp-simple-server.yml").String() argConfPath := k.Arg("confpath", "path to a config file. The default is rtsp-simple-server.yml.").Default("rtsp-simple-server.yml").String()
@ -53,7 +52,7 @@ func newProgram(args []string) (*program, error) {
kingpin.MustParse(k.Parse(args)) kingpin.MustParse(k.Parse(args))
if *argVersion == true { if *argVersion == true {
fmt.Println(Version) fmt.Println(version)
os.Exit(0) os.Exit(0)
} }
@ -129,7 +128,7 @@ func (p *program) createResources(initial bool) error {
} }
if initial { if initial {
p.Log("rtsp-simple-server %s", Version) p.Log("rtsp-simple-server %s", version)
} }
if p.conf.Metrics { if p.conf.Metrics {

Loading…
Cancel
Save