Crates.io | upversion |
lib.rs | upversion |
version | 0.1.0 |
source | src |
created_at | 2022-07-24 19:44:18.952433 |
updated_at | 2022-07-24 19:44:18.952433 |
description | provides you to notify your clients when new version released |
homepage | https://github.com/rusty-ferris-club/upversion |
repository | https://github.com/rusty-ferris-club/upversion |
max_upload_size | |
id | 632168 |
size | 77,426 |
:label: keep your client up to date
:see_no_evil: Run in the background
:hourglass: Limit background task
upversion
provides you to notify your clients when new version released and show the latest download link.
$ ./test-tool
==> 🙆♂️ Newer <tool-name> version available: <user-version> (currently running: 0.5.2) | Link: <dynamic-link>
upversion
running as a background process which not affect your tool performance.
upversion
Add this to Cargo.toml:
[dependencies]
upversion = { version = "0.1" }
GitHub releases
Custom RestAPI
use anyhow::Result;
use upversion::vendors::GitHubVendor;
use upversion::CheckVersion;
fn main() -> Result<()> {
let github = Box::new(GitHubVendor::new("kaplanelad", "shellfirm"));
let timeout = 2; // in seconds
let version_context = CheckVersion::new("app-name", github, timeout)?;
// run command execute upversion check in the background and finish immediately.
version_context.run("0.0.1")?;
// sleep here simulator your program
std::thread::sleep(std::time::Duration::from_secs(3));
// at the end of your program, you can call printstd to print to the STDOUT a alert information for a new version which released
version_context.printstd();
Ok(())
}
If you manage your program version internally, you allow to serve the new version with your custom logic via rest API, and upversion
will query your endpoint.
use anyhow::Result;
use upversion::vendors::Api;
use upversion::CheckVersion;
fn main() -> Result<()> {
// server json response: { "version": "", "release_downloads": [] }
let api = Box::new(Api::new("http://127.0.0.1:3000"));
let timeout = 2; // in seconds
let version_context = CheckVersion::new("app-name", api, timeout)?;
// run command execute upversion check in the background and finish immediately.
version_context.run("0.0.1")?;
// sleep here simulator your program
std::thread::sleep(std::time::Duration::from_secs(3));
// at the end of your program, you can call printstd to print to the STDOUT a alert information for a new version which released
version_context.printstd();
Ok(())
}
You can find more example here, or run via cargo cargo run --example
Customize alert message with your owned template
const CUSTOM_TEMPLATE: &str = r#"==> [CUSTOM_TEMPLATE]:: 🙆♂️ Newer {{ app_name }} version available: {{ new_version }} (currently running: {{ current_version }}) {% if download_link %}| Link: {{ download_link }} {% endif %}"#;
...
version_context.printstd_with_template(CUSTOM_TEMPLATE);
To all Contributors - you make this happen, thanks!
Copyright (c) 2022 @kaplanelad. See LICENSE for further details.