Skip to content

Commit

Permalink
Fixed version, setup version on build
Browse files Browse the repository at this point in the history
  • Loading branch information
msoap committed Oct 10, 2021
1 parent 2124e4f commit d261baa
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ builds:
flags:
- -trimpath
ldflags:
- '-s -w'
- -s -w -X main.version={{ .Version }}

nfpms:
-
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apk add --no-cache git
ADD . $GOPATH/src/github.com/msoap/shell2http
WORKDIR $GOPATH/src/github.com/msoap/shell2http
ENV CGO_ENABLED=0
RUN go build -v -trimpath -ldflags="-w -s" -o /go/bin/shell2http .
RUN go build -v -trimpath -ldflags="-w -s -X 'main.version=$(git describe --abbrev=0 --tags | sed s/v//)'" -o /go/bin/shell2http .

# final image
FROM alpine
Expand Down
6 changes: 3 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ func getConfig() (*Config, error) {
flag.PrintDefaults()
os.Exit(0)
}
version := flag.Bool("version", false, "get version")
getVersion := flag.Bool("version", false, "get version")

flag.Parse()

if *version {
fmt.Println(VERSION)
if *getVersion {
fmt.Println(version)
os.Exit(0)
}

Expand Down
2 changes: 1 addition & 1 deletion http_middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func mwLogging(handler http.HandlerFunc) http.HandlerFunc {
// mwCommonHeaders - set common headers
func mwCommonHeaders(handler http.HandlerFunc) http.HandlerFunc {
return func(rw http.ResponseWriter, req *http.Request) {
rw.Header().Set("Server", fmt.Sprintf("shell2http %s", VERSION))
rw.Header().Set("Server", fmt.Sprintf("shell2http %s", version))
handler.ServeHTTP(rw, req)
}
}
Expand Down
5 changes: 2 additions & 3 deletions shell2http.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import (
raphanuscommon "github.com/msoap/raphanus/common"
)

const (
// VERSION - version
VERSION = "1.13"
var version = "dev"

const (
// PORT - default port for http-server
PORT = 8080

Expand Down

0 comments on commit d261baa

Please sign in to comment.