Skip to content

Commit

Permalink
Include git commit in version
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <[email protected]>
  • Loading branch information
timvaillancourt committed Dec 7, 2023
1 parent 94463cf commit 3a44138
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ main() {
RELEASE_VERSION=$(cat RELEASE_VERSION)
fi

if [ -z "${GIT_COMMIT}" ]; then
GIT_COMMIT=$(git rev-parse HEAD)
fi

buildpath=/tmp/gh-ost-release
target=gh-ost
timestamp=$(date "+%Y%m%d%H%M%S")
ldflags="-X main.AppVersion=${RELEASE_VERSION}"
ldflags="-X main.AppVersion=${RELEASE_VERSION} -X main.GitCommit=${GIT_COMMIT}"

mkdir -p ${buildpath}
rm -rf ${buildpath:?}/*
Expand Down
6 changes: 3 additions & 3 deletions go/cmd/gh-ost/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"golang.org/x/term"
)

var AppVersion string
var AppVersion, GitCommit string

// acceptSignals registers for OS signals
func acceptSignals(migrationContext *base.MigrationContext) {
Expand Down Expand Up @@ -165,7 +165,7 @@ func main() {
if appVersion == "" {
appVersion = "unversioned"
}
fmt.Println(appVersion)
fmt.Printf("gh-ost version: %s, git commit: %s", appVersion, GitCommit)
return
}

Expand Down Expand Up @@ -308,7 +308,7 @@ func main() {
migrationContext.Log.Errore(err)
}

log.Infof("starting gh-ost %+v", AppVersion)
log.Infof("starting gh-ost %+v (git commit: %s)", AppVersion, GitCommit)
acceptSignals(migrationContext)

migrator := logic.NewMigrator(migrationContext, AppVersion)
Expand Down

0 comments on commit 3a44138

Please sign in to comment.