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

Include git commit in version #1347

Merged
merged 5 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all 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: 5 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ main() {
exit 1
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("%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
Loading