Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set version and build date for 'version' command. #2

Merged
merged 2 commits into from
May 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ jobs:
strategy:
matrix:
target:
- 'windows/amd64'
- 'windows/386'
- 'windows/arm64'
- 'linux/amd64'
- 'linux/386'
- 'linux/arm64'
- 'linux/arm'
# - 'windows/amd64'
# - 'windows/386'
# - 'windows/arm64'
# - 'linux/amd64'
# - 'linux/386'
# - 'linux/arm64'
# - 'linux/arm'
- 'darwin/amd64'
- 'darwin/arm64'
- 'freebsd/386'
- 'freebsd/amd64'
- 'freebsd/arm'
- 'openbsd/amd64'
- 'openbsd/arm64'
# - 'freebsd/386'
# - 'freebsd/amd64'
# - 'freebsd/arm'
# - 'openbsd/amd64'
# - 'openbsd/arm64'
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -70,10 +70,12 @@ jobs:
set -euo pipefail

VERSION=${GITHUB_REF#refs/tags/v}
COMMIT=$(git rev-parse HEAD)
DATE=$(date +'%FT%TZ%z')
NAME="snip_${VERSION}_${GOOS}_${GOARCH}"

CGO_ENABLED=0 go build -v \
-ldflags "-X main.Version=`${VERSION}` -X main.Commit=`git rev-parse HEAD` -X main.Date=`date +'%FT%TZ%z'`" .
-ldflags "-X main.Version=$VERSION -X main.Commit=$COMMIT -X main.Date=$DATE" .

if [[ "$GOOS" != "windows" ]]; then
tar -czf "$NAME.tar.gz" snip
Expand Down
Loading