Skip to content

Commit

Permalink
Added git commit id and git commit description for version info
Browse files Browse the repository at this point in the history
  • Loading branch information
rprakashg committed Apr 19, 2019
1 parent 5c46b5b commit 3a4973f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"

RUN go test $(go list ./...) -cover \
&& VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///') \
&& GIT_COMMIT=$(git rev-list -1 HEAD) \
&& GIT_COMMIT_ID=$(git rev-list -1 HEAD) \
&& GIT_COMMIT_DESC=$(git log -1) \
&& CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build --ldflags "-s -w \
-X github.com/appsbyram/seafoodtruck-slack/version.Version=${VERSION} \
-X github.com/appsbyram/seafoodtruck-slack/version.GitCommitDescription=${GIT_COMMIT}" \
-X github.com/appsbyram/seafoodtruck-slack/version.GitCommitID=${GIT_COMMIT_ID} \
-X github.com/appsbyram/seafoodtruck-slack/version.GitCommitDescription=${GIT_COMMIT_DESC}" \
-a -installsuffix cgo -o bot

FROM alpine:latest
Expand Down
3 changes: 2 additions & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ func homeHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
json := fmt.Sprintf(`{
"Version": "%s",
"GitCommitID": "%s",
"GitCommitDescription": "%s"
}`, version.Version, version.GitCommitDescription)
}`, version.Version, version.GitCommitID, version.GitCommitDescription)

buffer = []byte(json)
w.Write(buffer)
Expand Down
Binary file modified seafoodtruck-slack
Binary file not shown.
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package version

var (
Version, GitCommitDescription string
Version, GitCommitID, GitCommitDescription string
)

0 comments on commit 3a4973f

Please sign in to comment.