mirror of
https://github.com/MedzikUser/go-github-selfupdate.git
synced 2024-08-15 03:25:29 +00:00
support tcnksm/go-gitconfig.GithubToken()
This commit is contained in:
parent
cee0f07401
commit
179b999395
1 changed files with 8 additions and 3 deletions
|
@ -3,14 +3,16 @@ package selfupdate
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/blang/semver"
|
|
||||||
"github.com/google/go-github/github"
|
|
||||||
"golang.org/x/oauth2"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/blang/semver"
|
||||||
|
"github.com/google/go-github/github"
|
||||||
|
gitconfig "github.com/tcnksm/go-gitconfig"
|
||||||
|
"golang.org/x/oauth2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var reVersion = regexp.MustCompile(`\d+\.\d+\.\d+`)
|
var reVersion = regexp.MustCompile(`\d+\.\d+\.\d+`)
|
||||||
|
@ -65,6 +67,9 @@ func findSuitableReleaseAndAsset(rels []*github.RepositoryRelease) (*github.Repo
|
||||||
// NewDetector crates a new detector instance. It initializes GitHub API client.
|
// NewDetector crates a new detector instance. It initializes GitHub API client.
|
||||||
func NewDetector() *ReleaseDetector {
|
func NewDetector() *ReleaseDetector {
|
||||||
token := os.Getenv("GITHUB_TOKEN")
|
token := os.Getenv("GITHUB_TOKEN")
|
||||||
|
if token == "" {
|
||||||
|
token, _ = gitconfig.GithubToken()
|
||||||
|
}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
var auth *http.Client
|
var auth *http.Client
|
||||||
|
|
Loading…
Reference in a new issue