blob: 14e774fb2ec7e080d6a17207fd9f86526151171e [file] [log] [blame]
khenaidoo5fc5cea2021-08-11 17:39:16 -04001// Copyright 2019 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// Package version records versioning information about this module.
6package version
7
8import (
9 "fmt"
10 "strings"
11)
12
13// These constants determine the current version of this module.
14//
15//
16// For our release process, we enforce the following rules:
17// * Tagged releases use a tag that is identical to String.
18// * Tagged releases never reference a commit where the String
19// contains "devel".
20// * The set of all commits in this repository where String
21// does not contain "devel" must have a unique String.
22//
23//
24// Steps for tagging a new release:
25// 1. Create a new CL.
26//
27// 2. Update Minor, Patch, and/or PreRelease as necessary.
28// PreRelease must not contain the string "devel".
29//
30// 3. Since the last released minor version, have there been any changes to
31// generator that relies on new functionality in the runtime?
32// If yes, then increment RequiredGenerated.
33//
34// 4. Since the last released minor version, have there been any changes to
35// the runtime that removes support for old .pb.go source code?
36// If yes, then increment SupportMinimum.
37//
38// 5. Send out the CL for review and submit it.
39// Note that the next CL in step 8 must be submitted after this CL
40// without any other CLs in-between.
41//
42// 6. Tag a new version, where the tag is is the current String.
43//
44// 7. Write release notes for all notable changes
45// between this release and the last release.
46//
47// 8. Create a new CL.
48//
49// 9. Update PreRelease to include the string "devel".
50// For example: "" -> "devel" or "rc.1" -> "rc.1.devel"
51//
52// 10. Send out the CL for review and submit it.
53const (
54 Major = 1
55 Minor = 27
56 Patch = 1
57 PreRelease = ""
58)
59
60// String formats the version string for this module in semver format.
61//
62// Examples:
63// v1.20.1
64// v1.21.0-rc.1
65func String() string {
66 v := fmt.Sprintf("v%d.%d.%d", Major, Minor, Patch)
67 if PreRelease != "" {
68 v += "-" + PreRelease
69
70 // TODO: Add metadata about the commit or build hash.
71 // See https://golang.org/issue/29814
72 // See https://golang.org/issue/33533
73 var metadata string
74 if strings.Contains(PreRelease, "devel") && metadata != "" {
75 v += "+" + metadata
76 }
77 }
78 return v
79}