This commit is contained in:
MedzikUser 2021-10-27 22:23:51 +02:00
parent 8ab4b94ea1
commit 9abefd0460
16 changed files with 162 additions and 114 deletions

View File

@ -15,7 +15,7 @@
- New Feature: Filtering releases by matching regular expressions to release names (Thanks to [@fredbi](https://github.com/fredbi)). - 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 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. for more details.
- Allow `{cmd}_{os}_{arch}` format for executable names. - Allow `{cmd}_{os}_{arch}` format for executable names.
- `.tgz` file name suffix was supported. - `.tgz` file name suffix was supported.
@ -24,7 +24,7 @@
## [v1.1.0] - 2018-11-10 ## [v1.1.0] - 2018-11-10
- New Feature: Signature validation for release assets (Thanks to [@tobiaskohlbau](https://github.com/tobiaskohlbau)). - 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 ## [v1.0.0] - 2018-09-23
@ -32,9 +32,9 @@
First release! :tada: First release! :tada:
[v1.2.3]: https://github.com/rhysd/go-github-selfupdate/compare/v1.2.2...v1.2.3 [v1.2.3]: https://github.com/MedzikUser/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.2]: https://github.com/MedzikUser/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.1]: https://github.com/MedzikUser/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.2.0]: https://github.com/MedzikUser/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.1.0]: https://github.com/MedzikUser/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.0.0]: https://github.com/MedzikUser/go-github-selfupdate/compare/example-1.2.4...v1.0.0

View File

@ -1,6 +1,6 @@
the MIT License the MIT License
Copyright (c) 2017 rhysd Copyright (c) 2017 MedzikUser
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -36,9 +36,9 @@ And small wrapper CLIs are provided:
- [detect-latest-release](./cmd/detect-latest-release): Detect the latest release of given GitHub repository from command line - [detect-latest-release](./cmd/detect-latest-release): Detect the latest release of given GitHub repository from command line
- [go-get-release](./cmd/go-get-release): Like `go get`, but install a release binary from GitHub instead - [go-get-release](./cmd/go-get-release): Like `go get`, but install a release binary from GitHub instead
[Slide at GoCon 2018 Spring (Japanese)](https://speakerdeck.com/rhysd/go-selfupdate-github-de-turuwozi-ji-atupudetosuru) [Slide at GoCon 2018 Spring (Japanese)](https://speakerdeck.com/MedzikUser/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/ [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. 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. And check the version by `-version`. `-help` flag is also available to know all flags.
@ -76,9 +76,9 @@ So running `-selfupdate` again only shows 'Current binary is the latest version'
Following tools are using this library. Following tools are using this library.
- [dot-github](https://github.com/rhysd/dot-github) - [dot-github](https://github.com/MedzikUser/dot-github)
- [dotfiles](https://github.com/rhysd/dotfiles) - [dotfiles](https://github.com/MedzikUser/dotfiles)
- [github-clone-all](https://github.com/rhysd/github-clone-all) - [github-clone-all](https://github.com/MedzikUser/github-clone-all)
- [pythonbrew](https://github.com/utahta/pythonbrew) - [pythonbrew](https://github.com/utahta/pythonbrew)
- [akashic](https://github.com/cowlick/akashic) - [akashic](https://github.com/cowlick/akashic)
- [butler](https://github.com/netzkern/butler) - [butler](https://github.com/netzkern/butler)
@ -106,7 +106,7 @@ Following is the easiest way to use this package.
import ( import (
"log" "log"
"github.com/blang/semver" "github.com/blang/semver"
"github.com/rhysd/go-github-selfupdate/selfupdate" "github.com/MedzikUser/go-github-selfupdate/selfupdate"
) )
const version = "1.2.3" const version = "1.2.3"
@ -134,7 +134,7 @@ Following asks user to update or not.
import ( import (
"bufio" "bufio"
"github.com/blang/semver" "github.com/blang/semver"
"github.com/rhysd/go-github-selfupdate/selfupdate" "github.com/MedzikUser/go-github-selfupdate/selfupdate"
"log" "log"
"os" "os"
) )
@ -196,7 +196,7 @@ Following is an example of usage with GitHub Enterprise.
import ( import (
"log" "log"
"github.com/blang/semver" "github.com/blang/semver"
"github.com/rhysd/go-github-selfupdate/selfupdate" "github.com/MedzikUser/go-github-selfupdate/selfupdate"
) )
const version = "1.2.3" const version = "1.2.3"
@ -433,12 +433,12 @@ tj/go-update:
Distributed under the [MIT License](LICENSE) Distributed under the [MIT License](LICENSE)
[GoDoc Badge]: https://godoc.org/github.com/rhysd/go-github-selfupdate/selfupdate?status.svg [GoDoc Badge]: https://godoc.org/github.com/MedzikUser/go-github-selfupdate/selfupdate?status.svg
[GoDoc]: https://godoc.org/github.com/rhysd/go-github-selfupdate/selfupdate [GoDoc]: https://godoc.org/github.com/MedzikUser/go-github-selfupdate/selfupdate
[TravisCI Status]: https://travis-ci.org/rhysd/go-github-selfupdate.svg?branch=master [TravisCI Status]: https://travis-ci.org/MedzikUser/go-github-selfupdate.svg?branch=master
[TravisCI]: https://travis-ci.org/rhysd/go-github-selfupdate [TravisCI]: https://travis-ci.org/MedzikUser/go-github-selfupdate
[AppVeyor Status]: https://ci.appveyor.com/api/projects/status/1tpyd9q9tw3ime5u/branch/master?svg=true [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 [AppVeyor]: https://ci.appveyor.com/project/MedzikUser/go-github-selfupdate/branch/master
[Codecov Status]: https://codecov.io/gh/rhysd/go-github-selfupdate/branch/master/graph/badge.svg [Codecov Status]: https://codecov.io/gh/MedzikUser/go-github-selfupdate/branch/master/graph/badge.svg
[Codecov]: https://codecov.io/gh/rhysd/go-github-selfupdate [Codecov]: https://codecov.io/gh/MedzikUser/go-github-selfupdate
[GitHub Enterprise]: https://enterprise.github.com/home [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`. 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. To know the usage, please try the command without any argument.
@ -12,9 +12,9 @@ To know the usage, please try the command without any argument.
$ detect-latest-release $ detect-latest-release
``` ```
For example, following shows the latest version of [github-clone-all](https://github.com/rhysd/github-clone-all). For example, following shows the latest version of [github-clone-all](https://github.com/MedzikUser/github-clone-all).
``` ```
$ detect-latest-release rhysd/github-clone-all $ detect-latest-release MedzikUser/github-clone-all
``` ```

View File

@ -3,7 +3,7 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"github.com/rhysd/go-github-selfupdate/selfupdate" "github.com/MedzikUser/go-github-selfupdate/selfupdate"
"os" "os"
"regexp" "regexp"
"strings" "strings"

View File

@ -1,10 +1,10 @@
Like `go get`, but it downloads and installs the latest release binary from GitHub instead. 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`. 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/`. 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 ( import (
"flag" "flag"
"fmt" "fmt"
"github.com/rhysd/go-github-selfupdate/selfupdate" "github.com/MedzikUser/go-github-selfupdate/selfupdate"
"go/build" "go/build"
"io" "io"
"net/http" "net/http"
@ -28,7 +28,7 @@ func getCommand(pkg string) string {
_, cmd := filepath.Split(pkg) _, cmd := filepath.Split(pkg)
if cmd == "" { if cmd == "" {
// When pkg path is ending with path separator, we need to split it out. // When pkg path is ending with path separator, we need to split it out.
// i.e. github.com/rhysd/foo/cmd/bar/ // i.e. github.com/MedzikUser/foo/cmd/bar/
_, cmd = filepath.Split(cmd) _, cmd = filepath.Split(cmd)
} }
return cmd return cmd
@ -118,7 +118,7 @@ func main() {
os.Exit(1) os.Exit(1)
} }
} else { } else {
if err := selfupdate.UpdateTo(latest.AssetURL, cmdPath, "" /* TODO */); err != nil { if err := selfupdate.UpdateTo(latest.AssetURL, cmdPath); err != nil {
fmt.Fprintf(os.Stderr, "Error while replacing the binary with %s: %s\n", latest.AssetURL, err) fmt.Fprintf(os.Stderr, "Error while replacing the binary with %s: %s\n", latest.AssetURL, err)
os.Exit(1) os.Exit(1)
} }

View File

@ -4,7 +4,7 @@ import (
"flag" "flag"
"fmt" "fmt"
"github.com/blang/semver" "github.com/blang/semver"
"github.com/rhysd/go-github-selfupdate/selfupdate" "github.com/MedzikUser/go-github-selfupdate/selfupdate"
"os" "os"
) )
@ -37,7 +37,7 @@ func main() {
help := flag.Bool("help", false, "Show this help") help := flag.Bool("help", false, "Show this help")
ver := flag.Bool("version", false, "Show version") ver := flag.Bool("version", false, "Show version")
update := flag.Bool("selfupdate", false, "Try go-github-selfupdate via GitHub") 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.Usage = usage
flag.Parse() flag.Parse()

5
go.sum
View File

@ -2,6 +2,7 @@ github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdn
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/blang/semver v3.5.1+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 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 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.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 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@ -26,11 +27,13 @@ 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/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 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I=
github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.9/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-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 h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY=
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= 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-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-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-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 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@ -39,10 +42,12 @@ golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288 h1:JIqe8uIcRBHXDQVvZtHwp8
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 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/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-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-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 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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/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.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= 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/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=

View File

@ -1,20 +0,0 @@
{
"extends": [
"config:base"
],
"includeForks": true,
"prHourlyLimit": 0,
"automergeType": "pr",
"prCreation": "immediate",
"packageRules": [
{
"matchUpdateTypes": [
"minor",
"patch",
"pin",
"digest"
],
"automerge": true
}
]
}

View File

@ -109,7 +109,7 @@ func findReleaseAndAsset(rels []*github.RepositoryRelease,
// Find the latest version from the list of releases. // Find the latest version from the list of releases.
// Returned list from GitHub API is in the order of the date when created. // 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 { for _, rel := range rels {
if a, v, ok := findAssetFromRelease(rel, suffixes, targetVersion, filters); ok { if a, v, ok := findAssetFromRelease(rel, suffixes, targetVersion, filters); ok {
// Note: any version with suffix is less than any version without suffix. // Note: any version with suffix is less than any version without suffix.

View File

@ -12,7 +12,7 @@ import (
) )
func TestDetectReleaseWithVersionPrefix(t *testing.T) { func TestDetectReleaseWithVersionPrefix(t *testing.T) {
r, ok, err := DetectLatest("rhysd/github-clone-all") r, ok, err := DetectLatest("MedzikUser/github-clone-all")
if err != nil { if err != nil {
t.Fatal("Fetch failed:", err) t.Fatal("Fetch failed:", err)
} }
@ -46,7 +46,7 @@ func TestDetectReleaseWithVersionPrefix(t *testing.T) {
if r.PublishedAt.IsZero() { if r.PublishedAt.IsZero() {
t.Error("Release time is unexpectedly zero") t.Error("Release time is unexpectedly zero")
} }
if r.RepoOwner != "rhysd" { if r.RepoOwner != "MedzikUser" {
t.Error("Repo owner is not correct:", r.RepoOwner) t.Error("Repo owner is not correct:", r.RepoOwner)
} }
if r.RepoName != "github-clone-all" { if r.RepoName != "github-clone-all" {
@ -56,7 +56,7 @@ func TestDetectReleaseWithVersionPrefix(t *testing.T) {
func TestDetectVersionExisting(t *testing.T) { func TestDetectVersionExisting(t *testing.T) {
testVersion := "v2.2.0" testVersion := "v2.2.0"
r, ok, err := DetectVersion("rhysd/github-clone-all", testVersion) r, ok, err := DetectVersion("MedzikUser/github-clone-all", testVersion)
if err != nil { if err != nil {
t.Fatal("Fetch failed:", err) t.Fatal("Fetch failed:", err)
} }
@ -69,7 +69,7 @@ func TestDetectVersionExisting(t *testing.T) {
} }
func TestDetectVersionNotExisting(t *testing.T) { func TestDetectVersionNotExisting(t *testing.T) {
r, ok, err := DetectVersion("rhysd/github-clone-all", "foobar") r, ok, err := DetectVersion("MedzikUser/github-clone-all", "foobar")
if err != nil { if err != nil {
t.Fatal("Fetch failed:", err) t.Fatal("Fetch failed:", err)
} }
@ -86,11 +86,11 @@ func TestDetectReleasesForVariousArchives(t *testing.T) {
slug string slug string
prefix string prefix string
}{ }{
{"rhysd-test/test-release-zip", "v"}, {"MedzikUser-test/test-release-zip", "v"},
{"rhysd-test/test-release-tar", "v"}, {"MedzikUser-test/test-release-tar", "v"},
{"rhysd-test/test-release-gzip", "v"}, {"MedzikUser-test/test-release-gzip", "v"},
{"rhysd-test/test-release-xz", "release-v"}, {"MedzikUser-test/test-release-xz", "release-v"},
{"rhysd-test/test-release-tar-xz", "release-"}, {"MedzikUser-test/test-release-tar-xz", "release-"},
} { } {
t.Run(tc.slug, func(t *testing.T) { t.Run(tc.slug, func(t *testing.T) {
r, ok, err := DetectLatest(tc.slug) r, ok, err := DetectLatest(tc.slug)
@ -128,8 +128,8 @@ func TestDetectReleasesForVariousArchives(t *testing.T) {
if r.PublishedAt.IsZero() { if r.PublishedAt.IsZero() {
t.Error("Release time is unexpectedly zero") t.Error("Release time is unexpectedly zero")
} }
if r.RepoOwner != "rhysd-test" { if r.RepoOwner != "MedzikUser-test" {
t.Error("Repo owner should be rhysd-test:", r.RepoOwner) t.Error("Repo owner should be MedzikUser-test:", r.RepoOwner)
} }
if !strings.HasPrefix(r.RepoName, "test-release-") { if !strings.HasPrefix(r.RepoName, "test-release-") {
t.Error("Repo name was not properly detectd:", r.RepoName) t.Error("Repo name was not properly detectd:", r.RepoName)
@ -139,7 +139,7 @@ func TestDetectReleasesForVariousArchives(t *testing.T) {
} }
func TestDetectReleaseButNoAsset(t *testing.T) { func TestDetectReleaseButNoAsset(t *testing.T) {
_, ok, err := DetectLatest("rhysd/clever-f.vim") _, ok, err := DetectLatest("MedzikUser/clever-f.vim")
if err != nil { if err != nil {
t.Fatal("Fetch failed:", err) t.Fatal("Fetch failed:", err)
} }
@ -149,7 +149,7 @@ func TestDetectReleaseButNoAsset(t *testing.T) {
} }
func TestDetectNoRelease(t *testing.T) { func TestDetectNoRelease(t *testing.T) {
_, ok, err := DetectLatest("rhysd/clever-f.vim") _, ok, err := DetectLatest("MedzikUser/clever-f.vim")
if err != nil { if err != nil {
t.Fatal("Fetch failed:", err) t.Fatal("Fetch failed:", err)
} }
@ -179,7 +179,7 @@ func TestInvalidSlug(t *testing.T) {
} }
func TestNonExistingRepo(t *testing.T) { func TestNonExistingRepo(t *testing.T) {
v, ok, err := DetectLatest("rhysd/non-existing-repo") v, ok, err := DetectLatest("MedzikUser/non-existing-repo")
if err != nil { if err != nil {
t.Fatal("Non-existing repo should not cause an error:", v) t.Fatal("Non-existing repo should not cause an error:", v)
} }
@ -189,7 +189,7 @@ func TestNonExistingRepo(t *testing.T) {
} }
func TestNoReleaseFound(t *testing.T) { func TestNoReleaseFound(t *testing.T) {
_, ok, err := DetectLatest("rhysd/misc") _, ok, err := DetectLatest("MedzikUser/misc")
if err != nil { if err != nil {
t.Fatal("Repo having no release should not cause an error:", err) t.Fatal("Repo having no release should not cause an error:", err)
} }

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. There are some naming rules. Please read following links.
Naming Rules of Released Binaries: 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: 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: 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: 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/MedzikUser/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/go-get-release
*/ */
package selfupdate package selfupdate

View File

@ -15,8 +15,13 @@ import (
"github.com/inconshreveable/go-update" "github.com/inconshreveable/go-update"
) )
func uncompressAndUpdate(src io.Reader, assetURL, cmdPath, cmdName string) error { func uncompressAndUpdate(src io.Reader, assetURL, cmdPath string, binaryName string) error {
asset, err := UncompressCommand(src, assetURL, cmdName) if binaryName == "" {
_, binaryName = filepath.Split(cmdPath)
} else if runtime.GOOS == "windows" {
binaryName += ".exe"
}
asset, err := UncompressCommand(src, assetURL, binaryName)
if err != nil { if err != nil {
return err return err
} }
@ -54,7 +59,7 @@ func (up *Updater) downloadDirectlyFromURL(assetURL string) (io.ReadCloser, erro
// UpdateTo downloads an executable from GitHub Releases API and replace current binary with the downloaded one. // UpdateTo downloads an executable from GitHub Releases API and replace current binary with the downloaded one.
// It downloads a release asset via GitHub Releases API so this function is available for update releases on private repository. // 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. // If a redirect occurs, it fallbacks into directly downloading from the redirect URL.
func (up *Updater) UpdateTo(rel *Release, cmdPath, cmdName string) error { func (up *Updater) UpdateTo(rel *Release, cmdPath string) error {
var client http.Client var client http.Client
src, redirectURL, err := up.api.Repositories.DownloadReleaseAsset(up.apiCtx, rel.RepoOwner, rel.RepoName, rel.AssetID, &client) src, redirectURL, err := up.api.Repositories.DownloadReleaseAsset(up.apiCtx, rel.RepoOwner, rel.RepoName, rel.AssetID, &client)
if err != nil { if err != nil {
@ -75,7 +80,7 @@ func (up *Updater) UpdateTo(rel *Release, cmdPath, cmdName string) error {
} }
if up.validator == nil { if up.validator == nil {
return uncompressAndUpdate(bytes.NewReader(data), rel.AssetURL, cmdPath, cmdName) 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) validationSrc, validationRedirectURL, err := up.api.Repositories.DownloadReleaseAsset(up.apiCtx, rel.RepoOwner, rel.RepoName, rel.ValidationAssetID, &client)
@ -101,7 +106,7 @@ func (up *Updater) UpdateTo(rel *Release, cmdPath, cmdName string) error {
return fmt.Errorf("Failed validating asset content: %v", err) return fmt.Errorf("Failed validating asset content: %v", err)
} }
return uncompressAndUpdate(bytes.NewReader(data), rel.AssetURL, cmdPath, cmdName) return uncompressAndUpdate(bytes.NewReader(data), rel.AssetURL, cmdPath, up.binaryName)
} }
// UpdateCommand updates a given command binary to the latest version. // UpdateCommand updates a given command binary to the latest version.
@ -137,8 +142,7 @@ func (up *Updater) UpdateCommand(cmdPath string, current semver.Version, slug st
return rel, nil return rel, nil
} }
log.Println("Will update", cmdPath, "to the latest version", rel.Version) log.Println("Will update", cmdPath, "to the latest version", rel.Version)
_, cmdName := filepath.Split(cmdPath) if err := up.UpdateTo(rel, cmdPath); err != nil {
if err := up.UpdateTo(rel, cmdPath, cmdName); err != nil {
return nil, err return nil, err
} }
return rel, nil return rel, nil
@ -158,14 +162,14 @@ func (up *Updater) UpdateSelf(current semver.Version, slug string) (*Release, er
// This function is low-level API to update the binary. Because it does not use GitHub API and downloads asset directly from the URL via HTTP, // This function is low-level API to update the binary. Because it does not use GitHub API and downloads asset directly from the URL via HTTP,
// this function is not available to update a release for private repositories. // this function is not available to update a release for private repositories.
// cmdPath is a file path to command executable. // cmdPath is a file path to command executable.
func UpdateTo(assetURL, cmdPath, cmdName string) error { func UpdateTo(assetURL, cmdPath string) error {
up := DefaultUpdater() up := DefaultUpdater()
src, err := up.downloadDirectlyFromURL(assetURL) src, err := up.downloadDirectlyFromURL(assetURL)
if err != nil { if err != nil {
return err return err
} }
defer src.Close() defer src.Close()
return uncompressAndUpdate(src, assetURL, cmdPath, cmdName) return uncompressAndUpdate(src, assetURL, cmdPath, up.binaryName)
} }
// UpdateCommand updates a given command binary to the latest version. // UpdateCommand updates a given command binary to the latest version.

View File

@ -11,16 +11,34 @@ import (
"github.com/blang/semver" "github.com/blang/semver"
) )
func setupTestBinary() { func setupTestBinary(name ...string) {
if err := exec.Command("go", "build", "./testdata/github-release-test/").Run(); err != nil { 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) panic(err)
} }
} }
func teardownTestBinary() { func teardownTestBinary(name ...string) {
bin := "github-release-test" var bin string
if len(name) == 0 {
bin = "github-release-test"
} else {
bin = name[0]
}
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
bin = "github-release-test.exe" bin += ".exe"
} }
if err := os.Remove(bin); err != nil { if err := os.Remove(bin); err != nil {
panic(err) panic(err)
@ -33,12 +51,12 @@ func TestUpdateCommand(t *testing.T) {
} }
for _, slug := range []string{ for _, slug := range []string{
"rhysd-test/test-release-zip", "MedzikUser-test/test-release-zip",
"rhysd-test/test-release-tar", "MedzikUser-test/test-release-tar",
"rhysd-test/test-release-gzip", "MedzikUser-test/test-release-gzip",
"rhysd-test/test-release-tar-xz", "MedzikUser-test/test-release-tar-xz",
"rhysd-test/test-release-xz", "MedzikUser-test/test-release-xz",
"rhysd-test/test-release-contain-version", "MedzikUser-test/test-release-contain-version",
} { } {
t.Run(slug, func(t *testing.T) { t.Run(slug, func(t *testing.T) {
setupTestBinary() setupTestBinary()
@ -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, "MedzikUser-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, "MedzikUser-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) { func TestUpdateViaSymlink(t *testing.T) {
if testing.Short() { if testing.Short() {
t.Skip("skip tests in short mode.") t.Skip("skip tests in short mode.")
@ -87,7 +140,7 @@ func TestUpdateViaSymlink(t *testing.T) {
latest := semver.MustParse("1.2.3") latest := semver.MustParse("1.2.3")
prev := semver.MustParse("1.2.2") prev := semver.MustParse("1.2.2")
rel, err := UpdateCommand(symPath, prev, "rhysd-test/test-release-zip") rel, err := UpdateCommand(symPath, prev, "MedzikUser-test/test-release-zip")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -167,7 +220,7 @@ func TestNotExistingCommandPath(t *testing.T) {
func TestNoReleaseFoundForUpdate(t *testing.T) { func TestNoReleaseFoundForUpdate(t *testing.T) {
v := semver.MustParse("1.0.0") v := semver.MustParse("1.0.0")
fake := filepath.FromSlash("./testdata/fake-executable") fake := filepath.FromSlash("./testdata/fake-executable")
rel, err := UpdateCommand(fake, v, "rhysd/misc") rel, err := UpdateCommand(fake, v, "MedzikUser/misc")
if err != nil { if err != nil {
t.Fatal("No release should not make an error:", err) t.Fatal("No release should not make an error:", err)
} }
@ -193,7 +246,7 @@ func TestCurrentIsTheLatest(t *testing.T) {
defer teardownTestBinary() defer teardownTestBinary()
v := semver.MustParse("1.2.3") v := semver.MustParse("1.2.3")
rel, err := UpdateCommand("github-release-test", v, "rhysd-test/test-release-zip") rel, err := UpdateCommand("github-release-test", v, "MedzikUser-test/test-release-zip")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -217,7 +270,7 @@ func TestBrokenBinaryUpdate(t *testing.T) {
} }
fake := filepath.FromSlash("./testdata/fake-executable") fake := filepath.FromSlash("./testdata/fake-executable")
_, err := UpdateCommand(fake, semver.MustParse("1.2.2"), "rhysd-test/test-incorrect-release") _, err := UpdateCommand(fake, semver.MustParse("1.2.2"), "MedzikUser-test/test-incorrect-release")
if err == nil { if err == nil {
t.Fatal("Error should occur for broken package") t.Fatal("Error should occur for broken package")
} }
@ -228,7 +281,7 @@ func TestBrokenBinaryUpdate(t *testing.T) {
func TestInvalidSlugForUpdate(t *testing.T) { func TestInvalidSlugForUpdate(t *testing.T) {
fake := filepath.FromSlash("./testdata/fake-executable") fake := filepath.FromSlash("./testdata/fake-executable")
_, err := UpdateCommand(fake, semver.MustParse("1.0.0"), "rhysd/") _, err := UpdateCommand(fake, semver.MustParse("1.0.0"), "MedzikUser/")
if err == nil { if err == nil {
t.Fatal("Unknown repo should cause an error") t.Fatal("Unknown repo should cause an error")
} }
@ -238,7 +291,7 @@ func TestInvalidSlugForUpdate(t *testing.T) {
} }
func TestInvalidAssetURL(t *testing.T) { func TestInvalidAssetURL(t *testing.T) {
err := UpdateTo("https://github.com/rhysd/non-existing-repo/releases/download/v1.2.3/foo.zip", "foo", "bar") err := UpdateTo("https://github.com/MedzikUser/non-existing-repo/releases/download/v1.2.3/foo.zip", "foo")
if err == nil { if err == nil {
t.Fatal("Error should occur for URL not found") t.Fatal("Error should occur for URL not found")
} }
@ -248,8 +301,8 @@ func TestInvalidAssetURL(t *testing.T) {
} }
func TestBrokenAsset(t *testing.T) { func TestBrokenAsset(t *testing.T) {
asset := "https://github.com/rhysd-test/test-incorrect-release/releases/download/invalid/broken-zip.zip" asset := "https://github.com/MedzikUser-test/test-incorrect-release/releases/download/invalid/broken-zip.zip"
err := UpdateTo(asset, "foo", "bar") err := UpdateTo(asset, "foo")
if err == nil { if err == nil {
t.Fatal("Error should occur for URL not found") t.Fatal("Error should occur for URL not found")
} }
@ -263,7 +316,7 @@ func TestBrokenGitHubEnterpriseURL(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
err = up.UpdateTo(&Release{AssetURL: "https://example.com"}, "foo", "") err = up.UpdateTo(&Release{AssetURL: "https://example.com"}, "foo")
if err == nil { if err == nil {
t.Fatal("Invalid GitHub Enterprise base URL should raise an error") t.Fatal("Invalid GitHub Enterprise base URL should raise an error")
} }
@ -332,7 +385,7 @@ func TestUpdateFromGitHubPrivateRepo(t *testing.T) {
latest := semver.MustParse("1.2.3") latest := semver.MustParse("1.2.3")
prev := semver.MustParse("1.2.2") prev := semver.MustParse("1.2.2")
rel, err := up.UpdateCommand("github-release-test", prev, "rhysd/private-release-test") rel, err := up.UpdateCommand("github-release-test", prev, "MedzikUser/private-release-test")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -15,10 +15,11 @@ import (
// Updater is responsible for managing the context of self-update. // Updater is responsible for managing the context of self-update.
// It contains GitHub client and its context. // It contains GitHub client and its context.
type Updater struct { type Updater struct {
api *github.Client api *github.Client
apiCtx context.Context apiCtx context.Context
validator Validator validator Validator
filters []*regexp.Regexp filters []*regexp.Regexp
binaryName string
} }
// Config represents the configuration of self-update. // 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. // 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. // Please make sure that your filter(s) uniquely match an asset.
Filters []string 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 { func newHTTPClient(ctx context.Context, token string) *http.Client {
@ -71,7 +76,7 @@ func NewUpdater(config Config) (*Updater, error) {
if config.EnterpriseBaseURL == "" { if config.EnterpriseBaseURL == "" {
client := github.NewClient(hc) 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 u := config.EnterpriseUploadURL
@ -82,7 +87,8 @@ func NewUpdater(config Config) (*Updater, error) {
if err != nil { if err != nil {
return nil, err 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. // DefaultUpdater creates a new updater instance with default configuration.