Improve earthly build, tweak caching

This commit is contained in:
Daniel
2024-04-10 14:11:31 +02:00
parent 2f88d487a9
commit 313ed4de4b
2 changed files with 92 additions and 26 deletions

14
cmds/portmaster-core/build Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
# Gather build metadata.
VERSION=$(git tag --points-at)
if [[ -z "$VERSION" ]]; then
VERSION=$(git describe --tags --abbrev=0 || echo "dev_build")
fi
SOURCE=$( ( git remote -v | cut -f2 | cut -d" " -f1 | head -n 1 ) || echo "unknown_source" )
BUILD_TIME=$(date -u "+%Y-%m-%dT%H:%M:%SZ" || echo "unknown_build_time")
# Build
CGO_ENABLED=0
BUILD_PATH="github.com/safing/portbase/info"
go build -ldflags "-X github.com/safing/portbase/info.version=${VERSION} -X github.com/safing/portbase/info.buildSource=${SOURCE} -X github.com/safing/portbase/info.buildTime=${BUILD_TIME}" "$@"