18 releases (5 breaking)

new 0.6.4 May 14, 2024
0.6.3 May 14, 2024
0.5.1 Apr 16, 2024
0.4.1 Apr 10, 2024
0.1.0 Feb 29, 2024

#189 in Development tools

Download history 159/week @ 2024-02-26 350/week @ 2024-03-04 18/week @ 2024-03-11 708/week @ 2024-03-18 289/week @ 2024-03-25 721/week @ 2024-04-01 1157/week @ 2024-04-08 726/week @ 2024-04-15 578/week @ 2024-04-22 886/week @ 2024-04-29 1195/week @ 2024-05-06 2179/week @ 2024-05-13

4,871 downloads per month
Used in 3 crates

MIT/Apache

68KB
1.5K SLoC

axoupdater

axoupdater provides an autoupdater program designed for use with cargo-dist. It can be used either as a standalone program, or as a library within your own program. It supports releases hosted on either GitHub Releases or Axo Releases (in beta).

In order to be able to check information about an installed program, it uses the install receipts produced by cargo-dist since version 0.10.0 or later. These install receipts are JSON files containing metadata about the currently-installed version of an app and the version of cargo-dist that produced it; they can be found in ~/.config/APP_NAME (Linux, Mac) or %LOCALAPPDATA%\APP_NAME (Windows).

Standalone use

When built as a standalone commandline app, axoupdater does exactly one thing: check if the user is using the latest version of the software it's built for, and perform an update if not. Rather than being hardcoded for a specific application, the updater's filename is used to determine what app to update. For example, if axoupdater is installed under the filename axolotlsay-update, then it will try to fetch updates for the app named axolotlsay. This means you only need to build axoupdater once, and can deploy it for many apps without rebuilding.

In an upcoming release, cargo-dist will support generating and installing the updater for your users as an optional feature.

Library use

axoupdater can also be used as a library within your own applications in order to let you check for updates or perform an automatic update within your own apps. Here's a few examples of how that can be used.

To check for updates and notify the user:

if AxoUpdater::new_for("axolotlsay").load_receipt()?.is_update_needed_sync()? {
    eprintln!("axolotlsay is outdated; please upgrade!");
}

To automatically perform an update if the program isn't up to date:

if AxoUpdater::new_for("axolotlsay").load_receipt()?.run_sync()? {
    eprintln!("Update installed!");
} else {
    eprintln!("axolotlsay already up to date");
}

To use the blocking versions of the methods, make sure to enable the "blocking" feature on this dependency in your Cargo.toml. Asynchronous versions of is_update_needed() and run() are also provided:

if AxoUpdater::new_for("axolotlsay").load_receipt()?.run().await? {
    eprintln!("Update installed!");
} else {
    eprintln!("axolotlsay already up to date");
}

Crate features

By default, axoupdater is built with support for both GitHub and Axo releases. If you're using it as a library in your program, and you know ahead of time which backend you're using to host your release assets, you can disable the other library in order to reduce the size of the dependency tree.

Building

To build as a standalone binary, follow these steps:

  • Run cargo build --release
  • Rename target/release/axoupdater to APPNAME-update, where APPNAME is the name of the app you want it to upgrade.

License

Licensed under either of

at your option.

Dependencies

~5–37MB
~588K SLoC