updater

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package updater provides functionality to automatically update a Go application by checking for the latest release on GitHub and, if available, downloading and applying the update. It is designed to work with applications that are distributed with GitHub releases.

The updater checks the latest release by calling the GitHub Releases API and compares the tag name of the latest release with the current version of the application. If the tag name indicates a newer version, the updater downloads the release asset that matches the running application's operating system and architecture, replaces the current executable, and restarts the application.

Usage:

To use the updater, you should include it in your application's main package:

import "github.com/H0llyW00dzZ/ChatGPT-Next-Web-Session-Exporter/updater"

func main() {
    if err := updater.UpdateApplication(); err != nil {
        // Handle error
    }
    // Continue with application logic
}

The updater assumes that the GitHub repository's release assets follow a naming convention that includes the OS and architecture. It also assumes that the binary to be updated is named "myapp" and is located in the current working directory of the running application.

Note that the updater package defines a constant `currentVersion` that must be updated to match the application's current version string before building a new release. This version string is used to compare against the tag name of the latest release on GitHub.

The updater package is designed with simplicity in mind and does not handle complex update scenarios such as database migrations, configuration changes, or rollback of failed updates. It is recommended to test the update process thoroughly in a controlled environment before deploying it in a production setting.

Security Considerations:

The updater performs a direct binary replacement and restarts the application. Users should ensure that the GitHub repository and release assets are secure and that the release process includes steps to verify the integrity and authenticity of the binaries, such as signing the releases.

Additional Note: This Package Currently under development.

Copyright (c) 2023 H0llyW00dzZ

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UpdateApplication

func UpdateApplication(rfs filesystem.FileSystem) error

UpdateApplication checks the GitHub repository for a newer release of the application. If a newer release is found, it downloads the corresponding binary for the current platform and architecture, replaces the current executable with the downloaded binary, and restarts the application.

Returns nil if the application is up to date or the update is successfully applied. If an error occurs during the update process, it returns a non-nil error.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL