Compare commits
16 Commits
Author | SHA1 | Date |
---|---|---|
Renovate Bot | 14b987cb42 | |
Renovate Bot | fed5b400de | |
Oskar | 5aea9fd5f3 | |
MedzikUser | e33f9e522e | |
MedzikUser | 542dc5db61 | |
MedzikUser | 4b201b07f5 | |
MedzikUser | c9e5fe26ca | |
MedzikUser | e8ecb189e5 | |
MedzikUser | a75b2492cb | |
MedzikUser | 8a2cf5e596 | |
Oskar | ec571e8c14 | |
MedzikUser | 9c76d66885 | |
MedzikUser | 9abefd0460 | |
Oskar | 8ab4b94ea1 | |
Oskar | 13766db3e1 | |
Medzik | f29763a683 |
|
@ -0,0 +1,26 @@
|
|||
name: Go
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17
|
||||
|
||||
- run: find . -type f -exec sed -i 's,MedzikUser/go-github-selfupdate,rhysd/go-github-selfupdate,g' {} +
|
||||
|
||||
- name: Build
|
||||
run: go build -v ./...
|
||||
|
||||
- name: Test
|
||||
run: go test -v ./...
|
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -15,7 +15,7 @@
|
|||
|
||||
- New Feature: Filtering releases by matching regular expressions to release names (Thanks to [@fredbi](https://github.com/fredbi)).
|
||||
Regular expression strings specified at `Filters` field in `Config` struct are used on detecting the
|
||||
latest release. Please read [documentation](https://godoc.org/github.com/rhysd/go-github-selfupdate/selfupdate#Config)
|
||||
latest release. Please read [documentation](https://godoc.org/github.com/MedzikUser/go-github-selfupdate/selfupdate#Config)
|
||||
for more details.
|
||||
- Allow `{cmd}_{os}_{arch}` format for executable names.
|
||||
- `.tgz` file name suffix was supported.
|
||||
|
@ -24,7 +24,7 @@
|
|||
## [v1.1.0] - 2018-11-10
|
||||
|
||||
- New Feature: Signature validation for release assets (Thanks to [@tobiaskohlbau](https://github.com/tobiaskohlbau)).
|
||||
Please read [the instruction](https://github.com/rhysd/go-github-selfupdate#hash-or-signature-validation) for usage.
|
||||
Please read [the instruction](https://github.com/MedzikUser/go-github-selfupdate#hash-or-signature-validation) for usage.
|
||||
|
||||
|
||||
## [v1.0.0] - 2018-09-23
|
||||
|
@ -32,9 +32,9 @@
|
|||
First release! :tada:
|
||||
|
||||
|
||||
[v1.2.3]: https://github.com/rhysd/go-github-selfupdate/compare/v1.2.2...v1.2.3
|
||||
[v1.2.2]: https://github.com/rhysd/go-github-selfupdate/compare/v1.2.1...v1.2.2
|
||||
[v1.2.1]: https://github.com/rhysd/go-github-selfupdate/compare/v1.2.0...v1.2.1
|
||||
[v1.2.0]: https://github.com/rhysd/go-github-selfupdate/compare/go-get-release...v1.2.0
|
||||
[v1.1.0]: https://github.com/rhysd/go-github-selfupdate/compare/v1.0.0...v1.1.0
|
||||
[v1.0.0]: https://github.com/rhysd/go-github-selfupdate/compare/example-1.2.4...v1.0.0
|
||||
[v1.2.3]: https://github.com/MedzikUser/go-github-selfupdate/compare/v1.2.2...v1.2.3
|
||||
[v1.2.2]: https://github.com/MedzikUser/go-github-selfupdate/compare/v1.2.1...v1.2.2
|
||||
[v1.2.1]: https://github.com/MedzikUser/go-github-selfupdate/compare/v1.2.0...v1.2.1
|
||||
[v1.2.0]: https://github.com/MedzikUser/go-github-selfupdate/compare/go-get-release...v1.2.0
|
||||
[v1.1.0]: https://github.com/MedzikUser/go-github-selfupdate/compare/v1.0.0...v1.1.0
|
||||
[v1.0.0]: https://github.com/MedzikUser/go-github-selfupdate/compare/example-1.2.4...v1.0.0
|
||||
|
|
24
README.md
24
README.md
|
@ -38,7 +38,7 @@ And small wrapper CLIs are provided:
|
|||
|
||||
[Slide at GoCon 2018 Spring (Japanese)](https://speakerdeck.com/rhysd/go-selfupdate-github-de-turuwozi-ji-atupudetosuru)
|
||||
|
||||
[go-github-selfupdate]: https://github.com/rhysd/go-github-selfupdate
|
||||
[go-github-selfupdate]: https://github.com/MedzikUser/go-github-selfupdate
|
||||
[GitHub Releases API]: https://developer.github.com/v3/repos/releases/
|
||||
|
||||
|
||||
|
@ -50,7 +50,7 @@ Example to understand what this library does is prepared as [CLI](./cmd/selfupda
|
|||
Install it at first.
|
||||
|
||||
```
|
||||
$ go get -u github.com/rhysd/go-github-selfupdate/cmd/selfupdate-example
|
||||
$ go get -u github.com/MedzikUser/go-github-selfupdate/cmd/selfupdate-example
|
||||
```
|
||||
|
||||
And check the version by `-version`. `-help` flag is also available to know all flags.
|
||||
|
@ -106,7 +106,7 @@ Following is the easiest way to use this package.
|
|||
import (
|
||||
"log"
|
||||
"github.com/blang/semver"
|
||||
"github.com/rhysd/go-github-selfupdate/selfupdate"
|
||||
"github.com/MedzikUser/go-github-selfupdate/selfupdate"
|
||||
)
|
||||
|
||||
const version = "1.2.3"
|
||||
|
@ -134,7 +134,7 @@ Following asks user to update or not.
|
|||
import (
|
||||
"bufio"
|
||||
"github.com/blang/semver"
|
||||
"github.com/rhysd/go-github-selfupdate/selfupdate"
|
||||
"github.com/MedzikUser/go-github-selfupdate/selfupdate"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
@ -196,7 +196,7 @@ Following is an example of usage with GitHub Enterprise.
|
|||
import (
|
||||
"log"
|
||||
"github.com/blang/semver"
|
||||
"github.com/rhysd/go-github-selfupdate/selfupdate"
|
||||
"github.com/MedzikUser/go-github-selfupdate/selfupdate"
|
||||
)
|
||||
|
||||
const version = "1.2.3"
|
||||
|
@ -433,12 +433,12 @@ tj/go-update:
|
|||
|
||||
Distributed under the [MIT License](LICENSE)
|
||||
|
||||
[GoDoc Badge]: https://godoc.org/github.com/rhysd/go-github-selfupdate/selfupdate?status.svg
|
||||
[GoDoc]: https://godoc.org/github.com/rhysd/go-github-selfupdate/selfupdate
|
||||
[TravisCI Status]: https://travis-ci.org/rhysd/go-github-selfupdate.svg?branch=master
|
||||
[TravisCI]: https://travis-ci.org/rhysd/go-github-selfupdate
|
||||
[GoDoc Badge]: https://godoc.org/github.com/MedzikUser/go-github-selfupdate/selfupdate?status.svg
|
||||
[GoDoc]: https://godoc.org/github.com/MedzikUser/go-github-selfupdate/selfupdate
|
||||
[TravisCI Status]: https://travis-ci.org/MedzikUser/go-github-selfupdate.svg?branch=master
|
||||
[TravisCI]: https://travis-ci.org/MedzikUser/go-github-selfupdate
|
||||
[AppVeyor Status]: https://ci.appveyor.com/api/projects/status/1tpyd9q9tw3ime5u/branch/master?svg=true
|
||||
[AppVeyor]: https://ci.appveyor.com/project/rhysd/go-github-selfupdate/branch/master
|
||||
[Codecov Status]: https://codecov.io/gh/rhysd/go-github-selfupdate/branch/master/graph/badge.svg
|
||||
[Codecov]: https://codecov.io/gh/rhysd/go-github-selfupdate
|
||||
[AppVeyor]: https://ci.appveyor.com/project/MedzikUser/go-github-selfupdate/branch/master
|
||||
[Codecov Status]: https://codecov.io/gh/MedzikUser/go-github-selfupdate/branch/master/graph/badge.svg
|
||||
[Codecov]: https://codecov.io/gh/MedzikUser/go-github-selfupdate
|
||||
[GitHub Enterprise]: https://enterprise.github.com/home
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
This command line tool is a small wrapper of [`selfupdate.DetectLatest()`](https://godoc.org/github.com/rhysd/go-github-selfupdate/selfupdate#DetectLatest).
|
||||
This command line tool is a small wrapper of [`selfupdate.DetectLatest()`](https://godoc.org/github.com/MedzikUser/go-github-selfupdate/selfupdate#DetectLatest).
|
||||
|
||||
Please install using `go get`.
|
||||
|
||||
```
|
||||
$ go get -u github.com/rhysd/go-github-selfupdate/cmd/detect-latest-release
|
||||
$ go get -u github.com/MedzikUser/go-github-selfupdate/cmd/detect-latest-release
|
||||
```
|
||||
|
||||
To know the usage, please try the command without any argument.
|
||||
|
|
|
@ -3,7 +3,7 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/rhysd/go-github-selfupdate/selfupdate"
|
||||
"github.com/MedzikUser/go-github-selfupdate/selfupdate"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
Like `go get`, but it downloads and installs the latest release binary from GitHub instead.
|
||||
|
||||
Please download a binary from [release page](https://github.com/rhysd/go-github-selfupdate/releases/tag/go-get-release)
|
||||
Please download a binary from [release page](https://github.com/MedzikUser/go-github-selfupdate/releases/tag/go-get-release)
|
||||
and put it in `$PATH` or build from source with `go get`.
|
||||
|
||||
```
|
||||
$ go get -u github.com/rhysd/go-github-selfupdate/cmd/go-get-release
|
||||
$ go get -u github.com/MedzikUser/go-github-selfupdate/cmd/go-get-release
|
||||
```
|
||||
|
||||
Usage is quite similar to `go get`. But `{package}` must be hosted on GitHub. So it needs to start with `github.com/`.
|
||||
|
|
|
@ -3,7 +3,7 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/rhysd/go-github-selfupdate/selfupdate"
|
||||
"github.com/MedzikUser/go-github-selfupdate/selfupdate"
|
||||
"go/build"
|
||||
"io"
|
||||
"net/http"
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"github.com/blang/semver"
|
||||
"github.com/rhysd/go-github-selfupdate/selfupdate"
|
||||
"github.com/MedzikUser/go-github-selfupdate/selfupdate"
|
||||
"os"
|
||||
)
|
||||
|
||||
|
@ -37,7 +37,7 @@ func main() {
|
|||
help := flag.Bool("help", false, "Show this help")
|
||||
ver := flag.Bool("version", false, "Show version")
|
||||
update := flag.Bool("selfupdate", false, "Try go-github-selfupdate via GitHub")
|
||||
slug := flag.String("slug", "rhysd/go-github-selfupdate", "Repository of this command")
|
||||
slug := flag.String("slug", "MedzikUser/go-github-selfupdate", "Repository of this command")
|
||||
|
||||
flag.Usage = usage
|
||||
flag.Parse()
|
||||
|
|
6
go.mod
6
go.mod
|
@ -1,13 +1,13 @@
|
|||
module github.com/rhysd/go-github-selfupdate
|
||||
module github.com/MedzikUser/go-github-selfupdate
|
||||
|
||||
require (
|
||||
github.com/blang/semver v3.5.1+incompatible
|
||||
github.com/blang/semver v3.8.0+incompatible
|
||||
github.com/google/go-github/v30 v30.1.0
|
||||
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf
|
||||
github.com/kr/pretty v0.1.0 // indirect
|
||||
github.com/onsi/gomega v1.4.2 // indirect
|
||||
github.com/tcnksm/go-gitconfig v0.1.2
|
||||
github.com/ulikunitz/xz v0.5.9
|
||||
github.com/ulikunitz/xz v0.5.10
|
||||
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288
|
||||
golang.org/x/text v0.3.5 // indirect
|
||||
|
|
4
go.sum
4
go.sum
|
@ -1,5 +1,7 @@
|
|||
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
|
||||
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
|
||||
github.com/blang/semver v3.8.0+incompatible h1:pJL/7tIY4048kLKL5Bvbif+Q2WxiKQcJprKDla+x33U=
|
||||
github.com/blang/semver v3.8.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
|
||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
||||
|
@ -27,6 +29,8 @@ github.com/tcnksm/go-gitconfig v0.1.2 h1:iiDhRitByXAEyjgBqsKi9QU4o2TNtv9kPP3RgPg
|
|||
github.com/tcnksm/go-gitconfig v0.1.2/go.mod h1:/8EhP4H7oJZdIPyT+/UIsG87kTzrzM4UsLGSItWYCpE=
|
||||
github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I=
|
||||
github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
|
||||
github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8=
|
||||
github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY=
|
||||
|
|
|
@ -109,7 +109,7 @@ func findReleaseAndAsset(rels []*github.RepositoryRelease,
|
|||
|
||||
// Find the latest version from the list of releases.
|
||||
// Returned list from GitHub API is in the order of the date when created.
|
||||
// ref: https://github.com/rhysd/go-github-selfupdate/issues/11
|
||||
// ref: https://github.com/MedzikUser/go-github-selfupdate/issues/11
|
||||
for _, rel := range rels {
|
||||
if a, v, ok := findAssetFromRelease(rel, suffixes, targetVersion, filters); ok {
|
||||
// Note: any version with suffix is less than any version without suffix.
|
||||
|
|
|
@ -23,16 +23,16 @@ If newer version than itself is detected, it downloads released binary from GitH
|
|||
There are some naming rules. Please read following links.
|
||||
|
||||
Naming Rules of Released Binaries:
|
||||
https://github.com/rhysd/go-github-selfupdate#naming-rules-of-released-binaries
|
||||
https://github.com/MedzikUser/go-github-selfupdate#naming-rules-of-released-binaries
|
||||
|
||||
Naming Rules of Git Tags:
|
||||
https://github.com/rhysd/go-github-selfupdate#naming-rules-of-git-tags
|
||||
https://github.com/MedzikUser/go-github-selfupdate#naming-rules-of-git-tags
|
||||
|
||||
This package is hosted on GitHub:
|
||||
https://github.com/rhysd/go-github-selfupdate
|
||||
https://github.com/MedzikUser/go-github-selfupdate
|
||||
|
||||
Small CLI tools as wrapper of this library are available also:
|
||||
https://github.com/rhysd/go-github-selfupdate/cmd/detect-latest-release
|
||||
https://github.com/rhysd/go-github-selfupdate/cmd/go-get-release
|
||||
https://github.com/MedzikUser/go-github-selfupdate/cmd/detect-latest-release
|
||||
https://github.com/MedzikUser/go-github-selfupdate/cmd/go-get-release
|
||||
*/
|
||||
package selfupdate
|
||||
|
|
|
@ -15,9 +15,13 @@ import (
|
|||
"github.com/inconshreveable/go-update"
|
||||
)
|
||||
|
||||
func uncompressAndUpdate(src io.Reader, assetURL, cmdPath string) error {
|
||||
_, cmd := filepath.Split(cmdPath)
|
||||
asset, err := UncompressCommand(src, assetURL, cmd)
|
||||
func uncompressAndUpdate(src io.Reader, assetURL, cmdPath string, binaryName string) error {
|
||||
if binaryName == "" {
|
||||
_, binaryName = filepath.Split(cmdPath)
|
||||
} else if runtime.GOOS == "windows" {
|
||||
binaryName += ".exe"
|
||||
}
|
||||
asset, err := UncompressCommand(src, assetURL, binaryName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -76,7 +80,7 @@ func (up *Updater) UpdateTo(rel *Release, cmdPath string) error {
|
|||
}
|
||||
|
||||
if up.validator == nil {
|
||||
return uncompressAndUpdate(bytes.NewReader(data), rel.AssetURL, cmdPath)
|
||||
return uncompressAndUpdate(bytes.NewReader(data), rel.AssetURL, cmdPath, up.binaryName)
|
||||
}
|
||||
|
||||
validationSrc, validationRedirectURL, err := up.api.Repositories.DownloadReleaseAsset(up.apiCtx, rel.RepoOwner, rel.RepoName, rel.ValidationAssetID, &client)
|
||||
|
@ -102,7 +106,7 @@ func (up *Updater) UpdateTo(rel *Release, cmdPath string) error {
|
|||
return fmt.Errorf("Failed validating asset content: %v", err)
|
||||
}
|
||||
|
||||
return uncompressAndUpdate(bytes.NewReader(data), rel.AssetURL, cmdPath)
|
||||
return uncompressAndUpdate(bytes.NewReader(data), rel.AssetURL, cmdPath, up.binaryName)
|
||||
}
|
||||
|
||||
// UpdateCommand updates a given command binary to the latest version.
|
||||
|
@ -165,7 +169,7 @@ func UpdateTo(assetURL, cmdPath string) error {
|
|||
return err
|
||||
}
|
||||
defer src.Close()
|
||||
return uncompressAndUpdate(src, assetURL, cmdPath)
|
||||
return uncompressAndUpdate(src, assetURL, cmdPath, up.binaryName)
|
||||
}
|
||||
|
||||
// UpdateCommand updates a given command binary to the latest version.
|
||||
|
|
|
@ -11,16 +11,34 @@ import (
|
|||
"github.com/blang/semver"
|
||||
)
|
||||
|
||||
func setupTestBinary() {
|
||||
if err := exec.Command("go", "build", "./testdata/github-release-test/").Run(); err != nil {
|
||||
func setupTestBinary(name ...string) {
|
||||
var options []string
|
||||
var output string
|
||||
if len(name) == 0 {
|
||||
options = []string{"build", "./testdata/github-release-test/"}
|
||||
} else {
|
||||
output = name[0]
|
||||
if runtime.GOOS == "windows" {
|
||||
output += ".exe"
|
||||
}
|
||||
options = []string{"build", "-o", output, "./testdata/github-release-test/"}
|
||||
}
|
||||
|
||||
if err := exec.Command("go", options...).Run(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func teardownTestBinary() {
|
||||
bin := "github-release-test"
|
||||
func teardownTestBinary(name ...string) {
|
||||
var bin string
|
||||
if len(name) == 0 {
|
||||
bin = "github-release-test"
|
||||
} else {
|
||||
bin = name[0]
|
||||
}
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
bin = "github-release-test.exe"
|
||||
bin += ".exe"
|
||||
}
|
||||
if err := os.Remove(bin); err != nil {
|
||||
panic(err)
|
||||
|
@ -64,6 +82,41 @@ func TestUpdateCommand(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestUpdateWithDifferentBinaryName(t *testing.T) {
|
||||
setupTestBinary("gh-release-test")
|
||||
defer teardownTestBinary("gh-release-test")
|
||||
latest := semver.MustParse("1.2.3")
|
||||
prev := semver.MustParse("1.2.2")
|
||||
|
||||
_, err := UpdateCommand("gh-release-test", prev, "rhysd-test/test-release-zip")
|
||||
if err == nil {
|
||||
t.Fatal("Error should occur for broken package")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "the command is not found") {
|
||||
t.Fatal("Unexpected error:", err)
|
||||
}
|
||||
|
||||
up, err := NewUpdater(Config{BinaryName: "github-release-test", Filters: []string{"github-release-test"}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rel, err := up.UpdateCommand("gh-release-test", prev, "rhysd-test/test-release-zip")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if rel.Version.NE(latest) {
|
||||
t.Error("Version is not latest", rel.Version)
|
||||
}
|
||||
bytes, err := exec.Command(filepath.FromSlash("./gh-release-test")).Output()
|
||||
if err != nil {
|
||||
t.Fatal("Failed to run test binary after update:", err)
|
||||
}
|
||||
out := string(bytes)
|
||||
if out != "v1.2.3\n" {
|
||||
t.Error("Output from test binary after update is unexpected:", out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateViaSymlink(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skip tests in short mode.")
|
||||
|
|
|
@ -15,10 +15,11 @@ import (
|
|||
// Updater is responsible for managing the context of self-update.
|
||||
// It contains GitHub client and its context.
|
||||
type Updater struct {
|
||||
api *github.Client
|
||||
apiCtx context.Context
|
||||
validator Validator
|
||||
filters []*regexp.Regexp
|
||||
api *github.Client
|
||||
apiCtx context.Context
|
||||
validator Validator
|
||||
filters []*regexp.Regexp
|
||||
binaryName string
|
||||
}
|
||||
|
||||
// Config represents the configuration of self-update.
|
||||
|
@ -37,6 +38,10 @@ type Config struct {
|
|||
// An asset is selected if it matches any of those, in addition to the regular tag, os, arch, extensions.
|
||||
// Please make sure that your filter(s) uniquely match an asset.
|
||||
Filters []string
|
||||
|
||||
// BinaryName represents the name of the binary extracted from the archive downloaded from GitHub.
|
||||
// If unset, the current executable's name will be used to match.
|
||||
BinaryName string
|
||||
}
|
||||
|
||||
func newHTTPClient(ctx context.Context, token string) *http.Client {
|
||||
|
@ -71,7 +76,7 @@ func NewUpdater(config Config) (*Updater, error) {
|
|||
|
||||
if config.EnterpriseBaseURL == "" {
|
||||
client := github.NewClient(hc)
|
||||
return &Updater{api: client, apiCtx: ctx, validator: config.Validator, filters: filtersRe}, nil
|
||||
return &Updater{api: client, apiCtx: ctx, validator: config.Validator, filters: filtersRe, binaryName: config.BinaryName}, nil
|
||||
}
|
||||
|
||||
u := config.EnterpriseUploadURL
|
||||
|
@ -82,7 +87,8 @@ func NewUpdater(config Config) (*Updater, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Updater{api: client, apiCtx: ctx, validator: config.Validator, filters: filtersRe}, nil
|
||||
|
||||
return &Updater{api: client, apiCtx: ctx, validator: config.Validator, filters: filtersRe, binaryName: config.BinaryName}, nil
|
||||
}
|
||||
|
||||
// DefaultUpdater creates a new updater instance with default configuration.
|
||||
|
|
Loading…
Reference in New Issue