Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print commit hash and build time. #212

Merged
merged 3 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
ro-tex marked this conversation as resolved.
Show resolved Hide resolved
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"))
}
log.Printf("Starting Accounts.\nGitRevision: %v (built %v)\n", build.GitRevision, build.BuildTime)
logger.Fatal(server.ListenAndServe(3000))
}