https://github.com/rusty-ferris-club/upversion
notify your clients when new version release and show the latest download link
https://github.com/rusty-ferris-club/upversion
Last synced: 3 months ago
JSON representation
notify your clients when new version release and show the latest download link
- Host: GitHub
- URL: https://github.com/rusty-ferris-club/upversion
- Owner: rusty-ferris-club
- License: apache-2.0
- Created: 2022-07-02T12:39:23.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-24T19:54:57.000Z (about 3 years ago)
- Last Synced: 2025-04-30T19:41:43.926Z (6 months ago)
- Language: Rust
- Homepage:
- Size: 59.6 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[](https://github.com/rusty-ferris-club/upversion/actions/workflows/ci.yml)
:label: keep your client up to date
:see_no_evil: Run in the background
:hourglass: Limit background task
# upversion
`upversion` provides you to notify your clients when new version released and show the latest download link.
```sh
$ ./test-tool
==> 🙆♂️ Newer version available: (currently running: 0.5.2) | Link:
```## How it works
`upversion` running as a background process which not affect your tool performance.
1. you can choose when present the newer version
2. you can skip message notification if your proccess finished before `upversion`## Usage
Add this to Cargo.toml:
```toml
[dependencies]
upversion = { version = "0.1" }
```## Vendor
* GitHub releases
* Custom RestAPI## Github Example:
```rs
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(())
}
```## Custom API:
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.
```rs
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(())
}
```### More example
You can find more example [here](./examples/), or run via cargo `cargo run --example`## Customize Template
Customize alert message with your owned template
```rs
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);
```# Thanks
To all [Contributors](https://github.com/rusty-ferris-club/upversion/graphs/contributors) - you make this happen, thanks!# Copyright
Copyright (c) 2022 [@kaplanelad](https://github.com/kaplanelad). See [LICENSE](LICENSE.txt) for further details.