Skip to content

Commit 149162b

Browse files
another-rexjulieqiu
authored andcommitted
Set version in source code (google#295)
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.
1 parent 2736df1 commit 149162b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

cmd/osv-scanner/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import (
1313
)
1414

1515
var (
16-
version = "dev"
16+
// Update this variable when doing a release
17+
version = "1.2.0"
1718
commit = "n/a"
1819
date = "n/a"
1920
)

cmd/osv-scanner/main_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func TestRun(t *testing.T) {
118118
args: []string{"", "--version"},
119119
wantExitCode: 0,
120120
wantStdout: `
121-
osv-scanner version: dev
121+
osv-scanner version: 1.2.0
122122
commit: n/a
123123
built at: n/a
124124
`,

0 commit comments

Comments
 (0)