Skip to content

Commit

Permalink
Print commit hash and build time.
Browse files Browse the repository at this point in the history
  • Loading branch information
ro-tex committed May 31, 2022
1 parent 31bf525 commit 610c5d4
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# These variables get inserted into ./build/commit.go
BUILD_TIME=$(shell date)
BUILD_TIME=$(shell date -u)
GIT_REVISION=$(shell git rev-parse --short HEAD)
GIT_DIRTY=$(shell git diff-index --quiet HEAD -- || echo "✗-")

ldflags= -X github.com/SkynetLabs/skynet-accounts/build.GitRevision=${GIT_DIRTY}${GIT_REVISION} \
ldflags= -X "github.com/SkynetLabs/skynet-accounts/build.GitRevision=${GIT_DIRTY}${GIT_REVISION}" \
-X "github.com/SkynetLabs/skynet-accounts/build.BuildTime=${BUILD_TIME}"

racevars= history_size=3 halt_on_error=1 atexit_sleep_ms=2000
Expand Down Expand Up @@ -124,7 +124,7 @@ dev-race:

# release builds and installs release binaries.
release:
go install -tags='netgo' -ldflags='-s -w $(ldflags)' $(release-pkgs)
go install -tags='netgo dev' -ldflags='-s -w $(ldflags)' $(release-pkgs)
release-race:
GORACE='$(racevars)' go install -race -tags='netgo' -ldflags='-s -w $(ldflags)' $(release-pkgs)
release-util:
Expand Down
9 changes: 9 additions & 0 deletions build/build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package build

// GitRevision and BuildTime get assigned via the Makefile when built.
var (
// GitRevision is the git commit hash used when built
GitRevision string
// BuildTime is the date and time the build was completed
BuildTime string
)
6 changes: 6 additions & 0 deletions build/debug_off.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// +build !debug

package build

// DEBUG set to false turns the debugging off
const DEBUG = false
6 changes: 6 additions & 0 deletions build/debug_on.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// +build debug

package build

// DEBUG set to true turns the debugging on
const DEBUG = true
6 changes: 6 additions & 0 deletions build/release_dev.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// +build dev

package build

// Release refers to the dev release mode.
const Release = "dev"
6 changes: 6 additions & 0 deletions build/release_standard.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// +build !testing,!dev

package build

// Release refers to the standard release mode.
const Release = "standard"
6 changes: 6 additions & 0 deletions build/release_testing.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// +build testing

package build

// Release refers to the testing release mode.
const Release = "testing"
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"strings"

"github.com/SkynetLabs/skynet-accounts/api"
"github.com/SkynetLabs/skynet-accounts/build"
"github.com/SkynetLabs/skynet-accounts/database"
"github.com/SkynetLabs/skynet-accounts/email"
"github.com/SkynetLabs/skynet-accounts/jwt"
"github.com/SkynetLabs/skynet-accounts/metafetcher"
"github.com/joho/godotenv"
"github.com/stripe/stripe-go/v72"
"gitlab.com/SkynetLabs/skyd/build"
"gitlab.com/SkynetLabs/skyd/skymodules"

"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -264,5 +264,6 @@ func main() {
if err != nil {
log.Fatal(errors.AddContext(err, "failed to build the API"))
}
fmt.Printf("Starting Accounts.\nGitRevision: %v (built %v)\n", build.GitRevision, build.BuildTime)
logger.Fatal(server.ListenAndServe(3000))
}

0 comments on commit 610c5d4

Please sign in to comment.