godownloader

Download Go binaries as fast and easily as possible.

  • 所有者: goreleaser/godownloader
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

Warning: this is no longer actively maintained.

See #161 for details.



This is the inverse of goreleaser. The goreleaser YAML file is read and creates a custom shell script that can download the right package and the right version for the existing machine.

If you use goreleaser already, this will create scripts suitable for "curl bash" style downloads.

This is also useful in CI/CD systems such as travis-ci.org.

  • Much faster then 'go get' (sometimes up to 100x)
  • Make sure your local environment (macOS) and the CI environment (Linux) are using the exact same versions of your go binaries.

CI/CD Example

Let's say you are using hugo, the static website generator, with travis-ci.

Your old .travis.yml file might have

install:
  - go get github.com/gohugoio/hugo

This can take up to 30 seconds!

Hugo doesn't have (yet) a godownloader.sh file. So we will make our own:

# create a godownloader script
godownloader --repo=gohugoio/hugo > ./godownloader-hugo.sh

and add godownloader-hugo.sh to your GitHub repo. Edit your .travis.yml as such

install:
  - ./godownloader-hugo.sh v0.37.1

Without a version number, GitHub is queried to get the latest version number.

install:
  - ./godownloader-hugo.sh

Typical download time is 0.3 seconds, or 100x improvement.

Your new hugo binary is in ./bin, so change your Makefie or scripts to use ./bin/hugo.

The default installation directory can be changed with the -b flag or the BINDIR environment variable.

Notes on Functionality

  • Only GitHub Releases are supported right now.
  • Checksums are checked.
  • Binares are installed using tar.gz or zip.
  • No OS-specific installs such as homebrew, deb, rpm. Everything is installed locally via a tar.gz or zip. Typically OS installs are done differently anyways (e.g. brew, apt-get, yum, etc).

Experimental support

Some people do not use Goreleaser (why!), so there is experimental support for the following alterative distributions.

"naked" releases on GitHub

A naked release is just the raw binary put on GitHub releases. Limited support can be done by

./goreleaser -source raw -repo [owner/repo] -exe [name] -nametpl [tpl]

Where exe is the final binary name, and tpl is the same type of name template that Goreleaser uses.

An example repo is at mvdan/sh. Note how the repo sh is different than the binary shfmt.

Equinox.io

Equinox.io is a really interesting platform. Take a look.

There is no API, so godownloader screen scrapes to figure out the latest release. Likewise, checksums are not verified.

./goreleaser -source equinoxio -repo [owner/repo]

While Equinox.io supports the concept of different release channels, only the stable channel is supported by godownloader.

Yes, it's true.

It's a go program that reads a YAML file that uses a template to make a posix shell script.

Other Resources and Inspiration

Other applications have written custom shell downloaders and installers:

golang/dep

The golang/dep package manager has a nice downloader, install.sh. Their trick to extract a version number from GitHub Releases is excellent:

$(echo "${LATEST_RELEASE}", tr -s '\n' ' ', sed 's/.*"tag_name":"//', sed 's/".*//' )

This is probably based on masterminds/glide and its installer at https://glide.sh/get

kubernetes/helm

kubernetes/helm is a "tool for managing Kubernetes charts. Charts are packages of pre-configured Kubernetes resources."

It has a get script. Of note is that it won't re-install if the desired version is already present.

chef

Chef has the one of the most complete installers at https://omnitruck.chef.io/install.sh. In particular it has support for

  • Support for solaris and aix, and some other less common platforms
  • python or perl as installers if curl or wget isn't present
  • http proxy support

Caddy

Caddy is "the HTTP/2 web server with automatic HTTPS" and a NGINX replacement. It has a clever installer at https://getcaddy.com. Of note is GPG signature verification.

主要指标

概览
名称与所有者goreleaser/godownloader
主编程语言Go
编程语言Go (语言数: 4)
平台
许可证MIT License
所有者活动
创建于2017-05-10 00:05:40
推送于2021-07-17 00:51:02
最后一次提交2021-07-16 17:50:29
发布数1
最新版本名称v0.1.0 (发布于 )
第一版名称v0.1.0 (发布于 )
用户参与
星数448
关注者数10
派生数54
提交数333
已启用问题?
问题数95
打开的问题数1
拉请求数68
打开的拉请求数0
关闭的拉请求数44
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?