fix version file generator

This commit is contained in:
c9s 2021-12-27 23:10:29 +08:00
parent 4ea4bfb3fa
commit 9b1783a92a
4 changed files with 18 additions and 9 deletions

View File

@ -123,10 +123,13 @@ dist-bbgo-darwin: \
dist: static dist-bbgo-linux dist-bbgo-darwin desktop dist: static dist-bbgo-linux dist-bbgo-darwin desktop
pkg/version/version.go: .FORCE pkg/version/version.go: .FORCE
bash utils/generate-version-file.sh > $@ BUILD_FLAGS="release" bash utils/generate-version-file.sh > $@
pkg/version/dev.go: .FORCE pkg/version/dev.go: .FORCE
VERSION_SUFFIX="-dev" bash utils/generate-version-file.sh > $@ BUILD_FLAGS="!release" VERSION_SUFFIX="-dev" bash utils/generate-version-file.sh > $@
dev-version: pkg/version/dev.go
git commit $< -m "update dev build version"
version: pkg/version/version.go pkg/version/dev.go migrations version: pkg/version/version.go pkg/version/dev.go migrations
git commit $< $(word 2,$^) -m "bump version to $(VERSION)" || true git commit $< $(word 2,$^) -m "bump version to $(VERSION)" || true

View File

@ -1,8 +1,8 @@
//go:build !release
// +build !release // +build !release
package version package version
const Version = "v1.21.0-b4044156-dev" const Version = "v1.21.0-4ea4bfb3-dev"
const VersionGitRef = "4ea4bfb3"
const VersionGitRef = "b4044156"

View File

@ -2,7 +2,7 @@
package version package version
const Version = "v1.21.0-b4044156" const Version = "v1.21.0-4ea4bfb3"
const VersionGitRef = "b4044156" const VersionGitRef = "4ea4bfb3"

View File

@ -1,18 +1,24 @@
#!/bin/bash #!/bin/bash
PACKAGE_NAME=version PACKAGE_NAME=version
REF=$(git show -s --format=%h -1) REF=$(git show -s --format=%h -1)
VERSION=$VERSION-$REF
if [[ -z $VERSION ]] ; then if [[ -z $VERSION ]] ; then
VERSION=$(git describe --tags) VERSION=$(git describe --tags)
fi fi
VERSION=$VERSION-$REF
if [[ -z $BUILD_FLAGS ]] ; then
BUILD_FLAGS=release
fi
if [[ -n $VERSION_SUFFIX ]] ; then if [[ -n $VERSION_SUFFIX ]] ; then
VERSION=${VERSION}${VERSION_SUFFIX} VERSION=${VERSION}${VERSION_SUFFIX}
fi fi
cat <<END cat <<END
// +build release // +build $BUILD_FLAGS
package $PACKAGE_NAME package $PACKAGE_NAME