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

feat: Use version from Goreleaser #148

Merged
merged 2 commits into from
Jul 17, 2024
Merged

feat: Use version from Goreleaser #148

merged 2 commits into from
Jul 17, 2024

Conversation

yngvark
Copy link
Contributor

@yngvark yngvark commented Jul 17, 2024

Description

See GoReleaser ldlflags.

By default, GoReleaser will set the following 3 ldflags:
main.version: Current Git tag (the v prefix is stripped) or the name of the snapshot, if you're using the --snapshot flag
main.commit: Current git commit SHA
main.date: Date in the RFC3339 format

This in turn setsversion, commit and date variables:

ok/main.go

Line 11 in af8801f

version = "dev"

This can be tested locally:

go build -ldflags "-X main.version=1.0.0 -X main.commit=abc1234 -X main.date=$(date +%Y-%m-%dT%H:%M:%SZ)" -o ok .

./ok version

Version: 1.0.0
Date:    2024-07-17T12:07:21Z
Commit:  abc1234

Motivation

ok version should match the actual released version from Goreleaser.

@yngvark yngvark requested a review from staticaland July 17, 2024 12:52
@yngvark yngvark merged commit 31fde97 into main Jul 17, 2024
1 check passed
@yngvark yngvark deleted the 0-ldlflags_version branch July 17, 2024 14:40
@okctl-bot okctl-bot mentioned this pull request Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants