Skip to content

Commit

Permalink
fix version file generator
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Dec 27, 2021
1 parent 4ea4bfb commit 9b1783a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,13 @@ dist-bbgo-darwin: \
dist: static dist-bbgo-linux dist-bbgo-darwin desktop

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
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
git commit $< $(word 2,$^) -m "bump version to $(VERSION)" || true
Expand Down
6 changes: 3 additions & 3 deletions pkg/version/dev.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//go:build !release
// +build !release

package version

const Version = "v1.21.0-b4044156-dev"
const Version = "v1.21.0-4ea4bfb3-dev"

const VersionGitRef = "4ea4bfb3"

const VersionGitRef = "b4044156"
4 changes: 2 additions & 2 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

package version

const Version = "v1.21.0-b4044156"
const Version = "v1.21.0-4ea4bfb3"

const VersionGitRef = "b4044156"
const VersionGitRef = "4ea4bfb3"

10 changes: 8 additions & 2 deletions utils/generate-version-file.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
#!/bin/bash
PACKAGE_NAME=version
REF=$(git show -s --format=%h -1)
VERSION=$VERSION-$REF

if [[ -z $VERSION ]] ; then
VERSION=$(git describe --tags)
fi

VERSION=$VERSION-$REF

if [[ -z $BUILD_FLAGS ]] ; then
BUILD_FLAGS=release
fi


if [[ -n $VERSION_SUFFIX ]] ; then
VERSION=${VERSION}${VERSION_SUFFIX}
fi

cat <<END
// +build release
// +build $BUILD_FLAGS
package $PACKAGE_NAME
Expand Down

0 comments on commit 9b1783a

Please sign in to comment.