Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Add build.sh to build backend with version info
天舟be5da41cfe00
diff --git a/backend/.gitignore b/backend/.gitignoreindex 843827b279..c40059797c 100644--- a/backend/.gitignore+++ b/backend/.gitignore@@ -23,5 +23,5 @@ dist# Dev databasedata-# Release folder-release\ No newline at end of file+# build folder+bytebase-build\ No newline at end of filediff --git a/backend/bin/server/cmd/version.go b/backend/bin/server/cmd/version.goindex c335feb252..fd3c35214f 100644--- a/backend/bin/server/cmd/version.go+++ b/backend/bin/server/cmd/version.go@@ -6,6 +6,13 @@ import ("github.com/spf13/cobra")+// These should be set via go build -ldflags -X 'xxxx'+var version = "development"+var goversion = "unknown"+var gitcommit = "unknown"+var buildtime = "unknown"+var builduser = "unknown"+func init() {rootCmd.AddCommand(versionCmd)}@@ -14,6 +21,10 @@ var versionCmd = &cobra.Command{Use: "version",Short: "Print the version number of Bytebase",Run: func(cmd *cobra.Command, args []string) {- fmt.Println("Bytebase server v0.1")+ fmt.Printf("Bytebase version: %s\n", version)+ fmt.Printf("Golang version: %s\n", goversion)+ fmt.Printf("Git commit hash: %s\n", gitcommit)+ fmt.Printf("Built on: %s\n", buildtime)+ fmt.Printf("Built by: %s\n", builduser)},}diff --git a/backend/build.sh b/backend/build.shnew file mode 100755index 0000000000..a91bba9724--- /dev/null+++ b/backend/build.sh@@ -0,0 +1,5 @@+#!/bin/sh++version=0.1.0+flags="-X 'github.com/bytebase/bytebase/bin/server/cmd.version=${version}' -X 'github.com/bytebase/bytebase/bin/server/cmd.goversion=$(go version)' -X 'github.com/bytebase/bytebase/bin/server/cmd.gitcommit=$(git rev-parse HEAD)' -X 'github.com/bytebase/bytebase/bin/server/cmd.buildtime=$(date) ($(date -u))' -X 'github.com/bytebase/bytebase/bin/server/cmd.builduser=$(id -u -n)'"+go build -ldflags "$flags" -o ./bytebase-build/bytebase ./bin/server/main.go\ No newline at end of file