Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.1.0
8 changes: 4 additions & 4 deletions cmd/semantic-release/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"errors"
"flag"
"fmt"
"github.com/semantic-release/go-semantic-release"
"github.com/semantic-release/go-semantic-release/condition"
"github.com/semantic-release/go-semantic-release/update"
"github.com/6RiverSystems/go-semantic-release"
"github.com/6RiverSystems/go-semantic-release/condition"
"github.com/6RiverSystems/go-semantic-release/update"
"io/ioutil"
"log"
"os"
Expand Down Expand Up @@ -64,7 +64,7 @@ func main() {
}

logger.Println("getting latest release...")
release, err := repo.GetLatestRelease()
release, err := repo.GetLatestReleaseWithBackoff()
exitIfError(err)
logger.Println("found version: " + release.Version.String())

Expand Down
22 changes: 22 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module github.com/6RiverSystems/go-semantic-release

go 1.17

require (
github.com/Ableton/go-travis v0.0.0-20160216095425-1cdf3cca2f3a
github.com/Masterminds/semver v1.2.2
github.com/cenkalti/backoff/v4 v4.1.2
github.com/google/go-github v3.0.1-0.20170308155316-2694dcaaa606+incompatible
golang.org/x/oauth2 v0.0.0-20170302202304-efb10a30610e
)

require (
github.com/fatih/structs v1.0.0 // indirect
github.com/golang/protobuf v0.0.0-20170307001533-c9c7427a2a70 // indirect
github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 // indirect
github.com/oleiade/reflections v0.0.0-20160817071559-0e86b3c98b2f // indirect
github.com/stretchr/testify v1.7.0 // indirect
golang.org/x/net v0.0.0-20170303215036-d379faa25cbd // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
google.golang.org/appengine v1.0.1-0.20170307235554-b79c28f01977 // indirect
)
34 changes: 34 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
github.com/Ableton/go-travis v0.0.0-20160216095425-1cdf3cca2f3a h1:TN1/XKVf4MSw7ABVKhhB2UAeqRe78kKv++D59Ua5xb8=
github.com/Ableton/go-travis v0.0.0-20160216095425-1cdf3cca2f3a/go.mod h1:yrIiBz4eKmjoNtbDoW3V2H/mYsPhPcrifUmP/P110c8=
github.com/Masterminds/semver v1.2.2 h1:ptelpryog9A0pR4TGFvIAvw2c8SaNrYkFtfrxhSviss=
github.com/Masterminds/semver v1.2.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo=
github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/structs v1.0.0 h1:BrX964Rv5uQ3wwS+KRUAJCBBw5PQmgJfJ6v4yly5QwU=
github.com/fatih/structs v1.0.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/golang/protobuf v0.0.0-20170307001533-c9c7427a2a70 h1:WKo1/VPcI3cbJwnIHISxazgDxbw+UIrktU3zNxzcp4c=
github.com/golang/protobuf v0.0.0-20170307001533-c9c7427a2a70/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/go-github v3.0.1-0.20170308155316-2694dcaaa606+incompatible h1:9NajpjscIdTwdj0OC8tj0aA8utuxV9Tm1HS8MpKEoCo=
github.com/google/go-github v3.0.1-0.20170308155316-2694dcaaa606+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 h1:zLTLjkaOFEFIOxY5BWLFLwh+cL8vOBW4XJ2aqLE/Tf0=
github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/oleiade/reflections v0.0.0-20160817071559-0e86b3c98b2f h1:I6mXuorHlvwNDFelz7a+j0HaGYSzX7+Gq60DqLVypfc=
github.com/oleiade/reflections v0.0.0-20160817071559-0e86b3c98b2f/go.mod h1:RbATFBbKYkVdqmSFtx13Bb/tVhR0lgOBXunWTZKeL4w=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/net v0.0.0-20170303215036-d379faa25cbd h1:jmQMFWtDxPuJYgzEPuUp6gA5g+tbMA/TFQ/8QwMfCiI=
golang.org/x/net v0.0.0-20170303215036-d379faa25cbd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/oauth2 v0.0.0-20170302202304-efb10a30610e h1:B703Cy0NUPHiFSmjWtOLpigF6SzPWMFDTJRm+8dChgY=
golang.org/x/oauth2 v0.0.0-20170302202304-efb10a30610e/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
google.golang.org/appengine v1.0.1-0.20170307235554-b79c28f01977 h1:pWBLhgzeI98ZJrXXFGbuFX4SCfn4be9ZPCH4CChIyaU=
google.golang.org/appengine v1.0.1-0.20170307235554-b79c28f01977/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
34 changes: 31 additions & 3 deletions semrel.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import (
"context"
"errors"
"fmt"
"github.com/Masterminds/semver"
"github.com/google/go-github/github"
"golang.org/x/oauth2"

"regexp"
"sort"
"strings"
"time"

"github.com/Masterminds/semver"
"github.com/cenkalti/backoff/v4"
"github.com/google/go-github/github"
"golang.org/x/oauth2"
)

var commitPattern = regexp.MustCompile("^(\\w*)(?:\\((.*)\\))?\\: (.*)$")
Expand Down Expand Up @@ -114,6 +117,31 @@ func (repo *Repository) GetLatestRelease() (*Release, error) {
return &Release{tags[0].Commit.GetSHA(), version}, nil
}


func (repo *Repository) GetLatestReleaseWithBackoff() (*Release, error) {
opts := &github.ListOptions{PerPage: 1}

var tags []*github.RepositoryTag
listTags := func() (err error) {
tags, _, err = repo.Client.Repositories.ListTags(repo.Ctx, repo.Owner, repo.Repo, opts)
return err
}

err := backoff.Retry(listTags, backoff.NewExponentialBackOff())

if err != nil {
return nil, err
}
if len(tags) == 0 {
return &Release{"", &semver.Version{}}, nil
}
version, verr := semver.NewVersion(tags[0].GetName())
if verr != nil {
return nil, verr
}
return &Release{tags[0].Commit.GetSHA(), version}, nil
}

func (repo *Repository) CreateRelease(commits []*Commit, latestRelease *Release, newVersion *semver.Version) error {
tag := fmt.Sprintf("v%s", newVersion.String())
changelog := GetChangelog(commits, latestRelease, newVersion)
Expand Down
24 changes: 0 additions & 24 deletions vendor/github.com/Ableton/go-travis/.gitignore

This file was deleted.

13 changes: 0 additions & 13 deletions vendor/github.com/Ableton/go-travis/.travis.yml

This file was deleted.

38 changes: 0 additions & 38 deletions vendor/github.com/Ableton/go-travis/CONTRIBUTING.md

This file was deleted.

27 changes: 0 additions & 27 deletions vendor/github.com/Ableton/go-travis/LICENSE

This file was deleted.

Loading