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

fix: use correct tag when commit is tagged with both prerelease and release #218

Merged
merged 5 commits into from
Oct 7, 2024

Conversation

sbruens
Copy link

@sbruens sbruens commented Oct 7, 2024

Add a Git config specification to make goreleaser find the latest tag for a specific release, following this advice.

When you run goreleaser on a non-rc tag, the corresponding commit will always have 2 tags (the vX.X.X-rcY and vX.X.X tags) and goreleaser seems to be picking the wrong one, which puts the -rc variant first. This prevents someone from checking out the vX.X.X tag and running goreleaser.

@sbruens sbruens requested a review from a team as a code owner October 7, 2024 14:33
@sbruens sbruens requested a review from fortuna October 7, 2024 14:33
@sbruens
Copy link
Author

sbruens commented Oct 7, 2024

Actually this only resolves the problem when there are multiple tags, but will not work if the vX.X.X tag does not yet exist, which would happen if you run this for a new release candidate. I need to think about this a bit more.

@sbruens
Copy link
Author

sbruens commented Oct 7, 2024

Ok I changed the approach and updated the PR description accordingly.

@sbruens sbruens changed the title fix: set explicit build tag in release fix: remove -rc suffixfrom release name Oct 7, 2024
@sbruens sbruens changed the title fix: remove -rc suffixfrom release name fix: remove -rc suffix from release name Oct 7, 2024
.goreleaser.yml Outdated
@@ -39,7 +39,8 @@ builds:
goarch: 386

archives:
-
- name_template: >-
Copy link

Choose a reason for hiding this comment

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

Why remove the -rc from the filename? Isn't it better to make it clear it's a release candidate?

Copy link
Author

@sbruens sbruens Oct 7, 2024

Choose a reason for hiding this comment

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

Then we can't simply promote an -rc by creating a new tag, as we've been doing.

If we want to go the route where we keep the -rc in the filename, we'd have to either:

  1. Delete the existing assets, update the prerelease, and create new assets by running goreleaser again.
  2. Delete the existing pre-release and create a new release with new assets by running goreleaser again.
  3. Somehow change the name of all the assets and checksum file on the existing prerelease.

For 1 and 2 we run the risk of introducing (build environment) changes between the pre-release and the release that's published. Not sure how easy 3 is to automate, but it could be messy.

Copy link

Choose a reason for hiding this comment

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

I believe you are trying to simply upgrade the candidate binary. If that's what you want to do, can you confirm that the correct version (without the -rc) is being injected here:

. Otherwise you will need to figure out how to inject the version correctly, or rebuild like we used to.

For context, we didn't use to create a release for candidates, only set the tag. I think we created prereleases sometimes. Once confident about the candidate, the release was created. In that case you don't need all those steps you listed. vN-rc-M can be one prerelease and vn can be another. There was no need to edit releases.

Copy link
Author

@sbruens sbruens Oct 7, 2024

Choose a reason for hiding this comment

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

I'm okay with that approach. The less a developer needs to manually amend the release candidate, the better, so if we're rebuilding having separate GitHub releases is safer.

I can revert the file renaming part of this PR and update our process doc to avoid upgrading the candidates in the prerelease.

@sbruens sbruens changed the title fix: remove -rc suffix from release name fix: remove -rc suffix from release assets archive filenames Oct 7, 2024
@sbruens sbruens requested a review from fortuna October 7, 2024 18:39
@sbruens sbruens changed the title fix: remove -rc suffix from release assets archive filenames fix: use the latest tag when a commit is tagged with both prerelease and release Oct 7, 2024
@sbruens sbruens changed the title fix: use the latest tag when a commit is tagged with both prerelease and release fix: use correct tag when commit is tagged with both prerelease and release Oct 7, 2024
@sbruens sbruens merged commit 3dfecd8 into master Oct 7, 2024
5 checks passed
@sbruens sbruens deleted the sbruens/goreleaser branch October 7, 2024 19:27
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