Skip to content

Commit

Permalink
automatically embed git version in yagpdb binary on build
Browse files Browse the repository at this point in the history
  • Loading branch information
jogramming committed Oct 15, 2019
1 parent 1b9e095 commit 823c4f5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
8 changes: 7 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ jobs: # basic units of work in a run
keys:
- v1-pkg-cache

- run: cd cmd/yagpdb && go install -i && cd -
- run:
name: main yagpdb binary build
command: |
VERSION=$(git describe --tags)
cd cmd/yagpdb
go install -i -ldflags "-X github.com/jonas747/yagpdb/common.VERSION=${VERSION}"
cd -
- run: cd cmd/shardorchestrator && go install -i && cd -
- run: cd cmd/capturepanics && go install -i && cd -

Expand Down
4 changes: 4 additions & 0 deletions cmd/yagpdb/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
VERSION=$(git describe --tags)
echo Building version $VERSION
go build -ldflags "-X github.com/jonas747/yagpdb/common.VERSION=${VERSION}"
9 changes: 1 addition & 8 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,8 @@ import (
"github.com/volatiletech/sqlboiler/boil"
)

const (
VERSIONMAJOR = 1
VERSIONMINOR = 20
VERSIONPATCH = 10
)

var (
VERSIONNUMBER = fmt.Sprintf("%d.%d.%d", VERSIONMAJOR, VERSIONMINOR, VERSIONPATCH)
VERSION = VERSIONNUMBER
VERSION = "unknown"

GORM *gorm.DB
PQ *sql.DB
Expand Down
2 changes: 1 addition & 1 deletion reddit/redditbot.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (p *Plugin) StopFeed(wg *sync.WaitGroup) {
}

func UserAgent() string {
return fmt.Sprintf("YAGPDB:%s:%s (by /u/jonas747)", confClientID.GetString(), common.VERSIONNUMBER)
return fmt.Sprintf("YAGPDB:%s:%s (by /u/jonas747)", confClientID.GetString(), common.VERSION)
}

func setupClient() *reddit.Client {
Expand Down

0 comments on commit 823c4f5

Please sign in to comment.