Skip to content

Commit

Permalink
build: read the version from git tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Bensmann committed Oct 19, 2024
1 parent 00795ce commit f6ddae5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
22 changes: 13 additions & 9 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
#!/bin/sh
targets="linux,amd64"

rm -rf dist/

for i in $targets; do
IFS=","
set -- $i
# read the version from the git tag and remove the 'v' prefix
# if there is not tag, use the short commit hash
VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//')
if [ -z "$VERSION" ]; then
VERSION=$(git rev-parse --short HEAD)
fi
echo "VERSION=${VERSION}"

build() {
os=$1
arch=$2
echo "building $os:$arch"
GOOS=$os GOARCH=$arch go build -ldflags "-s -w" -o dist/mouseless .
GOOS=$os GOARCH=$arch go build -ldflags "-s -w -X main.version=$VERSION" -o dist/mouseless .
if [ $? != 0 ]; then
exit 1
fi
tar -czvf dist/mouseless-${os}-${arch}.tar.gz dist/mouseless
done

tar -czvf "dist/mouseless-${os}-${arch}.tar.gz" dist/mouseless
}

build linux amd64
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ import (
log "github.com/sirupsen/logrus"
)

const version = "0.2.0-dev"

const (
defaultConfigFile = ".config/mouseless/config.yaml"
)

var (
version string
configFile string

keyboardDevices []*keyboard.Device
Expand Down

0 comments on commit f6ddae5

Please sign in to comment.