gh-update is a Go package that provides functionality to update a Go application from a GitHub release.
To install gh-update, run the following command:
go get github.com/dhcgn/gh-update
The GetLatestVersion
function retrieves the latest release from a GitHub repository. It takes the following parameters:
name
(string): The name of the GitHub repository, e.g. "dhcgn/gh-update".version
(string): The current version of the application.assetfilter
(string): A regex to filter the assets of the release, e.g. "^myapp-.*windows.*zip$".
The function returns a LatestRelease
struct, which contains the name of the asset and the URL to download the asset.
The SelfUpdateAndRestart
function updates the current executable with the latest release from GitHub and restarts the application. It takes the following parameters:
latest
(LatestRelease): The result ofGetLatestVersion
.runningexepath
(string): The path to the currently running executable.
The SelfUpdateWithLatestAndRestart
function updates the current executable with the latest release from GitHub and restarts the application. It takes the following parameters:
name
(string): The name of the GitHub repository, e.g. "dhcgn/gh-update".version
(string): The current version of the application.assetfilter
(string): A regex to filter the assets of the release, e.g. "^myapp-.*windows.*zip$".runningexepath
(string): The path to the currently running executable.
This project is licensed under the MIT License.