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

[Bug]: .VERSION is wrong in --snapshot mode. #2415

Closed
3 tasks done
cimnine opened this issue Aug 19, 2021 · 6 comments
Closed
3 tasks done

[Bug]: .VERSION is wrong in --snapshot mode. #2415

cimnine opened this issue Aug 19, 2021 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@cimnine
Copy link
Contributor

cimnine commented Aug 19, 2021

What happened?

The template variable {{ .Version }} behaves differently when Goreleaser is invoked regularly vs. when it is invoked with --snapshot:

  • In regular mode it strips the v from the tag, i.e. if the tag is v1.2.3, then .Version becomes 1.2.3.
  • But in snapshot mode, this does not happen. So if the most recent tag is v1.2.3, then .Version becomes v1.2.3-snapshot.

We use .Version in docker.image_templates as follows:

dockers:
- image_templates:
  - "docker.io/foo/bar:v{{ .Version }}"

When we do a regular release, the image that is built becomes docker.io/foo/bar:v1.2.3. But when we build a snapshot, then the image that is built becomes docker.io/foo/bar:vv1.2.3-snapshot, which is unexpected.

How can we reproduce this?

Prepare

git clone https://github.com/cimnine/goreleaser-bug.git reproduce
cd reproduce

Correct Version

$ goreleaser release --skip-publish --rm-dist
[…]
   • docker images
      • building docker image     image=docker.io/foo/bar:v1.0.1
[…]

Incorrect Version

$ goreleaser release --skip-publish --rm-dist --snapshot
[…]
   • docker images
      • building docker image     image=docker.io/foo/bar:vv1.0.2-next
[…]

goreleaser version

goreleaser version 0.175.0
commit: 5e006eb236284c29143341e48c2f692826865d47
built by: homebrew

https://goreleaser.com

GoReleaser Check

  • goreleaser check shows no errors

Search

  • I did search for other open and closed issues before opening this.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Additional context

No response

@cimnine cimnine added the bug Something isn't working label Aug 19, 2021
@caarlos0
Copy link
Member

you can tweak that by changing snapshot.name_template: https://goreleaser.com/customization/snapshots/

probably you have the v prefix there.

@cimnine
Copy link
Contributor Author

cimnine commented Aug 19, 2021

Indeed, our snapshot.name_template was set to "{{ .Tag }}-snapshot instead of {{ .Version }}-snapshot. Thanks!

@cimnine
Copy link
Contributor Author

cimnine commented Aug 19, 2021

I just checked: It is the default behaviour (i.e. goreleaser init) that snapshot.name_template is set to "{{ incpatch .Tag }}-next".

Maybe that could/should be adjusted to "{{ incpatch .Version }}-next"?

cimnine added a commit to k8up-io/k8up that referenced this issue Aug 19, 2021
@caarlos0
Copy link
Member

yeah, I think it makes sense, can you open a pr?

@cimnine
Copy link
Contributor Author

cimnine commented Aug 20, 2021

yeah, I think it makes sense, can you open a pr?

Sure, see #2417.

@github-actions
Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants