Git Product home page Git Product logo

go-rocket-update's Introduction

go-rocket-update: Build self-updating Go programs

Build Status codecov Go Report Card Go Reference Mentioned in Awesome Go

Enable your Golang applications to easily and safely to self update.

Here is the list of projects using this package.

It provides the flexibility to implement different updating user experiences like auto-updating, or manual user-initiated updates, and updates from different sources.

Go rocket image The gopher in this image was created by Takuya Ueda, licensed under Creative Commons 3.0 Attributions license.

Features

  • Flexible way to provide updates (ex: using Github or Gitlab!)
  • Cross platform support (Mac, Linux, Arm, and Windows)
  • RSA signature verification
  • Tooling to generate and verify signatures
  • Background update
  • Rollback feature

QuickStart

Install library

go get -u github.com/mouuff/go-rocket-update/...

Enable your App to Self Update

Here is an example using Github releases:

u := &updater.Updater{
	Provider: &provider.Github{
		RepositoryURL: "github.com/mouuff/go-rocket-update-example",
		ArchiveName:   fmt.Sprintf("binaries_%s.zip", runtime.GOOS),
	},
	ExecutableName: fmt.Sprintf("go-rocket-update-example_%s_%s", runtime.GOOS, runtime.GOARCH),
	Version:        "v0.0.1",
}

if _, err := u.Update(); err != nil {
	log.Println(err)
}

For more examples, please take a look at some code samples and this example project.

Push an update

The updater uses a Provider as an input source for updates. It provides files and version for the updater.

Here is few examples of providers:

  • provider.Github: It will check for the latest release on Github with a specific archive name (zip or tar.gz)
  • provider.Gitlab: It will check for the latest release on Gitlab with a specific archive name (zip or tar.gz)
  • provider.Local: It will use a local folder, version will be defined in the VERSION file (can be used for testing, or in a company with a shared folder for example)
  • provider.Zip: It will use a zip file. The version is defined by the file name (Example: binaries-v1.0.0.tar.gz). Use GlobNewestFile to find the right file.
  • provider.Gzip: Same as provider.Zip but with a tar.gz file.

The updater will list the files and retrieve them the same way for all the providers:

The directory should have files containing ExecutableName.

Example directory content with ExecutableName: fmt.Sprintf("test_%s_%s", runtime.GOOS, runtime.GOARCH):

test_windows_amd64.exe
test_darwin_amd64
test_linux_arm

We recommend using goxc for compiling your Go application for multiple platforms.

Planned features

This project is currently under construction, here is some of the things to come:

  • More documentation and examples
  • Variable templating
  • Mutliple providers (enables the use of another provider if the first one is down)
  • Update channels for Github provider (alpha, beta, ...)
  • Validation of the executable being installed

API Breaking Changes

  • Aug 1, 2021: Major: The UpdateHook variable used in Updater have been replaced with PostUpdateFunc and the Updater will no longer call Rollback() automatically if the PostUpdateFunc returns an error.

go-rocket-update's People

Contributors

mouuff avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.