Skip to content

Commit

Permalink
Fix version metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed Apr 11, 2024
1 parent bc96ee4 commit ed20c7f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
9 changes: 6 additions & 3 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,17 @@ go-base:

LET version = $(git tag --points-at)
IF [ "${version}" = "" ]
SET version = $(git describe --tags --abbrev=0 || echo "dev_build")
SET version = "$(git describe --tags --abbrev=0)_dev_build"
END
IF [ "${version}" = "" ]
SET version = "dev_build"
END
ENV VERSION="${version}"

LET source = $( ( git remote -v | cut -f2 | cut -d" " -f1 | head -n 1 ) || echo "unknown_source" )
LET source = $( ( git remote -v | cut -f2 | cut -d" " -f1 | head -n 1 ) || echo "unknown" )
ENV SOURCE="${source}"

LET build_time = $(date -u "+%Y-%m-%dT%H:%M:%SZ" || echo "unknown_build_time")
LET build_time = $(date -u "+%Y-%m-%dT%H:%M:%SZ" || echo "unknown")
ENV BUILD_TIME = "${build_time}"

# Explicitly cache here.
Expand Down
11 changes: 4 additions & 7 deletions cmds/portmaster-core/build
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/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")
VERSION="$(git tag --points-at)"; test -z "$VERSION" && VERSION="$(git describe --tags --abbrev=0)_dev_build"; test -z "$VERSION" && VERSION="dev_build"
SOURCE=$( ( git remote -v | cut -f2 | cut -d" " -f1 | head -n 1 ) || echo "unknown" )
BUILD_TIME=$(date -u "+%Y-%m-%dT%H:%M:%SZ" || echo "unknown")

# Build
CGO_ENABLED=0
export 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}" "$@"
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ require (
github.com/r3labs/diff/v3 v3.0.1
github.com/rot256/pblind v0.0.0-20231024115251-cd3f239f28c1
github.com/safing/jess v0.3.3
github.com/safing/portbase v0.19.1
github.com/safing/portbase v0.19.3
github.com/safing/portmaster-android/go v0.0.0-20230830120134-3226ceac3bec
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/spf13/cobra v1.8.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ github.com/safing/portbase v0.19.0 h1:2T6f/w90IdIsSgUfyXoveqZM7tVwW+IFrtLbPVXtY3
github.com/safing/portbase v0.19.0/go.mod h1:Qrh3ck+7VZloFmnozCs9Hj8godhJAi55cmiDiC7BwTc=
github.com/safing/portbase v0.19.1 h1:Uk/WyP9HsIJrCn0pE4a7AWIrfUSHyCOObQyRmXsGQ9A=
github.com/safing/portbase v0.19.1/go.mod h1:Qrh3ck+7VZloFmnozCs9Hj8godhJAi55cmiDiC7BwTc=
github.com/safing/portbase v0.19.2 h1:qGF5Jv9eEE33d2aIxeBQdnitnBoF44BGVFtboqfE+1A=
github.com/safing/portbase v0.19.2/go.mod h1:Qrh3ck+7VZloFmnozCs9Hj8godhJAi55cmiDiC7BwTc=
github.com/safing/portbase v0.19.3 h1:fzb4d2nzhmRq4Lt6sgn9R20iykireAkBNyf9pfGqQjk=
github.com/safing/portbase v0.19.3/go.mod h1:Qrh3ck+7VZloFmnozCs9Hj8godhJAi55cmiDiC7BwTc=
github.com/safing/portmaster-android/go v0.0.0-20230830120134-3226ceac3bec h1:oSJY1seobofPwpMoJRkCgXnTwfiQWNfGMCPDfqgAEfg=
github.com/safing/portmaster-android/go v0.0.0-20230830120134-3226ceac3bec/go.mod h1:abwyAQrZGemWbSh/aCD9nnkp0SvFFf/mGWkAbOwPnFE=
github.com/safing/spn v0.7.5 h1:WfkMs2omLrwxBWccGGG9Akx0AvsvJLG+W7rjWQpQhl4=
Expand Down

0 comments on commit ed20c7f

Please sign in to comment.