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

Support simplified building and go get #98

Merged
merged 2 commits into from
Jun 1, 2020
Merged

Support simplified building and go get #98

merged 2 commits into from
Jun 1, 2020

Conversation

paultyng
Copy link
Contributor

I modified the usage of ldflags to support the goreleaser default variables it fills in and removed the build target from the Makefile. I think in the docs we should just encourage people to use goreleaser --snapshot locally, unfortunately you can't seem to skip the Artifactory step currently.

Curl / Make are not available by default on Windows, and we should probably make it more approachable for as many devs as possible to contribute. Considering the length of the Makefile now we could also just remove it but we should definitely call out the vendor usage for a canonical test environment.

@paultyng
Copy link
Contributor Author

This would address #88

@paultyng paultyng linked an issue May 13, 2020 that may be closed by this pull request
@radeksimko radeksimko marked this pull request as ready for review May 15, 2020 14:57
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

I like the simplification in general. I left you some comments inline - I'm happy to address these myself next week, but I wanted to share that feedback before touching the code myself.


As a side note I still think there's value in the identification of dev builds and I'd like to address that by adding some form of sed && git commit probably inside GitHub Actions. That might also explain why I think it's good to keep these variables in a separate file. Cutting releases via goreleaser --snapshot is fine, but not everyone's going to do that I think, also because it builds all platforms at the same time.

main.go Outdated
version string = `dev`
commit string = ``
date string = ``
builtBy string = ``
Copy link
Member

Choose a reason for hiding this comment

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

As discussed offline I'm ok with these variables being in main package - as we can pass them down to wherever they're needed and it is better than global state in version package.

However (1) I think it'd be cleaner to still keep them in a separate file and (2) it would be better to retain some of the logic from the version package:

  • variable names version/prerelease - which can be un-exported, but I think we should retain the meaning and avoid setting version to dev. I'd say the meaningful default is version = "0.0.0" prerelease = "dev"
  • semver check via init() - which won't be panicing on go get/build/install anymore if version defaults to 0.0.0, but still gives us safety net against building a version which isn't semver-compatible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A separate file is a good call.

Why have separate fields? It gets complicated for snapshots as its already going to send a prerelease string to the version (ie. 1.2.3-SNAPSHOT-hash) or if your goreleaser tag is prerelease, it will mess it up wouldn't it? As the version var and the prerelease var will kinda be redundant. Could just do version string = "0.0.0-dev" couldn't you?

Copy link
Member

Choose a reason for hiding this comment

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

As for GoReleaser - it may do by default, but it won't with custom ldflags, like we have now (without this patch), except that these flags would be less verbose with variables being in main.

As for why - I don't have any better reason other than keeping it aligned with other HashiCorp Go projects (terraform, packer, consul, vault, nomad).

That said I appreciate you challenging this convention and I have not asked teams why they do it and if they still feel this is right in today's context, as the separate package thing probably isn't in retrospect and this may be just a relic of some inflexible release tooling we may still have in place.

So I'll ask around next week - and if there are no strong opinions/reasons then I'm happy to go ahead with the "GoReleaser style" you're proposing! 😄

@radeksimko
Copy link
Member

As discussed/clarified via DMs I have opened goreleaser/goreleaser#1532

@radeksimko
Copy link
Member

goreleaser/goreleaser#1557 will be part of the next GoReleaser release, which means we can leverage RawVersion, Prerelease and IsSnapshot variables in the config and retain the variable names and meanings as we use in other HashiCorp projects and still use GoReleaser's snapshot builds.

https://goreleaser-git-f-snapshot-versioning.goreleaser.now.sh/customization/templates/

We can put this PR hold temporarily until the next release comes out as that should happen 🔜

@radeksimko radeksimko added the ci Continuous integration/delivery related label May 26, 2020
This makes building and installing simpler by relying on default behavior from goreleaser, we can encourage users to use `goreleaser --snapshot` to create local builds if they need them, simplifying the usage story on Windows and allowing this to be go-gettable.
@radeksimko radeksimko merged commit bde83f4 into master Jun 1, 2020
@radeksimko radeksimko deleted the build-windows branch June 1, 2020 09:16
@ghost
Copy link

ghost commented Jul 1, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the context necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Jul 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ci Continuous integration/delivery related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make project go get-able
2 participants