Skip to content

Commit 5df7d98

Browse files
craig[bot]dcrostaspilchen
committed
142900: use github.com/cockroachdb/version instead of pkg/util/version r=dcrosta a=dcrosta CRDB versions are not semantic versions [1], but the version library was designed to work with & correctly handle semvers. This change adopts the version library from Cockroach Cloud (now extracted to its own shared repo) to: * More-strictly validate actual, valid CockroachDB versions * Correctly order actual CockroachDB versions [2] * Add a MajorVersion type to capture & order CRDB major versions * Remove the word "minor" from the Version type [1] [1] The "minor" version -- the Y in vX.Y.Z -- does not carry the same meaning as in semver [2] In particular, the "-cloudonly" release phase should sort after "-rc"; semver sorts these phases alphabetically, but we must not, in order to correctly order versions Epic: None Issue: RE-814 Release note: None 143158: sql/schemachanger: require table ownership for RLS DDL operations r=spilchen a=spilchen Previously, executing row-level security (RLS) DDL statements (e.g., CREATE POLICY, DROP POLICY) required only the CREATE privilege. This change updates the requirement so that only the table owner can perform these operations, aligning with postgres' behaviour. Closes #143080 Epic: CRDB-45203 Release note: none Co-authored-by: Dan Crosta <[email protected]> Co-authored-by: Matt Spilchen <[email protected]>
3 parents 9ca8917 + 6e47a67 + 474d6c2 commit 5df7d98

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+396
-661
lines changed

DEPS.bzl

+13-3
Original file line numberDiff line numberDiff line change
@@ -1971,6 +1971,16 @@ def go_deps():
19711971
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/ttycolor/com_github_cockroachdb_ttycolor-v0.0.0-20210902133924-c7d7dcdde4e8.zip",
19721972
],
19731973
)
1974+
go_repository(
1975+
name = "com_github_cockroachdb_version",
1976+
build_file_proto_mode = "disable_global",
1977+
importpath = "github.com/cockroachdb/version",
1978+
sha256 = "4e734ab8c4e4ff81003fedffa30dc5727f9b210c72a188ee3127eeedea09f644",
1979+
strip_prefix = "github.com/cockroachdb/[email protected]",
1980+
urls = [
1981+
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/version/com_github_cockroachdb_version-v0.0.0-20250314144055-3860cd14adf2.zip",
1982+
],
1983+
)
19741984
go_repository(
19751985
name = "com_github_codahale_hdrhistogram",
19761986
build_file_proto_mode = "disable_global",
@@ -8586,10 +8596,10 @@ def go_deps():
85868596
name = "com_github_stretchr_testify",
85878597
build_file_proto_mode = "disable_global",
85888598
importpath = "github.com/stretchr/testify",
8589-
sha256 = "ee5d4f73cb689b1b5432c6908a189f9fbdb172507c49c32dbdf79b239ea9b8e0",
8590-
strip_prefix = "github.com/stretchr/testify@v1.9.0",
8599+
sha256 = "36c87573527a97ce97fc15ce2a101e65e5ebb350db142d09f633580cb8d5c839",
8600+
strip_prefix = "github.com/stretchr/testify@v1.10.0",
85918601
urls = [
8592-
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/stretchr/testify/com_github_stretchr_testify-v1.9.0.zip",
8602+
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/stretchr/testify/com_github_stretchr_testify-v1.10.0.zip",
85938603
],
85948604
)
85958605
go_repository(

build/bazelutil/distdir_files.bzl

+2-1
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ DISTDIR_FILES = {
370370
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/tokenbucket/com_github_cockroachdb_tokenbucket-v0.0.0-20230807174530-cc333fc44b06.zip": "150f3e8e5b515c0886cda0809f09b5d5173d7f2c30eb2f2c6045c2aeb2183aa3",
371371
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/tools/com_github_cockroachdb_tools-v0.0.0-20211112185054-642e51449b40.zip": "37a3737dd23768b4997b2f0341d625658f5862cdbf808f7fbf3a7f9fd25913a7",
372372
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/ttycolor/com_github_cockroachdb_ttycolor-v0.0.0-20210902133924-c7d7dcdde4e8.zip": "1260533510c89abd6d8af573a40f0246f6865d5091144dea509b2c48e7c61614",
373+
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/version/com_github_cockroachdb_version-v0.0.0-20250314144055-3860cd14adf2.zip": "4e734ab8c4e4ff81003fedffa30dc5727f9b210c72a188ee3127eeedea09f644",
373374
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/vitess/com_github_cockroachdb_vitess-v0.0.0-20210218160543-54524729cc82.zip": "71f14e67f9396930d978d85c47b853f5cc4ce340e53cf88bf7d731b8428b2f77",
374375
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/x-time/com_github_cockroachdb_x_time-v0.3.1-0.20230525123634-71747adb5d5c.zip": "b151d95b9250e6aab7e53ea08bf6a9ca31c2aa964723baa1df28082589f01b21",
375376
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/yaml/com_github_cockroachdb_yaml-v0.0.0-20210825132133-2d6955c8edbc.zip": "98f901d1a2446ea98010e56f8f0587f2f790704ea56d14417803602b214e5697",
@@ -991,7 +992,7 @@ DISTDIR_FILES = {
991992
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/streadway/handy/com_github_streadway_handy-v0.0.0-20190108123426-d5acb3125c2a.zip": "f770ed96081220a9cbc5e975a06c2858b4f3d02820cb9902982116af491b171f",
992993
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/streadway/quantile/com_github_streadway_quantile-v0.0.0-20150917103942-b0c588724d25.zip": "45156bab62475784e2eacb349570c86bcf245a84d97825ce9ee2bf604a4438d5",
993994
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/stretchr/objx/com_github_stretchr_objx-v0.5.2.zip": "3c22c1d1c4c4024eb16a12f0187775640bf35d51b0a06649febc7797119451c0",
994-
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/stretchr/testify/com_github_stretchr_testify-v1.9.0.zip": "ee5d4f73cb689b1b5432c6908a189f9fbdb172507c49c32dbdf79b239ea9b8e0",
995+
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/stretchr/testify/com_github_stretchr_testify-v1.10.0.zip": "36c87573527a97ce97fc15ce2a101e65e5ebb350db142d09f633580cb8d5c839",
995996
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/subosito/gotenv/com_github_subosito_gotenv-v1.2.0.zip": "21474df92536f36de6f91dfbf466995289445cc4e5a5900d9c40ae8776b8b0cf",
996997
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/syndtr/gocapability/com_github_syndtr_gocapability-v0.0.0-20200815063812-42c35b437635.zip": "91ff91da1936e17aa68fc13756e40ba4db1d7c9375a4ef0969fe19c9aa281195",
997998
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/tchap/go-patricia/com_github_tchap_go_patricia-v2.2.6+incompatible.zip": "948494017eae153a8c2d4ae9b450fd42abcb2578211f1c28e69ab71a2f27814d",

go.mod

+2-1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ require (
143143
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06
144144
github.com/cockroachdb/tools v0.0.0-20211112185054-642e51449b40
145145
github.com/cockroachdb/ttycolor v0.0.0-20210902133924-c7d7dcdde4e8
146+
github.com/cockroachdb/version v0.0.0-20250314144055-3860cd14adf2
146147
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd
147148
github.com/containerd/containerd v1.6.18
148149
github.com/coreos/go-oidc v2.2.1+incompatible
@@ -234,7 +235,7 @@ require (
234235
github.com/spf13/afero v1.9.2
235236
github.com/spf13/cobra v1.6.1
236237
github.com/spf13/pflag v1.0.5
237-
github.com/stretchr/testify v1.9.0
238+
github.com/stretchr/testify v1.10.0
238239
github.com/twmb/franz-go v1.18.0
239240
github.com/twmb/franz-go/pkg/kadm v1.11.0
240241
github.com/twpayne/go-geom v1.4.2

go.sum

+4-2
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,8 @@ github.com/cockroachdb/tools v0.0.0-20211112185054-642e51449b40 h1:qVTb3XEv+7VVj
606606
github.com/cockroachdb/tools v0.0.0-20211112185054-642e51449b40/go.mod h1:cllxeV+TYc387/XzQRnDg6YThHoDzFewovWffzAm37Q=
607607
github.com/cockroachdb/ttycolor v0.0.0-20210902133924-c7d7dcdde4e8 h1:Hli+oX84dKq44sLVCcsGKqifm5Lg9J8VoJ2P3h9iPdI=
608608
github.com/cockroachdb/ttycolor v0.0.0-20210902133924-c7d7dcdde4e8/go.mod h1:75wnig8+TF6vst9hChkpcFO7YrRLddouJ5is8uqpfv0=
609+
github.com/cockroachdb/version v0.0.0-20250314144055-3860cd14adf2 h1:8Vfw2iNEpYIV6aLtMwT5UOGuPmp9MKlEKWKFTuB+MPU=
610+
github.com/cockroachdb/version v0.0.0-20250314144055-3860cd14adf2/go.mod h1:P9WiZOdQ1R/ZZDL0WzF5wlyRvrjtfhNOwMZymFpBwjE=
609611
github.com/cockroachdb/vitess v0.0.0-20210218160543-54524729cc82 h1:8htEd1lLILqfjKardWfKKGgXVCs0WmcgEj9cXnmcuos=
610612
github.com/cockroachdb/vitess v0.0.0-20210218160543-54524729cc82/go.mod h1:+bhevpN4bd6bstiRREkJDaMWZR3lTe5ypydTtXgf7GU=
611613
github.com/cockroachdb/x-time v0.3.1-0.20230525123634-71747adb5d5c h1:fL+zfQ88TclMTv0pWlHhe3z+rZvb9CpyCp+fFQSN2Ys=
@@ -2295,8 +2297,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
22952297
github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
22962298
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
22972299
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
2298-
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
2299-
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
2300+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
2301+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
23002302
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
23012303
github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
23022304
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=

pkg/BUILD.bazel

-3
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,6 @@ ALL_TESTS = [
805805
"//pkg/util/unique:unique_test",
806806
"//pkg/util/uuid:uuid_test",
807807
"//pkg/util/vector:vector_test",
808-
"//pkg/util/version:version_test",
809808
"//pkg/util:util_test",
810809
"//pkg/workload/bank:bank_test",
811810
"//pkg/workload/cli:cli_test",
@@ -2751,8 +2750,6 @@ GO_TARGETS = [
27512750
"//pkg/util/uuid:uuid_test",
27522751
"//pkg/util/vector:vector",
27532752
"//pkg/util/vector:vector_test",
2754-
"//pkg/util/version:version",
2755-
"//pkg/util/version:version_test",
27562753
"//pkg/util:util",
27572754
"//pkg/util:util_test",
27582755
"//pkg/workload/bank:bank",

pkg/backup/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ go_test(
328328
"//pkg/util/timeutil",
329329
"//pkg/util/tracing",
330330
"//pkg/util/uuid",
331-
"//pkg/util/version",
332331
"//pkg/workload",
333332
"//pkg/workload/bank",
334333
"//pkg/workload/histogram",
@@ -342,6 +341,7 @@ go_test(
342341
"@com_github_cockroachdb_pebble//sstable",
343342
"@com_github_cockroachdb_pebble//vfs",
344343
"@com_github_cockroachdb_redact//:redact",
344+
"@com_github_cockroachdb_version//:version",
345345
"@com_github_gogo_protobuf//types",
346346
"@com_github_jackc_pgx_v5//:pgx",
347347
"@com_github_kr_pretty//:pretty",

pkg/backup/restore_mid_schema_change_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/cockroachdb/cockroach/pkg/testutils/testcluster"
2323
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
2424
"github.com/cockroachdb/cockroach/pkg/util/log"
25-
"github.com/cockroachdb/cockroach/pkg/util/version"
25+
"github.com/cockroachdb/version"
2626
"github.com/stretchr/testify/require"
2727
)
2828

@@ -129,7 +129,8 @@ func runTestRestoreMidSchemaChange(t *testing.T, isSchemaOnly, isClusterRestore
129129
// parseMajorVersion parses our major-versioned directory names as if they were
130130
// full crdb versions.
131131
func parseMajorVersion(verStr string) (*version.Version, error) {
132-
return version.Parse(fmt.Sprintf("v%s.0", verStr))
132+
v, err := version.Parse(fmt.Sprintf("v%s.0", verStr))
133+
return &v, err
133134
}
134135

135136
// expectedSCJobCount returns the expected number of schema change jobs

pkg/build/BUILD.bazel

+5-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ go_library(
2525
deps = [
2626
"//pkg/util/buildutil",
2727
"//pkg/util/envutil",
28-
"//pkg/util/version",
2928
"@com_github_cockroachdb_redact//:redact",
29+
"@com_github_cockroachdb_version//:version",
3030
],
3131
)
3232

@@ -51,5 +51,8 @@ go_test(
5151
name = "build_test",
5252
srcs = ["info_test.go"],
5353
embed = [":build"],
54-
deps = ["@com_github_stretchr_testify//require"],
54+
deps = [
55+
"@com_github_cockroachdb_version//:version",
56+
"@com_github_stretchr_testify//require",
57+
],
5558
)

pkg/build/info.go

+14-12
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616

1717
"github.com/cockroachdb/cockroach/pkg/util/buildutil"
1818
"github.com/cockroachdb/cockroach/pkg/util/envutil"
19-
"github.com/cockroachdb/cockroach/pkg/util/version"
2019
"github.com/cockroachdb/redact"
20+
"github.com/cockroachdb/version"
2121
)
2222

2323
// TimeFormat is the reference format for build.Time. Make sure it stays in sync
@@ -76,7 +76,7 @@ func parseCockroachVersion(versionTxt string) *version.Version {
7676
if err != nil {
7777
panic(fmt.Errorf("could not parse version.txt: %w", err))
7878
}
79-
return v
79+
return &v
8080
}
8181

8282
func computeBinaryVersion(
@@ -110,21 +110,23 @@ func BinaryVersion() string {
110110
// N.B. new public-facing doc URLs are expected to be up beginning with the "alpha.1" prerelease. Otherwise, "dev" will
111111
// cause the url mapper to redirect to the latest stable release.
112112
func VersionForURLs() string {
113-
// Prerelease versions >= "alpha.1"
114-
if parsedVersionTxt.PreRelease() >= "alpha.1" {
115-
return fmt.Sprintf("v%d.%d", parsedVersionTxt.Major(), parsedVersionTxt.Minor())
113+
if parsedVersionTxt.IsPrerelease() {
114+
phaseAndOrdinal := parsedVersionTxt.Format("%P.%o")
115+
// builds prior to "alpha.1" use 'dev' in their URLs
116+
if phaseAndOrdinal < "alpha.1" {
117+
return "dev"
118+
}
119+
} else if parsedVersionTxt.IsCustomOrNightlyBuild() {
120+
return "dev"
116121
}
117-
// Production release versions
118-
if parsedVersionTxt.PreRelease() == "" {
119-
return fmt.Sprintf("v%d.%d", parsedVersionTxt.Major(), parsedVersionTxt.Minor())
120-
}
121-
return "dev"
122+
return parsedVersionTxt.Major().String()
122123
}
123124

124125
// BranchReleaseSeries returns tha major and minor in version.txt, without
125126
// allowing for any overrides.
126-
func BranchReleaseSeries() (major, minor int) {
127-
return parsedVersionTxt.Major(), parsedVersionTxt.Minor()
127+
func BranchReleaseSeries() (year, ordinal int) {
128+
major := parsedVersionTxt.Major()
129+
return major.Year, major.Ordinal
128130
}
129131

130132
func init() {

pkg/build/info_test.go

+48
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package build
88
import (
99
"testing"
1010

11+
"github.com/cockroachdb/version"
1112
"github.com/stretchr/testify/require"
1213
)
1314

@@ -78,3 +79,50 @@ func TestComputeBinaryVersion(t *testing.T) {
7879
})
7980
}
8081
}
82+
83+
func TestVersionForURLs(t *testing.T) {
84+
testCases := []struct {
85+
versionTxt string
86+
want string
87+
}{
88+
{
89+
versionTxt: "v25.2.0",
90+
want: "v25.2",
91+
},
92+
{
93+
versionTxt: "v25.2.0-alpha.000000",
94+
want: "dev",
95+
},
96+
{
97+
versionTxt: "v25.2.0-alpha.1",
98+
want: "v25.2",
99+
},
100+
{
101+
versionTxt: "v25.2.0-beta.1",
102+
want: "v25.2",
103+
},
104+
{
105+
versionTxt: "v25.2.0-rc.2",
106+
want: "v25.2",
107+
},
108+
{
109+
versionTxt: "v25.2.0-cloudonly.1",
110+
want: "v25.2",
111+
},
112+
{
113+
versionTxt: "v25.2.0-12-gabcdef01234",
114+
want: "dev",
115+
},
116+
}
117+
118+
for _, tc := range testCases {
119+
t.Run(tc.versionTxt, func(t *testing.T) {
120+
oldParsedVersionTxt := parsedVersionTxt
121+
defer func() { parsedVersionTxt = oldParsedVersionTxt }()
122+
v := version.MustParse(tc.versionTxt)
123+
parsedVersionTxt = &v
124+
125+
require.Equal(t, tc.want, VersionForURLs())
126+
})
127+
}
128+
}

pkg/cli/clisqlclient/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ go_library(
2828
"//pkg/sql/pgwire/pgcode",
2929
"//pkg/sql/scanner",
3030
"//pkg/sql/sem/catconstants",
31-
"//pkg/util/version",
3231
"@com_github_cockroachdb_cockroach_go_v2//crdb",
3332
"@com_github_cockroachdb_errors//:errors",
33+
"@com_github_cockroachdb_version//:version",
3434
"@com_github_jackc_pgx_v5//:pgx",
3535
"@com_github_jackc_pgx_v5//pgconn",
3636
"@com_github_jackc_pgx_v5//pgtype",

pkg/cli/clisqlclient/conn.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121
"github.com/cockroachdb/cockroach/pkg/security/pprompt"
2222
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode"
2323
"github.com/cockroachdb/cockroach/pkg/sql/sem/catconstants"
24-
"github.com/cockroachdb/cockroach/pkg/util/version"
2524
"github.com/cockroachdb/errors"
25+
"github.com/cockroachdb/version"
2626
"github.com/jackc/pgx/v5"
2727
"github.com/jackc/pgx/v5/pgconn"
2828
"github.com/otan/gopgkrb5"

pkg/cli/interactive_tests/test_sql_version_reporting.tcl

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ eexpect eof
6161
stop_server $argv
6262

6363
start_test "Check that the client picks up a new server version, and warns about lower versions."
64-
set env(COCKROACH_TESTING_VERSION_OVERRIDE) "v0.1.0-fakever"
64+
set env(COCKROACH_TESTING_VERSION_OVERRIDE) "v1.1.0-fakever"
6565
start_server $argv
66-
set env(COCKROACH_TESTING_VERSION_OVERRIDE) "v0.2.0-fakever"
66+
set env(COCKROACH_TESTING_VERSION_OVERRIDE) "v1.2.0-fakever"
6767
spawn $argv sql --no-line-editor
6868
send "select 1;\r"
6969
eexpect "# Client version: CockroachDB"

pkg/cmd/bazci/githubpost/issues/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ go_library(
1515
],
1616
deps = [
1717
"//pkg/build",
18-
"//pkg/util/version",
1918
"@com_github_cockroachdb_errors//:errors",
19+
"@com_github_cockroachdb_version//:version",
2020
"@com_github_google_go_github//github",
2121
"@org_golang_x_oauth2//:oauth2",
2222
],

pkg/cmd/bazci/githubpost/issues/issues.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import (
1717
"strings"
1818

1919
"github.com/cockroachdb/cockroach/pkg/build"
20-
"github.com/cockroachdb/cockroach/pkg/util/version"
2120
"github.com/cockroachdb/errors"
21+
"github.com/cockroachdb/version"
2222
"github.com/google/go-github/github"
2323
"golang.org/x/oauth2"
2424
)
@@ -66,7 +66,7 @@ func (p *poster) getProbableMilestone(ctx *postCtx) *int {
6666
ctx.Printf("unable to parse version from binary version to determine milestone: %s", err)
6767
return nil
6868
}
69-
vstring := fmt.Sprintf("%d.%d", v.Major(), v.Minor())
69+
vstring := v.Format("%X.%Y")
7070

7171
milestones, _, err := p.listMilestones(ctx, p.Org, p.Repo, &github.MilestoneListOptions{
7272
State: "open",

pkg/cmd/publish-provisional-artifacts/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ go_library(
77
visibility = ["//visibility:private"],
88
deps = [
99
"//pkg/release",
10-
"//pkg/util/version",
10+
"@com_github_cockroachdb_version//:version",
1111
"@com_github_kr_pretty//:pretty",
1212
],
1313
)

pkg/cmd/publish-provisional-artifacts/main.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"regexp"
1616

1717
"github.com/cockroachdb/cockroach/pkg/release"
18-
"github.com/cockroachdb/cockroach/pkg/util/version"
18+
"github.com/cockroachdb/version"
1919
"github.com/kr/pretty"
2020
)
2121

@@ -139,9 +139,7 @@ func run(
139139
versionStr, err)
140140
}
141141

142-
// Prerelease returns anything after the `-` and before metadata. eg:
143-
// `beta` for `1.0.1-beta+metadata`
144-
if ver.PreRelease() == "" {
142+
if !ver.IsPrerelease() {
145143
// TODO(dan): This is what it did before, but isn't this wrong? It
146144
// seems like it would mark a patch release of the previous minor
147145
// version as latest. Instead, move to something like "latest-2.0",

0 commit comments

Comments
 (0)