Skip to content

Commit 4e87c00

Browse files
committed
Fix build ldflags and build date string
1 parent 9c906a7 commit 4e87c00

2 files changed

Lines changed: 9 additions & 22 deletions

File tree

.github/workflows/release-test.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,15 @@ jobs:
5252
VERSION="0.0.0"
5353
fi
5454
55-
VERSION=${{ github.ref_name }}
5655
COMMIT=${{ github.sha }}
57-
DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
56+
DATE=$(date -u +"%Y-%m-%d at %H:%M:%S")
5857
5958
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} \
6059
go build \
6160
-ldflags "\
62-
-X constants.Version=$VERSION \
63-
-X constants.Commit=$COMMIT \
64-
-X constants.BuildDate=$DATE \
61+
-X sklair/constants.Version=$VERSION \
62+
-X sklair/constants.Commit=$COMMIT \
63+
-X sklair/constants.BuildDate=$DATE \
6564
" \
6665
-o dist/sklair-${{ matrix.os }}-${{ matrix.arch }}$EXT
6766

constants/version.go

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
11
package constants
22

3-
var (
4-
Version = "0.1.0" // to be replaced by ldflags during compile time in a GitHub runner
5-
Commit = "unknown" // likewise
6-
BuildDate = "unknown" // likewise, ISO-8601 UTC
3+
// these are replaced by ldflags during compile time on release
4+
const (
5+
Version = "0.0.0" // `MAJOR.MINOR.PATCH`, semantic versioning
6+
Commit = "unknown commit"
7+
BuildDate = "unknown date" // `YYYY-MM-DD at HH:MM:SS`
78
)
8-
9-
/*
10-
VERSION=v0.0.0
11-
COMMIT=$(git rev-parse --short HEAD)
12-
DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
13-
14-
go build \
15-
-ldflags "\
16-
-X sklair/constants.Version=$VERSION \
17-
-X sklair/constants.Commit=$COMMIT \
18-
-X sklair/constants.BuildDate=$DATE \
19-
"
20-
*/

0 commit comments

Comments
 (0)