Skip to content

Commit

Permalink
Update versions. (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
dajohi authored Aug 12, 2018
1 parent aa3128a commit 7119d61
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cmd/dcrinstall/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
53 changes: 51 additions & 2 deletions cmd/dcrinstall/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,53 @@ import (
"os"
"path/filepath"
"regexp"
"strconv"
"strings"

"github.com/moby/moby/pkg/archive"

"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')
Expand Down Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions cmd/dcrinstall/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7119d61

Please sign in to comment.