Provides a cobra command to allow your apps to self-update themselves by downloading the latest GitHub release.
-
Add the command to your Cobra app, passing in the owner/repo where new releases will be downloaded from:
import update "github.com/Shamus03/cobra-update" func init() { rootCmd.AddCommand(update.Command("Shamus03", "munn")) }
-
(optional) Make sure your root
*cobra.Command
has itsVersion
field set. This is the most simple example:var rootCmd = &cobra.Command { Use: "your-command", // other fields Version: "1.2.3", }
- Skipping this step will cause the update command to always download the latest release, even if the executable is already up to date.
- For a more complex example of setting the version through an automated workflow at build time, see munn's version file and semantic-release configuration.