Skip to content

Set version in source code #295

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

Merged
merged 2 commits into from
Mar 14, 2023
Merged

Conversation

another-rex
Copy link
Collaborator

Set the release version in the source code.

An alternative to setting the version directly in source code is to get package repositories to build their osv-scanner with goreleaser instead of go directly. While goreleaser is often already in most repositories, it is not as straightforward:

  • Package repositories sometimes have their own guidelines for how to build go, e.g. Arch Linux go binaries must be built with hardened options which we currently do not do with goreleaser.
  • goreleaser also expects to be in a git repository (to get version tags), but most build systems prefers downloading the source code in a tarball instead of checking out the repository.

@another-rex another-rex requested a review from oliverchang March 14, 2023 01:07
@@ -13,7 +13,8 @@ import (
)

var (
version = "dev"
// Update this variable when doing a release
version = "1.2.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this have a "-dev" suffix by default in non-release build contexts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thought about that a bit, I feel like it probably should not, since it seems like all linux package repos will build their own version, the version of osv-scanner people get from them will then also have the -dev suffix, which I don't think is ideal.

The user can already tell if it's built by us directly or not by looking at whether "built on" and "commit" is filled out or not.

Copy link
Collaborator

Choose a reason for hiding this comment

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

SGTM, that makes sense.

@another-rex another-rex merged commit 2d67543 into google:main Mar 14, 2023
julieqiu pushed a commit to julieqiu/osv-scanner that referenced this pull request May 2, 2023
Set the release version in the source code. 

An alternative to setting the version directly in source code is to get
package repositories to build their osv-scanner with goreleaser instead
of go directly. While goreleaser is often already in most repositories,
it is not as straightforward:

- Package repositories sometimes have their own guidelines for how to
build go, e.g. Arch Linux go binaries must be built with hardened
options which we currently do not do with goreleaser.
- goreleaser also expects to be in a git repository (to get version
tags), but most build systems prefers downloading the source code in a
tarball instead of checking out the repository.
julieqiu pushed a commit to julieqiu/osv-scanner that referenced this pull request May 2, 2023
Set the release version in the source code. 

An alternative to setting the version directly in source code is to get
package repositories to build their osv-scanner with goreleaser instead
of go directly. While goreleaser is often already in most repositories,
it is not as straightforward:

- Package repositories sometimes have their own guidelines for how to
build go, e.g. Arch Linux go binaries must be built with hardened
options which we currently do not do with goreleaser.
- goreleaser also expects to be in a git repository (to get version
tags), but most build systems prefers downloading the source code in a
tarball instead of checking out the repository.
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