Compare commits

...

28 Commits

Author SHA1 Message Date
Renovate Bot 14b987cb42 Update module github.com/blang/semver to v3.8.0 2022-06-10 18:06:24 +02:00
Renovate Bot fed5b400de Update module github.com/ulikunitz/xz to v0.5.10 2022-06-10 18:06:13 +02:00
Oskar 5aea9fd5f3
Update go.yml 2021-10-27 23:01:16 +02:00
MedzikUser e33f9e522e update 2021-10-27 22:59:25 +02:00
MedzikUser 542dc5db61 Revert "update"
This reverts commit c9e5fe26ca.
2021-10-27 22:56:40 +02:00
MedzikUser 4b201b07f5 update 2021-10-27 22:54:30 +02:00
MedzikUser c9e5fe26ca update 2021-10-27 22:54:03 +02:00
MedzikUser e8ecb189e5 update 2021-10-27 22:48:35 +02:00
MedzikUser a75b2492cb update 2021-10-27 22:41:38 +02:00
MedzikUser 8a2cf5e596 update 2021-10-27 22:35:41 +02:00
Oskar ec571e8c14
Create go.yml 2021-10-27 22:26:02 +02:00
MedzikUser 9c76d66885 update 2021-10-27 22:24:36 +02:00
MedzikUser 9abefd0460 update 2021-10-27 22:23:51 +02:00
Oskar 8ab4b94ea1
Update renovate.json 2021-10-27 22:18:50 +02:00
Oskar 13766db3e1
Create renovate.json 2021-08-18 20:46:00 +02:00
Medzik f29763a683 Update 2021-07-24 19:39:58 +00:00
rhysd 04a545f8ea update changelog for v1.2.3 2021-01-13 21:25:45 +09:00
Linda_pp 1aa7d81a46
Merge pull request #38 from bhamail/update_x_text
update x/text. Fix CVE-2020-14040
2021-01-13 16:43:16 +09:00
Dan Rollo f315b89e29 update x/text. Fix CVE-2020-14040 2021-01-12 23:03:40 -05:00
Linda_pp 4161c14e0c
Merge pull request #37 from bhamail/update_x_crypto
update x/crypto. Fix CVE-2019-11840
2021-01-13 12:55:27 +09:00
Dan Rollo ed69ef6c6b Merge branch 'master' into update_x_crypto
# Conflicts:
#	go.mod
2021-01-12 22:48:47 -05:00
Linda_pp 466402f90d
Merge pull request #36 from bhamail/update_xz
update to latest release of xz lib. Fix CVE-2020-16845
2021-01-13 10:41:36 +09:00
Dan Rollo a894e020c3 update x/crypto. Fix CVE-2019-11840 2021-01-12 19:03:43 -05:00
Dan Rollo 40792dc985 update to latest release of xz lib. Fix CVE-2020-16845 2021-01-12 18:31:49 -05:00
Linda_pp 5766a1046b
Merge pull request #29 from michaelbirdflyt/master
update to go-github v30.1.0
2020-04-10 15:26:13 +09:00
Mike Bird 17cd45ef2c update to go-github v30.1.0 2020-04-09 17:28:13 -07:00
rhysd 6cf6ce8c7a update changelog for v1.2.1 2019-12-19 18:08:27 +09:00
rhysd 905eb9f670 fix .tgz file is not handled on UncompressCommand 2019-12-19 16:28:00 +09:00
19 changed files with 254 additions and 82 deletions

26
.github/workflows/go.yml vendored Normal file
View File

@ -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 ./...

View File

@ -1,20 +1,30 @@
## [Unreleased]
## [v1.2.3] - 2021-01-13
- Fix security issues in dependencies; CVE-2020-16845, CVE-2019-11840, CVE-2020-14040 (Thanks to [@bhamail](https://github.com/bhamail)).
## [v1.2.2] - 2020-04-10
- Update `go-github` dependency to v30.1.0
## [v1.2.1] - 2019-12-19
- Fix `.tgz` file was not handled as `.tar.gz`.
## [v1.2.0] - 2019-12-19
- Filtering releases by matching regular expressions to release names was added (Thanks to @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)
for more details.
- Allow `{cmd}_{os}_{arch}` format for executable names
- `.tgz` file name suffix was supported
- 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/MedzikUser/go-github-selfupdate/selfupdate#Config)
for more details.
- Allow `{cmd}_{os}_{arch}` format for executable names.
- `.tgz` file name suffix was supported.
## [v1.1.0] - 2018-11-10
- Signature validation for release assets was added. (Thanks to @tobiaskohlbau). Please read
[the instruction](https://github.com/rhysd/go-github-selfupdate#hash-or-signature-validation) for usage.
- New Feature: Signature validation for release assets (Thanks to [@tobiaskohlbau](https://github.com/tobiaskohlbau)).
Please read [the instruction](https://github.com/MedzikUser/go-github-selfupdate#hash-or-signature-validation) for usage.
## [v1.0.0] - 2018-09-23
@ -22,7 +32,9 @@ for more details.
First release! :tada:
[Unreleased]: https://github.com/rhysd/go-github-selfupdate/compare/v1.2.0...HEAD
[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

View File

@ -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

View File

@ -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.

View File

@ -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"

View File

@ -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/`.

View File

@ -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"

View File

@ -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()

14
go.mod
View File

@ -1,18 +1,16 @@
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/google/go-github v17.0.0+incompatible
github.com/google/go-querystring v1.0.0 // indirect
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.5
golang.org/x/net v0.0.0-20181108082009-03003ca0c849 // indirect
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/sync v0.0.0-20181108010431-42b317875d0f // indirect
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8 // indirect
golang.org/x/text v0.3.5 // indirect
google.golang.org/appengine v1.3.0 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
)

70
go.sum Normal file
View File

@ -0,0 +1,70 @@
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=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/go-github/v30 v30.1.0 h1:VLDx+UolQICEOKu2m4uAoMti1SxuEBAl7RSEG16L+Oo=
github.com/google/go-github/v30 v30.1.0/go.mod h1:n8jBpHl45a/rlBUtRJMOG4GhNADUQFEufcolZ95JfU8=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf h1:WfD7VjIE6z8dIvMsI4/s+1qr5EL+zoIGev1BQj1eoJ8=
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf/go.mod h1:hyb9oH7vZsitZCiBt0ZvifOrB+qc8PS5IiilCIb87rg=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.2 h1:3mYCb7aPxS/RU7TI1y4rkEn1oKmPRjNJLNEXgw7MH2I=
github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/tcnksm/go-gitconfig v0.1.2 h1:iiDhRitByXAEyjgBqsKi9QU4o2TNtv9kPP3RgPgXBPw=
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=
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288 h1:JIqe8uIcRBHXDQVvZtHwp80ai3Lw3IJAeJEs55Dc1W0=
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.3.0 h1:FBSsiFRMz3LBeXIomRnVzrQwSDj4ibvcRexLG0LZGQk=
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

View File

@ -7,7 +7,7 @@ import (
"strings"
"github.com/blang/semver"
"github.com/google/go-github/github"
"github.com/google/go-github/v30/github"
)
var reVersion = regexp.MustCompile(`\d+\.\d+\.\d+`)
@ -69,7 +69,7 @@ func findAssetFromRelease(rel *github.RepositoryRelease,
for _, s := range suffixes {
if strings.HasSuffix(name, s) { // require version, arch etc
// default: assume single artifact
return &asset, ver, true
return asset, ver, true
}
}
}
@ -81,7 +81,7 @@ func findAssetFromRelease(rel *github.RepositoryRelease,
func findValidationAsset(rel *github.RepositoryRelease, validationName string) (*github.ReleaseAsset, bool) {
for _, asset := range rel.Assets {
if asset.GetName() == validationName {
return &asset, true
return asset, true
}
}
return nil, false
@ -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.

View File

@ -8,7 +8,7 @@ import (
"testing"
"github.com/blang/semver"
"github.com/google/go-github/github"
"github.com/google/go-github/v30/github"
)
func TestDetectReleaseWithVersionPrefix(t *testing.T) {
@ -279,7 +279,7 @@ func TestFindReleaseAndAsset(t *testing.T) {
rels: &github.RepositoryRelease{
Name: &rel1,
TagName: &v1,
Assets: []github.ReleaseAsset{
Assets: []*github.ReleaseAsset{
{
Name: &asset1,
URL: &url1,
@ -296,7 +296,7 @@ func TestFindReleaseAndAsset(t *testing.T) {
rels: &github.RepositoryRelease{
Name: &rel11,
TagName: &v11,
Assets: []github.ReleaseAsset{
Assets: []*github.ReleaseAsset{
{
Name: &wrongAsset1,
URL: &url11,
@ -311,7 +311,7 @@ func TestFindReleaseAndAsset(t *testing.T) {
rels: &github.RepositoryRelease{
Name: &rel11,
TagName: &v11,
Assets: []github.ReleaseAsset{
Assets: []*github.ReleaseAsset{
{
Name: &asset1,
URL: &url11,
@ -328,7 +328,7 @@ func TestFindReleaseAndAsset(t *testing.T) {
rels: &github.RepositoryRelease{
Name: &rel11,
TagName: &v11,
Assets: []github.ReleaseAsset{
Assets: []*github.ReleaseAsset{
{
Name: &asset11,
URL: &url11,
@ -346,7 +346,7 @@ func TestFindReleaseAndAsset(t *testing.T) {
rels: &github.RepositoryRelease{
Name: &rel11,
TagName: &v11,
Assets: []github.ReleaseAsset{
Assets: []*github.ReleaseAsset{
{
Name: &asset11,
URL: &url11,
@ -368,7 +368,7 @@ func TestFindReleaseAndAsset(t *testing.T) {
rels: &github.RepositoryRelease{
Name: &rel11,
TagName: &v11,
Assets: []github.ReleaseAsset{
Assets: []*github.ReleaseAsset{
{
Name: &asset11,
URL: &url11,
@ -390,7 +390,7 @@ func TestFindReleaseAndAsset(t *testing.T) {
rels: &github.RepositoryRelease{
Name: &rel11,
TagName: &v11,
Assets: []github.ReleaseAsset{
Assets: []*github.ReleaseAsset{
{
Name: &asset11,
URL: &url11,
@ -415,7 +415,7 @@ func TestFindReleaseAndAsset(t *testing.T) {
rels: &github.RepositoryRelease{
Name: &rel11,
TagName: &v11,
Assets: []github.ReleaseAsset{
Assets: []*github.ReleaseAsset{
{
Name: &asset11,
URL: &url11,

View File

@ -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

BIN
selfupdate/testdata/foo.tgz vendored Normal file

Binary file not shown.

View File

@ -59,7 +59,7 @@ func unarchiveTar(src io.Reader, url, cmd string) (io.Reader, error) {
// UncompressCommand uncompresses the given source. Archive and compression format is
// automatically detected from 'url' parameter, which represents the URL of asset.
// This returns a reader for the uncompressed command given by 'cmd'. '.zip',
// '.tar.gz', '.tar.xz', '.gz' and '.xz' are supported.
// '.tar.gz', '.tar.xz', '.tgz', '.gz' and '.xz' are supported.
func UncompressCommand(src io.Reader, url, cmd string) (io.Reader, error) {
if strings.HasSuffix(url, ".zip") {
log.Println("Uncompressing zip file", url)
@ -86,7 +86,7 @@ func UncompressCommand(src io.Reader, url, cmd string) (io.Reader, error) {
}
return nil, fmt.Errorf("File '%s' for the command is not found in %s", cmd, url)
} else if strings.HasSuffix(url, ".tar.gz") {
} else if strings.HasSuffix(url, ".tar.gz") || strings.HasSuffix(url, ".tgz") {
log.Println("Uncompressing tar.gz file", url)
gz, err := gzip.NewReader(src)

View File

@ -44,6 +44,7 @@ func TestUncompress(t *testing.T) {
"testdata/single-file.gz",
"testdata/single-file.gzip",
"testdata/foo.tar.gz",
"testdata/foo.tgz",
"testdata/foo.tar.xz",
"testdata/single-file.xz",
} {

View File

@ -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
}
@ -56,7 +60,8 @@ func (up *Updater) downloadDirectlyFromURL(assetURL string) (io.ReadCloser, erro
// It downloads a release asset via GitHub Releases API so this function is available for update releases on private repository.
// If a redirect occurs, it fallbacks into directly downloading from the redirect URL.
func (up *Updater) UpdateTo(rel *Release, cmdPath string) error {
src, redirectURL, err := up.api.Repositories.DownloadReleaseAsset(up.apiCtx, rel.RepoOwner, rel.RepoName, rel.AssetID)
var client http.Client
src, redirectURL, err := up.api.Repositories.DownloadReleaseAsset(up.apiCtx, rel.RepoOwner, rel.RepoName, rel.AssetID, &client)
if err != nil {
return fmt.Errorf("Failed to call GitHub Releases API for getting an asset(ID: %d) for repository '%s/%s': %s", rel.AssetID, rel.RepoOwner, rel.RepoName, err)
}
@ -75,10 +80,10 @@ 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)
validationSrc, validationRedirectURL, err := up.api.Repositories.DownloadReleaseAsset(up.apiCtx, rel.RepoOwner, rel.RepoName, rel.ValidationAssetID, &client)
if err != nil {
return fmt.Errorf("Failed to call GitHub Releases API for getting an validation asset(ID: %d) for repository '%s/%s': %s", rel.ValidationAssetID, rel.RepoOwner, rel.RepoName, err)
}
@ -101,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.
@ -164,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.

View File

@ -1,25 +1,44 @@
package selfupdate
import (
"github.com/blang/semver"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"
"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)
@ -63,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.")

View File

@ -7,7 +7,7 @@ import (
"os"
"regexp"
"github.com/google/go-github/github"
"github.com/google/go-github/v30/github"
gitconfig "github.com/tcnksm/go-gitconfig"
"golang.org/x/oauth2"
)
@ -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.