Skip to content

Commit

Permalink
feat: upgrade go to 1.23 + add loop to retrieve more releases
Browse files Browse the repository at this point in the history
  • Loading branch information
asvinours committed Oct 7, 2024
1 parent 553c6fa commit 8bead43
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 517 deletions.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ clean:

.PHONY: test
test: $(EXE)
mkdir -vp $(DIR)
mv $(EXE) $(DIR)
go test -v ./...

.PHONY: install
Expand Down
56 changes: 27 additions & 29 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,45 +1,43 @@
module github.com/warrensbox/tgswitch

go 1.19
go 1.23

require (
github.com/google/go-github/v49 v49.1.0
github.com/hashicorp/go-version v1.5.0
github.com/google/go-github/v66 v66.0.0
github.com/hashicorp/go-version v1.7.0
github.com/hashicorp/hcl2 v0.0.0-20191002203319-fb75b3253c80
github.com/manifoldco/promptui v0.9.0
github.com/mitchellh/go-homedir v1.1.0
github.com/pborman/getopt v0.0.0-20190130022237-7402d34a12a8
github.com/spf13/viper v1.12.0
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
github.com/pborman/getopt v1.1.0
github.com/spf13/viper v1.19.0
golang.org/x/oauth2 v0.23.0
golang.org/x/sys v0.26.0
)

require (
github.com/agext/levenshtein v1.2.1 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg v1.0.0 // indirect
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.3.0 // indirect
github.com/zclconf/go-cty v1.0.0 // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/zclconf/go-cty v1.15.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6 // indirect
golang.org/x/text v0.19.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
547 changes: 72 additions & 475 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net/http"
"os"

"github.com/google/go-github/v49/github"
"github.com/google/go-github/v66/github"
)

// DownloadFromURL : Downloads the binary from the source url
Expand Down
2 changes: 1 addition & 1 deletion lib/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"runtime"
"testing"

"github.com/google/go-github/v49/github"
"github.com/google/go-github/v66/github"
lib "github.com/warrensbox/tgswitch/lib"
)

Expand Down
2 changes: 1 addition & 1 deletion lib/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"regexp"
"runtime"

"github.com/google/go-github/v49/github"
"github.com/google/go-github/v66/github"
)

const (
Expand Down
18 changes: 13 additions & 5 deletions lib/list_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"regexp"
"strings"

"github.com/google/go-github/v49/github"
"github.com/google/go-github/v66/github"
)

// VersionExist : check if requested version exist
Expand Down Expand Up @@ -53,15 +53,23 @@ func GetAppList(ctx context.Context, ghClient *github.Client) []string {
repoName := ctx.Value("repoName").(string)

opt := &github.ListOptions{Page: 1, PerPage: 100}
releases, _, err := ghClient.Repositories.ListReleases(ctx, repoOwner, repoName, opt)
if err != nil {
log.Fatal("Unable to make request. Please try again.")
var allReleases []*github.RepositoryRelease
for {
repos, resp, err := ghClient.Repositories.ListReleases(ctx, repoOwner, repoName, opt)
if err != nil {
log.Fatal("Unable to make request. Please try again.")
}
allReleases = append(allReleases, repos...)
if resp.NextPage == 0 || resp.NextPage >= 3 {
break
}
opt.Page = resp.NextPage
}

var re = regexp.MustCompile(`^v([0-9]+\.[0-9]+\.[0-9]+)$`)

values := []string{}
for _, v := range releases {
for _, v := range allReleases {
name := *v.Name
res := re.MatchString(name)
if !res {
Expand Down
2 changes: 1 addition & 1 deletion lib/semver.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"sort"

"github.com/google/go-github/v49/github"
"github.com/google/go-github/v66/github"
semver "github.com/hashicorp/go-version"
)

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"path/filepath"
"strings"

"github.com/google/go-github/v49/github"
"github.com/google/go-github/v66/github"
"github.com/hashicorp/hcl2/gohcl"
"github.com/hashicorp/hcl2/hclparse"
"github.com/manifoldco/promptui"
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
RELEASE_VERSION=0.8.1
RELEASE_VERSION=0.9.0

0 comments on commit 8bead43

Please sign in to comment.