Skip to content

Commit

Permalink
Merge pull request #35 from zenon-network/improve-git-hash
Browse files Browse the repository at this point in the history
Move getting git version into native build
  • Loading branch information
georgezgeorgez authored Oct 10, 2023
2 parents 6c0f970 + 41e3b28 commit 9eaedfa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/znn_builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ jobs:
# run: |
# go install golang.org/x/vuln/cmd/govulncheck@latest
# /home/runner/go/bin/govulncheck -json ./...
- name: Make version
run: make version
- name: Build znnd
uses: crazy-max/ghaction-xgo@588a1a9bc6aa44305ce5d2c669c11687316f87bf
with:
Expand Down
12 changes: 3 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all clean znnd version
.PHONY: all clean znnd

GO ?= latest

Expand All @@ -18,8 +18,8 @@ ifeq ($(detected_OS),Linux)
EXECUTABLE=libznn.so
endif

SERVERMAIN = $(shell pwd)/cmd/znnd/main.go
LIBMAIN = $(shell pwd)/cmd/libznn/main_libznn.go
SERVERMAIN = $(shell pwd)/cmd/znnd
LIBMAIN = $(shell pwd)/cmd/libznn
BUILDDIR = $(shell pwd)/build
GIT_COMMIT=$(shell git rev-parse HEAD)
GIT_COMMIT_FILE=$(shell pwd)/metadata/git_commit.go
Expand All @@ -35,12 +35,6 @@ znnd:
@echo "Build znnd done."
@echo "Run \"$(BUILDDIR)/znnd\" to start znnd."

version:
@echo "package metadata\n" > $(GIT_COMMIT_FILE)
@echo "const (" >> $(GIT_COMMIT_FILE)
@echo "\tGitCommit = \"${GIT_COMMIT}\"" >> $(GIT_COMMIT_FILE)
@echo ")" >> $(GIT_COMMIT_FILE)

clean:
rm -r $(BUILDDIR)/

Expand Down
15 changes: 12 additions & 3 deletions metadata/git_commit.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package metadata

const (
GitCommit = "7e9c440f7e5e368efbade77ca900efa1219af0d4"
)
import "runtime/debug"

var GitCommit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {
for _, setting := range info.Settings {
if setting.Key == "vcs.revision" {
return setting.Value
}
}
}
return ""
}()

0 comments on commit 9eaedfa

Please sign in to comment.