Skip to content

Commit

Permalink
Add version while building binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
unkaktus committed Oct 7, 2024
1 parent b0add4d commit a93ed6d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cmd/robin/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/bin/bash
set -e

env GOOS=linux GOARCH=amd64 go build -o robin-linux-amd64
env GOOS=linux GOARCH=arm64 go build -o robin-linux-arm64
env GOOS=darwin GOARCH=amd64 go build -o robin-darwin-amd64
env GOOS=darwin GOARCH=arm64 go build -o robin-darwin-arm64
PROGRAM=robin
VERSION=$(git describe --exact-match --tags)
echo $VERSION
LDFLAGS="-X main.version=$VERSION"

env GOOS=linux GOARCH=amd64 go build -ldflags "$LDFLAGS" -o $PROGRAM-linux-amd64
env GOOS=linux GOARCH=arm64 go build -ldflags "$LDFLAGS" -o $PROGRAM-linux-arm64
env GOOS=darwin GOARCH=amd64 go build -ldflags "$LDFLAGS" -o $PROGRAM-darwin-amd64
env GOOS=darwin GOARCH=arm64 go build -ldflags "$LDFLAGS" -o $PROGRAM-darwin-arm64
2 changes: 2 additions & 0 deletions cmd/robin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
)

var (
version string
errUnsupported error = errors.New("unsupported batch system")
)

Expand Down Expand Up @@ -51,6 +52,7 @@ func run() (err error) {
Email: "git@unkaktus.art",
},
},
Version: version,
Commands: []*cli.Command{
{
Name: "list",
Expand Down

0 comments on commit a93ed6d

Please sign in to comment.