@@ -42,8 +42,8 @@ func init() {
42
42
}
43
43
44
44
type goVersion struct {
45
- major int
46
45
minor int
46
+ patch int
47
47
}
48
48
49
49
func newGoVersion (v string ) * goVersion {
@@ -52,32 +52,32 @@ func newGoVersion(v string) *goVersion {
52
52
log .Fatalf ("bad version: %s" , v )
53
53
}
54
54
m := strings .Split (c , "." )
55
- major , err := strconv .Atoi (string (m [1 ]))
55
+ minor , err := strconv .Atoi (string (m [1 ]))
56
56
if err != nil {
57
57
log .Fatal (err )
58
58
}
59
- minor , err := strconv .Atoi (string (m [2 ]))
59
+ patch , err := strconv .Atoi (string (m [2 ]))
60
60
if err != nil {
61
61
log .Fatal (err )
62
62
}
63
63
return & goVersion {
64
- major : major ,
65
64
minor : minor ,
65
+ patch : patch ,
66
66
}
67
67
}
68
68
69
- // major returns the version string without the minor version.
70
- func (g * goVersion ) Major () string {
71
- return fmt .Sprintf ("1.%d" , g .major )
69
+ // Minor returns the version string without the patch version.
70
+ func (g * goVersion ) Minor () string {
71
+ return fmt .Sprintf ("1.%d" , g .minor )
72
72
}
73
73
74
74
// golangVersion returns the full version string but without the leading '.0'
75
- // for the initial revision of a major release.
75
+ // for the initial revision of a minor release.
76
76
func (g * goVersion ) golangVersion () string {
77
- if g .major < 21 && g .minor == 0 {
78
- return g .Major ()
77
+ if g .minor < 21 && g .patch == 0 {
78
+ return g .Minor ()
79
79
}
80
- return fmt .Sprintf ("1.%d.%d" , g .major , g .minor )
80
+ return fmt .Sprintf ("1.%d.%d" , g .minor , g .patch )
81
81
}
82
82
83
83
// String returns the full version string.
@@ -86,14 +86,14 @@ func (g *goVersion) String() string {
86
86
}
87
87
88
88
func (g * goVersion ) less (o * goVersion ) bool {
89
- if g .major == o .major {
90
- return g .minor < o .minor
89
+ if g .minor == o .minor {
90
+ return g .patch < o .patch
91
91
}
92
- return g .major < o .major
92
+ return g .minor < o .minor
93
93
}
94
94
95
95
func (g * goVersion ) equal (o * goVersion ) bool {
96
- return g .major == o .major && g .minor == o .minor
96
+ return g .minor == o .minor && g .patch == o .patch
97
97
}
98
98
99
99
// url returns the URL of the Go archive.
@@ -115,12 +115,12 @@ func (g *goVersion) getSHA256() (string, error) {
115
115
return strings .TrimSpace (string (b )), nil
116
116
}
117
117
118
- // getLastMinorVersion returns the last minor version for a given Go version.
119
- func (g * goVersion ) getLastMinorVersion () (* goVersion , error ) {
118
+ // getLastPatchVersion returns the last patch version for a given Go version.
119
+ func (g * goVersion ) getLastPatchVersion () (* goVersion , error ) {
120
120
last := * g
121
121
for {
122
122
next := last
123
- next .minor ++
123
+ next .patch ++
124
124
resp , err := http .Head (next .url ())
125
125
if err != nil {
126
126
return nil , err
@@ -134,11 +134,11 @@ func (g *goVersion) getLastMinorVersion() (*goVersion, error) {
134
134
}
135
135
}
136
136
137
- // getNextMajor returns the next Go major version for a given Go version.
137
+ // getNextMinor returns the next Go minor version for a given Go version.
138
138
// It returns nil if the current version is already the latest.
139
- func (g * goVersion ) getNextMajor () * goVersion {
140
- version := newGoVersion (g .Major () + ".0" )
141
- version .major ++
139
+ func (g * goVersion ) getNextMinor () * goVersion {
140
+ version := newGoVersion (g .Minor () + ".0" )
141
+ version .minor ++
142
142
143
143
resp , err := http .Head (version .url ())
144
144
if err != nil {
@@ -202,9 +202,9 @@ func shaReplacer(old, new *goVersion) func(string) (string, error) {
202
202
}
203
203
}
204
204
205
- func majorVersionReplacer (old , new * goVersion ) func (string ) (string , error ) {
205
+ func minorVersionReplacer (old , new * goVersion ) func (string ) (string , error ) {
206
206
return func (out string ) (string , error ) {
207
- return strings .ReplaceAll (out , old .Major (), new .Major ()), nil
207
+ return strings .ReplaceAll (out , old .Minor (), new .Minor ()), nil
208
208
}
209
209
}
210
210
@@ -220,10 +220,10 @@ func fullVersionReplacer(old, new *goVersion) func(string) (string, error) {
220
220
}
221
221
}
222
222
223
- // replaceMajor switches the versions from [1.(N-1), 1.N] to [1.N, 1.(N+1)].
224
- func replaceMajor (old , current , next * goVersion ) error {
223
+ // replaceMinor switches the versions from [1.(N-1), 1.N] to [1.N, 1.(N+1)].
224
+ func replaceMinor (old , current , next * goVersion ) error {
225
225
// Replace the old version by the next one.
226
- err := filepath .Walk (old .Major (), func (path string , info os.FileInfo , err error ) error {
226
+ err := filepath .Walk (old .Minor (), func (path string , info os.FileInfo , err error ) error {
227
227
if err != nil {
228
228
return err
229
229
}
@@ -248,22 +248,22 @@ func replaceMajor(old, current, next *goVersion) error {
248
248
return replace (path ,
249
249
[]func (string ) (string , error ){
250
250
golangVersionReplacer ("" , old , next ),
251
- majorVersionReplacer (old , next ),
251
+ minorVersionReplacer (old , next ),
252
252
},
253
253
)
254
254
})
255
255
if err != nil {
256
256
return err
257
257
}
258
- if err := os .Rename (old .Major (), next .Major ()); err != nil {
258
+ if err := os .Rename (old .Minor (), next .Minor ()); err != nil {
259
259
return fmt .Errorf ("failed to create new version directory: %w" , err )
260
260
}
261
261
262
262
// Update CircleCI.
263
263
err = replace (".circleci/config.yml" ,
264
264
[]func (string ) (string , error ){
265
- majorVersionReplacer (current , next ),
266
- majorVersionReplacer (old , current ),
265
+ minorVersionReplacer (current , next ),
266
+ minorVersionReplacer (old , current ),
267
267
},
268
268
)
269
269
if err != nil {
@@ -273,8 +273,8 @@ func replaceMajor(old, current, next *goVersion) error {
273
273
// Update Makefile.
274
274
err = replace ("Makefile" ,
275
275
[]func (string ) (string , error ){
276
- majorVersionReplacer (current , next ),
277
- majorVersionReplacer (old , current ),
276
+ minorVersionReplacer (current , next ),
277
+ minorVersionReplacer (old , current ),
278
278
},
279
279
)
280
280
if err != nil {
@@ -285,22 +285,22 @@ func replaceMajor(old, current, next *goVersion) error {
285
285
return replace ("README.md" ,
286
286
[]func (string ) (string , error ){
287
287
fullVersionReplacer (current , next ),
288
- majorVersionReplacer (current , next ),
288
+ minorVersionReplacer (current , next ),
289
289
fullVersionReplacer (old , current ),
290
- majorVersionReplacer (old , current ),
290
+ minorVersionReplacer (old , current ),
291
291
},
292
292
)
293
293
}
294
294
295
- // updateNextMinor bumps the given directory to the next minor version.
295
+ // updateNextPatch bumps the given directory to the next patch version.
296
296
// It returns nil if no new version exists.
297
- func updateNextMinor (dir string ) (* goVersion , error ) {
297
+ func updateNextPatch (dir string ) (* goVersion , error ) {
298
298
current , err := getExactVersionFromDir (dir )
299
299
if err != nil {
300
300
return nil , fmt .Errorf ("failed to detect current version of %s: %w" , dir , err )
301
301
}
302
302
303
- next , err := current .getLastMinorVersion ()
303
+ next , err := current .getLastPatchVersion ()
304
304
if err != nil {
305
305
return nil , err
306
306
}
@@ -309,7 +309,7 @@ func updateNextMinor(dir string) (*goVersion, error) {
309
309
return nil , nil
310
310
}
311
311
312
- err = replace (filepath .Join (current .Major (), "base/Dockerfile" ),
312
+ err = replace (filepath .Join (current .Minor (), "base/Dockerfile" ),
313
313
[]func (string ) (string , error ){
314
314
golangVersionReplacer ("GOLANG_VERSION " , current , next ),
315
315
shaReplacer (current , next ),
@@ -319,7 +319,7 @@ func updateNextMinor(dir string) (*goVersion, error) {
319
319
return nil , err
320
320
}
321
321
322
- err = replace (filepath .Join (current .Major (), "Makefile.COMMON" ),
322
+ err = replace (filepath .Join (current .Minor (), "Makefile.COMMON" ),
323
323
[]func (string ) (string , error ){
324
324
fullVersionReplacer (current , next ),
325
325
},
@@ -373,10 +373,10 @@ func run() error {
373
373
return fmt .Errorf ("Expected 2 versions of Go but got %d\n " , len (dirs ))
374
374
}
375
375
376
- // Check if a new major Go version exists.
376
+ // Check if a new minor Go version exists.
377
377
nexts := make ([]* goVersion , 0 )
378
- if next := newGoVersion (dirs [1 ] + ".0" ).getNextMajor (); next != nil {
379
- log .Printf ("found a new major version of Go: %s" , next )
378
+ if next := newGoVersion (dirs [1 ] + ".0" ).getNextMinor (); next != nil {
379
+ log .Printf ("found a new minor version of Go: %s" , next )
380
380
old , err := getExactVersionFromDir (dirs [0 ])
381
381
if err != nil {
382
382
return err
@@ -385,15 +385,15 @@ func run() error {
385
385
if err != nil {
386
386
return err
387
387
}
388
- if err = replaceMajor (old , current , next ); err != nil {
388
+ if err = replaceMinor (old , current , next ); err != nil {
389
389
return err
390
390
}
391
391
nexts = append (nexts , next )
392
392
} else {
393
- // Otherwise check for new minor versions.
393
+ // Otherwise check for new patch versions.
394
394
for _ , d := range dirs {
395
395
log .Printf ("processing %s" , d )
396
- next , err := updateNextMinor (d )
396
+ next , err := updateNextPatch (d )
397
397
if err != nil {
398
398
return err
399
399
}
0 commit comments