diff --git a/cmd/dcrinstall/settings.go b/cmd/dcrinstall/settings.go index 6039bb9..25561aa 100644 --- a/cmd/dcrinstall/settings.go +++ b/cmd/dcrinstall/settings.go @@ -17,8 +17,8 @@ import ( // latestVersion and latestManifest must be updated every release. const ( - latestManifest = "manifest-v1.2.0-rc1.txt" - defaultURI = "https://github.com/decred/decred-binaries/releases/download/v1.2.0-rc1" + latestManifest = "manifest-v1.3.0-rc1.txt" + defaultURI = "https://github.com/decred/decred-binaries/releases/download/v1.3.0-rc1" netMain = "mainnet" netTest = "testnet" diff --git a/cmd/dcrinstall/util.go b/cmd/dcrinstall/util.go index 3791c98..419d538 100644 --- a/cmd/dcrinstall/util.go +++ b/cmd/dcrinstall/util.go @@ -13,6 +13,7 @@ import ( "os" "path/filepath" "regexp" + "strconv" "strings" "github.com/moby/moby/pkg/archive" @@ -20,6 +21,45 @@ import ( "golang.org/x/crypto/openpgp" ) +var relRE = regexp.MustCompile(`(v|release-v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?`) + +type semVerInfo struct { + Major uint32 + Minor uint32 + Patch uint32 + PreRelease string + Build string +} + +func extractSemVer(s string) (*semVerInfo, error) { + matches := relRE.FindStringSubmatch(s) + if len(matches) == 0 { + return nil, fmt.Errorf("version string %q does not follow semantic "+ + "versioning requirements", s) + } + + major, err := strconv.ParseInt(matches[2], 10, 32) + if err != nil { + return nil, err + } + minor, err := strconv.ParseInt(matches[3], 10, 32) + if err != nil { + return nil, err + } + patch, err := strconv.ParseInt(matches[4], 10, 32) + if err != nil { + return nil, err + } + + return &semVerInfo{ + Major: uint32(major), + Minor: uint32(minor), + Patch: uint32(patch), + PreRelease: matches[6], + Build: matches[9], + }, nil +} + func answer(def string) string { r := bufio.NewReader(os.Stdin) a, _ := r.ReadString('\n') @@ -118,6 +158,15 @@ func (c *ctx) extract() (string, error) { } // fish out version - re := regexp.MustCompile("v[0-9]+.[0-9]+.[0-9]+") - return re.FindString(filename), nil + info, err := extractSemVer(filename) + if err != nil { + return "", err + } + + version := fmt.Sprintf("v%v.%v.%v", info.Major, info.Minor, info.Patch) + if info.PreRelease != "" { + version += "-" + info.PreRelease + } + + return version, nil } diff --git a/cmd/dcrinstall/version.go b/cmd/dcrinstall/version.go index bb4ce04..d25fd7f 100644 --- a/cmd/dcrinstall/version.go +++ b/cmd/dcrinstall/version.go @@ -18,12 +18,12 @@ const semanticAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr // versioning 2.0.0 spec (http://semver.org/). const ( appMajor uint = 1 - appMinor uint = 2 + appMinor uint = 3 appPatch uint = 0 // appPreRelease MUST only contain characters from semanticAlphabet // per the semantic versioning spec. - appPreRelease = "" + appPreRelease = "rc1" ) // appBuild is defined as a variable so it can be overridden during the build