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: fill version with git and ldflags #180

Merged
merged 3 commits into from
May 14, 2024

Conversation

kachick
Copy link
Contributor

@kachick kachick commented May 12, 2024

Suggestion

I want to resolve two things in this PR.

  • Fill revision with git ref
  • Prevent missing to bump the version string

Background

https://github.com/google/yamlfmt/releases/tag/v0.12.1

This is my omitted part in #117 πŸ™‡β€β™‚οΈ

Example

Before

goreleaser

> goreleaser build --single-target --snapshot --clean
> ./dist/yamlfmt_linux_amd64_v1/yamlfmt --version
0.12.2-next

go build / go install

> make build
> ./dist/yamlfmt -version
0.12.0

After

goreleaser

> goreleaser build --single-target --snapshot --clean
> ./dist/yamlfmt_linux_amd64_v1/yamlfmt -version
yamlfmt 0.12.2-next (1a88c3d)

go build / go install

> make build
> ./dist/yamlfmt -version
yamlfmt 0.12.1 (1a88c3d)

* Respect goreleaser default except using short hash

* Manually set values with git in Makefile as same as goreleaser
Copy link
Collaborator

@braydonk braydonk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much! This frees up time for me this release cycle, I appreciate it. πŸ˜„

I had two questions, one here in the review and one other I will post, but I'm pretty sure it LGTM!

.goreleaser.yaml Outdated Show resolved Hide resolved
@braydonk
Copy link
Collaborator

In the PR description I see that for goreleaser is has 0.12.2-next, and when built directly it doesn't. That seems backwards to me, I would think building locally would have some kind of -dev or -next suffix and the goreleaser version wouldn't. Am I understanding that right?

@kachick
Copy link
Contributor Author

kachick commented May 13, 2024

In my understanding, using --snapshot applied the -next suffix.

And current release action is not enabling it.
I have tested the behavior with my forked repository.

kachick#2
https://github.com/kachick/yamlfmt/actions/runs/9056974116/job/24880263306
https://github.com/kachick/yamlfmt/releases/tag/v0.13.0-pre3

-pre3 is added tag by me, and -next is not applied in the version string


If using goreleaser 1.25.1 and tagged with v0.42.42

  • goreleaser build --single-target --clean: yamlfmt 0.42.42 (e42ab16)
  • goreleaser build --single-target --snapshot --clean: yamlfmt 0.42.43-next (e42ab16)
  • make build: yamlfmt 0.42.42 (e42ab16)

Copy link
Collaborator

@braydonk braydonk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@braydonk braydonk merged commit 7f77800 into google:main May 14, 2024
7 checks passed
@kachick
Copy link
Contributor Author

kachick commented May 14, 2024

Thank you!

@kachick kachick deleted the version-with-ldflags branch May 14, 2024 12:18
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.

None yet

2 participants