Enable your Go applications to self update

Overview

go-selfupdate

GoDoc Build Status

Enable your Golang applications to self update. Inspired by Chrome based on Heroku's hk.

Features

  • Tested on Mac, Linux, Arm, and Windows
  • Creates binary diffs with bsdiff allowing small incremental updates
  • Falls back to full binary update if diff fails to match SHA

QuickStart

Install library and update/patch creation utility

go get -u github.com/sanbornm/go-selfupdate/...

Enable your App to Self Update

var updater = &selfupdate.Updater{
	CurrentVersion: version,
	ApiURL:         "http://updates.yourdomain.com/",
	BinURL:         "http://updates.yourdomain.com/",
	DiffURL:        "http://updates.yourdomain.com/",
	Dir:            "update/",
	CmdName:        "myapp", // app name
}

if updater != nil {
	go updater.BackgroundRun()
}

Push Out and Update

go-selfupdate myapp 1.2

This will create a folder in your project called, public you can then rsync or transfer this to your webserver or S3.

If you are cross compiling you can specify a directory:

go-selfupdate /tmp/mybinares/ 1.2

The directory should contain files with the name, $GOOS-$ARCH. Example:

windows-386
darwin-amd64
linux-arm

If you are using goxc you can output the files with this naming format by specifying this config:

"OutPath": "{{.Dest}}{{.PS}}{{.Version}}{{.PS}}{{.Os}}-{{.Arch}}",
Comments
  • Does it still work?

    Does it still work?

    Hi,

    Does this module still work? I'm kind of new to GO but no idea if i'm doing something wrong or module doesn't work anymore, i'm using your exact code from readme and i'm getting:

    $ go run test.go
    # github.com/sanbornm/go-selfupdate/selfupdate
    ../../../github.com/sanbornm/go-selfupdate/selfupdate/selfupdate.go:79: undefined: update.SanityCheck
    ../../../github.com/sanbornm/go-selfupdate/selfupdate/selfupdate.go:144: undefined: update.FromStream
    
    opened by krzysztofantczak 6
  • Doesn't work, how do I debug?

    Doesn't work, how do I debug?

    I have an application that I crosscompile and upload to a folder on a server. The structure when uploaded is:

    archive/online-cli/
    |   online-cli.darwin-amd64.json
    |   online-cli.linux-amd64.json
    |   windows-amd64.json
    |
    +---17
    |       online-cli.darwin-amd64.gz
    |       online-cli.linux-amd64.gz
    |       online-cli.windows-amd64.gz
    |
    \---18
            online-cli.darwin-amd64.gz
            online-cli.linux-amd64.gz
            windows-amd64.gz
    

    My code for updating is this:

    func main() {
        updater := &selfupdate.Updater{
            CurrentVersion: version,
            ApiURL:         "http://updates.mysite.com/",
            BinURL:         "http://updates.mysite.com/",
            DiffURL:        "http://updates.mysite.com/",
            Dir:            "archive/online-cli/",
            CmdName:        appname, // app name
            Requester:      mr,
        }
    
        if updater != nil {
    
            log.Info("Checking for new versions...")
            err := updater.ForegroundRun()
            if err != nil {
                log.Fatal(err.Error())
            }
        }
    ...
    

    However this will not update, and it does not give an error either. I have tested the urls and the files are reachable. How would I move on to debug this issue? Is there something I've missed?

    opened by andrejohansson 3
  • ARM Build Output

    ARM Build Output

    Hi

    I'm including the update feature in a golang app targeted for ARM. I'm cross compiling from the latest stable Ubuntu.

    When I run: go-selfupdate {appname} {version} -platform="linux-arm"

    The output .json file in public is "linux-amd64.json" should this not be "linux-arm.json"?

    Am I setting an incorrect flag?

    opened by gibsonsyd 3
  • default platform value

    default platform value

    If I understand what you want to do this is incorrect:

    plat = os.Getenv("GOOS") + "-" + os.Getenv("GOARCH")

    runtime.GOOS and runtime.GOARCH should be used instead(?)

    My reason for asking is that I am adding more command line options (using flags) and I stumbled upon this inconsistency.

    This is the work so far.. It's mostly done and compatible with the the current way arguments are handed:

    https://github.com/thomasf/go-selfupdate/compare/sanbornm:master...master

    opened by thomasf 3
  • Update to use go mod and parameterize check time and randomize time

    Update to use go mod and parameterize check time and randomize time

    The following PR is intended to:

    • Update the project to use go mod
    • Expose previously private functions to be public, to allow for more granular usage
    • Add CheckTime and RandomizeTime parameters, giving implementor ability to specify update times

    I left ForceUpdate, even though you could use CheckTime=0 and RandomizeTime=0 since there may be use-cases where you may want to have both.

    opened by kyle-williams-1 2
  • Update to allow developers to customize the fetching of the update

    Update to allow developers to customize the fetching of the update

    information, diffs and binaries

    The specific issue my team is hitting is occurring is io timeouts are happening in http requests. Ideally I'd like a way to be able control the http requests, perhaps to add some code to do an exponential backoff and additional requests. I was going to actually add that into this change, but decided it was best just to have a hook. People may want to do a number of things. Perhaps connect to an endpoint with a cert as another example. I added some basic tests. I can't quite add testing for everything as the osext picks the exe up. Though I though I could at least add some tests as a starting point. Further refactoring can make this easier to test.

    opened by ChrisPRobinson 2
  • how to self-update mac apps with .app structure

    how to self-update mac apps with .app structure

    My go app is a CGO compiled Mac OS X application with a typical .app folder, which contains the binary, resource files, frameworks and more. Can I use go-selfupdate for that ?

    opened by rsaccon 2
  • Command go-selfupdate does not work

    Command go-selfupdate does not work

    Hi, how are you?

    I am trying to execute the command however, I do not know which folder should I run. I am in my gopath but the answer is that the command does not exist, help me please

    opened by margem 1
  • update does not works if app is in at an un-writable location

    update does not works if app is in at an un-writable location

    If the app is located for eg. in /usr/local/bin then update does not works if executing update as a normal user, this is fine because thats expected that if app is for eg. "root" controlled then it should not be updateable by any random user, but the problems is that update does not gives you an error, that it failed to update rather it returns success.

    opened by sushilkm 1
  • Example demonstrating how go-selfupdate works

    Example demonstrating how go-selfupdate works

    It took me a bit of playing to figure out how to use go-selfupdate, so I figured I'd share what I learned through an example. To run, just cd into the example directory and execute the run-example.sh script. The example leaves its files behind so the user can explore the public directory, etc.

    Code is donated to the go-selfupdate project with the same license that project uses.

    opened by deinspanjer 1
  • Add query escaping to the URLs built for updates

    Add query escaping to the URLs built for updates

    In semver, a + is a valid character, but in a URL that means 'space'.

    The URL's path should have all of its components properly URL escaped to resolve this issue.

    opened by robdaemon 1
  • add CPU-level parallelism for computing binary diffs

    add CPU-level parallelism for computing binary diffs

    I did some rudimentary testing of this --- used it on different versions of a Go executable I'm familiar with, verified that nothing crashed, that the expected files were produced, and that the expected level of parallelism was achieved. Let me know if you want me to do further testing.

    Thanks for this project! I was resistant to the idea at first but it works great. #13 was very useful.

    opened by slingamn 0
  • Support for DMG files (macOS)

    Support for DMG files (macOS)

    It is not mystery that each release of macOS has increased the default level of security. The latest one won't even run any binaries that is not notarized.

    Since notarization only works with .dmg files, it'll be great if go-selfupdate supports this format just like electron builder updates.

    Note :: A binary can be signed as .zip file or notarized + stapled as .dmg

    Although .dmg is ideal, support for .zip should also do that trick.

    opened by devinstasafe 0
  • Fix: resolve symlinks for bin filepaths

    Fix: resolve symlinks for bin filepaths

    If you run your commands from a symlink, we need to resolve the full symlink path, otherwise we'll just end up replacing the symlink itself and not the binary it was linking to.

    opened by josephschmitt 0
  • Fix Tests + Gomock

    Fix Tests + Gomock

    When checking out this module I noticed some failing test. Inspired by https://github.com/sanbornm/go-selfupdate/pull/32 I switched the Requester to be mocked by gomock and made the tests platform agnostic. Also tested on linux-arm64.

    opened by segfault16 0
Owner
Mark
Mark
Automatic-Update-Launcher - A general purpose updater for updating program binaries when update folder exists

Automatic Update Launcher A general purpose updater for updating (web) applicati

Toby Chui 4 Jun 27, 2022
Enable dynamic and seamless Kubernetes multi-cluster topologies

Enable dynamic and seamless Kubernetes multi-cluster topologies Explore the docs » View Demo · Report Bug · Request Feature About the project Liqo is

LiqoTech 697 Sep 21, 2022
Moby: an open-source project created by Docker to enable and accelerate software containerization

The Moby Project Moby is an open-source project created by Docker to enable and accelerate software containerization. It provides a "Lego set" of tool

null 0 Dec 10, 2021
Puccini-terraform - Enable TOSCA for Terraform using Puccini

(work in progress) TOSCA for Terraform Enable TOSCA for Terraform using Puccini.

Tal Liron 3 Jun 27, 2022
A reverse engineered github actions compatible self-hosted runner using nektos/act to execute your workflow steps

github-act-runner A reverse engineered github actions compatible self-hosted runner using nektos/act to execute your workflow steps. Unlike the offici

null 90 Sep 6, 2022
Triggers an update to a Koyeb app service to re-deploy the latest docker image

Triggers an update to a Koyeb app service to re-deploy the latest docker image

Reece May 3 May 5, 2021
Aws asg updater - Update AMIs within AWS Auto Scaling groups automatically.

AWS Auto Scaling Groups Updater AWS Auto Scaling group is a great way of managing Amazon EC2 instances. AWS Auto Scaling group watches the correspondi

Alexey Shagraev 1 Jan 6, 2022
🛅 Backup your Kubernetes Stateful Applications

Stash Stash by AppsCode is a cloud-native data backup and recovery solution for Kubernetes workloads. If you are running production workloads in Kuber

Stash by AppsCode 1.1k Sep 22, 2022
Easily deploy your Go applications with Dokku.

dokku-go-example Easily deploy your Go applications with Dokku. Features: Deploy on your own server Auto deployment HTTPS Check the full step by step

null 10 Aug 21, 2022
Cmsnr - cmsnr (pronounced "commissioner") is a lightweight framework for running OPA in a sidecar alongside your applications in Kubernetes.

cmsnr Description cmsnr (pronounced "commissioner") is a lightweight framework for running OPA in a sidecar alongside your applications in Kubernetes.

John Hooks 4 Jan 13, 2022
Monitor your Website and APIs from your Computer. Get Notified through Slack, E-mail when your server is down or response time is more than expected.

StatusOK Monitor your Website and APIs from your computer.Get notified through Slack or E-mail when your server is down or response time is more than

Sanath Kumar 1.6k Sep 21, 2022
Git with a cup of tea, painless self-hosted git service

Gitea - Git with a cup of tea View the chinese version of this document Purpose The goal of this project is to make the easiest, fastest, and most pai

Gitea 32.4k Sep 25, 2022
LinkPage is a FOSS self-hosted alternative to link listing websites such as LinkTree and Campsite.bio

LinkPage LinkPage is a FOSS self-hosted alternative to link listing websites such as LinkTree and Campsite.bio Features Self hostable and open source

Rohan Verma 50 Sep 20, 2022
Hermit manages isolated, self-bootstrapping sets of tools in software projects.

Hermit - uniform tooling for Linux and Mac Hermit installs tools for software projects in self-contained, isolated sets, so your team, your contributo

Cash App 359 Sep 16, 2022
Developer Self-Service Across Clusters

Monoskope (m8) Monoskope (short m8 spelled "mate") implements the management and operation of tenants, users and their roles in a Kubernetes multi-clu

finleap connect 6 Jul 6, 2022
Kubernetes operator for the Azure DevOps self-hosted pipe-line agent.

Kubernetes operator for the Azure DevOps self-hosted pipe-line agent. The operator adds an extra layer of configuration on top of the default images like: proxy settings, pool settings and auth keys.

Bart 0 Sep 1, 2022
A tiny self-contained pasting service with a built-in database.

A tiny self-contained pasting service with a built-in database.

SWZ 2 Dec 18, 2021
self-made curl because windows doesn't have one 😡

Go-Curl Basic Feature of Curl made on go Installation go mod tidy then go build . Usage go-curl get "https://jsonplaceholder.typicode.com/posts/1" -b=

Akbar H. P. S. 0 Dec 12, 2021
Manages nodes in hybrid k8s self-hosted cluster

node-manager Manages nodes in hybrid k8s self-hosted cluster Supported providers Contabo Hetzner Robot (dedicated) Supported commands Heal - reboots a

webtor.io 0 Dec 23, 2021