add version files

This commit is contained in:
c9s 2021-02-22 15:16:12 +08:00
parent 59d68e7f0d
commit f7c952f8ca
5 changed files with 37 additions and 7 deletions

View File

@ -21,16 +21,16 @@ $(BIN_DIR):
mkdir -p $@
bbgo-linux: $(BIN_DIR)
GOOS=linux GOARCH=$(TARGET_ARCH) go build -tags web -o $(BIN_DIR)/$@ ./cmd/bbgo
GOOS=linux GOARCH=$(TARGET_ARCH) go build -tags web,release -o $(BIN_DIR)/$@ ./cmd/bbgo
bbgo-darwin: $(BIN_DIR)
GOOS=darwin GOARCH=$(TARGET_ARCH) go build -tags web -o $(BIN_DIR)/$@ ./cmd/bbgo
GOOS=darwin GOARCH=$(TARGET_ARCH) go build -tags web,release -o $(BIN_DIR)/$@ ./cmd/bbgo
bbgo-darwin-slim: $(BIN_DIR)
GOOS=darwin GOARCH=$(TARGET_ARCH) go build -o $(BIN_DIR)/$@ ./cmd/bbgo
GOOS=darwin GOARCH=$(TARGET_ARCH) go build -tags release -o $(BIN_DIR)/$@ ./cmd/bbgo
bbgo-linux-slim: $(BIN_DIR)
GOOS=linux GOARCH=$(TARGET_ARCH) go build -o $(BIN_DIR)/$@ ./cmd/bbgo
GOOS=linux GOARCH=$(TARGET_ARCH) go build -tags release -o $(BIN_DIR)/$@ ./cmd/bbgo
clean:
rm -rf $(BUILD_DIR) $(DIST_DIR) $(FRONTEND_EXPORT_DIR)
@ -63,6 +63,11 @@ dist: static bbgo-linux bbgo-linux-slim bbgo-darwin bbgo-darwin-slim desktop
mkdir -p $(DIST_DIR)
tar -C $(BUILD_DIR) -cvzf $(DIST_DIR)/bbgo-$$(git describe --tags).tar.gz .
pkg/version/version.go: .git/HEAD
bash utils/generate-version-file.sh > $@
version: pkg/version/version.go
migrations:
rockhopper compile --config rockhopper_mysql.yaml --output pkg/migrations/mysql
rockhopper compile --config rockhopper_sqlite.yaml --output pkg/migrations/sqlite3
@ -87,4 +92,4 @@ embed: pkg/server/assets.go
static: frontend/out/index.html pkg/server/assets.go
.PHONY: bbgo dist migrations static embed desktop .FORCE
.PHONY: bbgo version dist migrations static embed desktop .FORCE

View File

@ -22,15 +22,16 @@ import (
log "github.com/sirupsen/logrus"
"github.com/c9s/bbgo/pkg/util"
"github.com/c9s/bbgo/pkg/version"
)
const (
// ProductionAPIURL is the official MAX API v2 Endpoint
ProductionAPIURL = "https://max-api.maicoin.com/api/v2"
UserAgent = "bbgo/1.0"
UserAgent = "bbgo/" + version.Version
defaultHTTPTimeout = time.Second * 15
defaultHTTPTimeout = time.Second * 30
)
var logger = log.WithField("exchange", "max")

5
pkg/version/dev.go Normal file
View File

@ -0,0 +1,5 @@
// +build !release
package version
const Version = "1.x-dev"

6
pkg/version/version.go Normal file
View File

@ -0,0 +1,6 @@
// +build release
package version
const Version = "v1.11.1-32-g1e205b1"

View File

@ -0,0 +1,13 @@
#!/bin/bash
packageName=version
version=$(git describe --tags)
cat <<END
// +build release
package $packageName
const Version = "${version}"
END