mirror of https://github.com/encounter/objdiff.git
Bump to 2.0.0-alpha.1 & fix version checks
This commit is contained in:
parent
f5b5a612fc
commit
94f1f07b00
|
@ -3081,7 +3081,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objdiff-cli"
|
name = "objdiff-cli"
|
||||||
version = "0.1.0"
|
version = "2.0.0-alpha.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"argp",
|
"argp",
|
||||||
|
@ -3100,7 +3100,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objdiff-core"
|
name = "objdiff-core"
|
||||||
version = "1.0.0"
|
version = "2.0.0-alpha.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
|
@ -3127,7 +3127,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objdiff-gui"
|
name = "objdiff-gui"
|
||||||
version = "1.0.0"
|
version = "2.0.0-alpha.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "objdiff-cli"
|
name = "objdiff-cli"
|
||||||
version = "0.1.0"
|
version = "2.0.0-alpha.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.70"
|
rust-version = "1.70"
|
||||||
authors = ["Luke Street <luke@street.dev>"]
|
authors = ["Luke Street <luke@street.dev>"]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "objdiff-core"
|
name = "objdiff-core"
|
||||||
version = "1.0.0"
|
version = "2.0.0-alpha.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.70"
|
rust-version = "1.70"
|
||||||
authors = ["Luke Street <luke@street.dev>"]
|
authors = ["Luke Street <luke@street.dev>"]
|
||||||
|
|
|
@ -143,10 +143,11 @@ fn validate_min_version(config: &ProjectConfig) -> Result<()> {
|
||||||
let Some(min_version) = &config.min_version else { return Ok(()) };
|
let Some(min_version) = &config.min_version else { return Ok(()) };
|
||||||
let version = semver::Version::parse(env!("CARGO_PKG_VERSION"))
|
let version = semver::Version::parse(env!("CARGO_PKG_VERSION"))
|
||||||
.context("Failed to parse package version")?;
|
.context("Failed to parse package version")?;
|
||||||
match semver::VersionReq::parse(&format!(">={min_version}")) {
|
let min_version = semver::Version::parse(min_version).context("Failed to parse min_version")?;
|
||||||
Ok(version_req) if version_req.matches(&version) => Ok(()),
|
if version >= min_version {
|
||||||
Ok(_) => Err(anyhow!("Project requires objdiff version {min_version} or higher")),
|
Ok(())
|
||||||
Err(e) => Err(anyhow::Error::new(e).context("Failed to parse min_version")),
|
} else {
|
||||||
|
Err(anyhow!("Project requires objdiff version {min_version} or higher"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "objdiff-gui"
|
name = "objdiff-gui"
|
||||||
version = "1.0.0"
|
version = "2.0.0-alpha.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.70"
|
rust-version = "1.70"
|
||||||
authors = ["Luke Street <luke@street.dev>"]
|
authors = ["Luke Street <luke@street.dev>"]
|
||||||
|
|
|
@ -5,13 +5,13 @@ use self_update::{cargo_crate_version, update::Release};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
jobs::{start_job, update_status, Job, JobContext, JobResult, JobState},
|
jobs::{start_job, update_status, Job, JobContext, JobResult, JobState},
|
||||||
update::{build_updater, BIN_NAME},
|
update::{build_updater, BIN_NAME_NEW, BIN_NAME_OLD},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct CheckUpdateResult {
|
pub struct CheckUpdateResult {
|
||||||
pub update_available: bool,
|
pub update_available: bool,
|
||||||
pub latest_release: Release,
|
pub latest_release: Release,
|
||||||
pub found_binary: bool,
|
pub found_binary: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_check_update(context: &JobContext, cancel: Receiver<()>) -> Result<Box<CheckUpdateResult>> {
|
fn run_check_update(context: &JobContext, cancel: Receiver<()>) -> Result<Box<CheckUpdateResult>> {
|
||||||
|
@ -20,7 +20,13 @@ fn run_check_update(context: &JobContext, cancel: Receiver<()>) -> Result<Box<Ch
|
||||||
let latest_release = updater.get_latest_release()?;
|
let latest_release = updater.get_latest_release()?;
|
||||||
let update_available =
|
let update_available =
|
||||||
self_update::version::bump_is_greater(cargo_crate_version!(), &latest_release.version)?;
|
self_update::version::bump_is_greater(cargo_crate_version!(), &latest_release.version)?;
|
||||||
let found_binary = latest_release.assets.iter().any(|a| a.name == BIN_NAME);
|
// Find the binary name in the release assets
|
||||||
|
let found_binary = latest_release
|
||||||
|
.assets
|
||||||
|
.iter()
|
||||||
|
.find(|a| a.name == BIN_NAME_NEW)
|
||||||
|
.or_else(|| latest_release.assets.iter().find(|a| a.name == BIN_NAME_OLD))
|
||||||
|
.map(|a| a.name.clone());
|
||||||
|
|
||||||
update_status(context, "Complete".to_string(), 1, 1, &cancel)?;
|
update_status(context, "Complete".to_string(), 1, 1, &cancel)?;
|
||||||
Ok(Box::new(CheckUpdateResult { update_available, latest_release, found_binary }))
|
Ok(Box::new(CheckUpdateResult { update_available, latest_release, found_binary }))
|
||||||
|
|
|
@ -6,26 +6,29 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use const_format::formatcp;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
jobs::{start_job, update_status, Job, JobContext, JobResult, JobState},
|
jobs::{start_job, update_status, Job, JobContext, JobResult, JobState},
|
||||||
update::{build_updater, BIN_NAME},
|
update::build_updater,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct UpdateResult {
|
pub struct UpdateResult {
|
||||||
pub exe_path: PathBuf,
|
pub exe_path: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_update(status: &JobContext, cancel: Receiver<()>) -> Result<Box<UpdateResult>> {
|
fn run_update(
|
||||||
|
status: &JobContext,
|
||||||
|
cancel: Receiver<()>,
|
||||||
|
bin_name: String,
|
||||||
|
) -> Result<Box<UpdateResult>> {
|
||||||
update_status(status, "Fetching latest release".to_string(), 0, 3, &cancel)?;
|
update_status(status, "Fetching latest release".to_string(), 0, 3, &cancel)?;
|
||||||
let updater = build_updater().context("Failed to create release updater")?;
|
let updater = build_updater().context("Failed to create release updater")?;
|
||||||
let latest_release = updater.get_latest_release()?;
|
let latest_release = updater.get_latest_release()?;
|
||||||
let asset = latest_release
|
let asset = latest_release
|
||||||
.assets
|
.assets
|
||||||
.iter()
|
.iter()
|
||||||
.find(|a| a.name == BIN_NAME)
|
.find(|a| a.name == bin_name)
|
||||||
.ok_or_else(|| anyhow::Error::msg(formatcp!("No release asset for {}", BIN_NAME)))?;
|
.ok_or_else(|| anyhow::Error::msg(format!("No release asset for {bin_name}")))?;
|
||||||
|
|
||||||
update_status(status, "Downloading release".to_string(), 1, 3, &cancel)?;
|
update_status(status, "Downloading release".to_string(), 1, 3, &cancel)?;
|
||||||
let tmp_dir = tempfile::Builder::new().prefix("update").tempdir_in(current_dir()?)?;
|
let tmp_dir = tempfile::Builder::new().prefix("update").tempdir_in(current_dir()?)?;
|
||||||
|
@ -53,8 +56,8 @@ fn run_update(status: &JobContext, cancel: Receiver<()>) -> Result<Box<UpdateRes
|
||||||
Ok(Box::from(UpdateResult { exe_path: target_file }))
|
Ok(Box::from(UpdateResult { exe_path: target_file }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_update(ctx: &egui::Context) -> JobState {
|
pub fn start_update(ctx: &egui::Context, bin_name: String) -> JobState {
|
||||||
start_job(ctx, "Update app", Job::Update, move |context, cancel| {
|
start_job(ctx, "Update app", Job::Update, move |context, cancel| {
|
||||||
run_update(&context, cancel).map(JobResult::Update)
|
run_update(&context, cancel, bin_name).map(JobResult::Update)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,9 @@ cfg_if! {
|
||||||
}
|
}
|
||||||
pub const GITHUB_USER: &str = "encounter";
|
pub const GITHUB_USER: &str = "encounter";
|
||||||
pub const GITHUB_REPO: &str = "objdiff";
|
pub const GITHUB_REPO: &str = "objdiff";
|
||||||
pub const BIN_NAME: &str =
|
pub const BIN_NAME_NEW: &str =
|
||||||
formatcp!("{}-{}-{}{}", GITHUB_REPO, OS, ARCH, std::env::consts::EXE_SUFFIX);
|
formatcp!("objdiff-gui-{}-{}{}", OS, ARCH, std::env::consts::EXE_SUFFIX);
|
||||||
|
pub const BIN_NAME_OLD: &str = formatcp!("objdiff-{}-{}{}", OS, ARCH, std::env::consts::EXE_SUFFIX);
|
||||||
pub const RELEASE_URL: &str =
|
pub const RELEASE_URL: &str =
|
||||||
formatcp!("https://github.com/{}/{}/releases/latest", GITHUB_USER, GITHUB_REPO);
|
formatcp!("https://github.com/{}/{}/releases/latest", GITHUB_USER, GITHUB_REPO);
|
||||||
|
|
||||||
|
@ -29,7 +30,8 @@ pub fn build_updater() -> self_update::errors::Result<Box<dyn ReleaseUpdate>> {
|
||||||
self_update::backends::github::Update::configure()
|
self_update::backends::github::Update::configure()
|
||||||
.repo_owner(GITHUB_USER)
|
.repo_owner(GITHUB_USER)
|
||||||
.repo_name(GITHUB_REPO)
|
.repo_name(GITHUB_REPO)
|
||||||
.bin_name(BIN_NAME)
|
// bin_name is required, but unused?
|
||||||
|
.bin_name(BIN_NAME_NEW)
|
||||||
.no_confirm(true)
|
.no_confirm(true)
|
||||||
.show_output(false)
|
.show_output(false)
|
||||||
.current_version(cargo_crate_version!())
|
.current_version(cargo_crate_version!())
|
||||||
|
|
|
@ -41,7 +41,7 @@ pub struct ConfigViewState {
|
||||||
pub check_update_running: bool,
|
pub check_update_running: bool,
|
||||||
pub queue_check_update: bool,
|
pub queue_check_update: bool,
|
||||||
pub update_running: bool,
|
pub update_running: bool,
|
||||||
pub queue_update: bool,
|
pub queue_update: Option<String>,
|
||||||
pub build_running: bool,
|
pub build_running: bool,
|
||||||
pub queue_build: bool,
|
pub queue_build: bool,
|
||||||
pub watch_pattern_text: String,
|
pub watch_pattern_text: String,
|
||||||
|
@ -127,9 +127,8 @@ impl ConfigViewState {
|
||||||
jobs.push_once(Job::CheckUpdate, || start_check_update(ctx));
|
jobs.push_once(Job::CheckUpdate, || start_check_update(ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.queue_update {
|
if let Some(bin_name) = self.queue_update.take() {
|
||||||
self.queue_update = false;
|
jobs.push_once(Job::Update, || start_update(ctx, bin_name));
|
||||||
jobs.push_once(Job::Update, || start_update(ctx));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,15 +200,16 @@ pub fn config_ui(
|
||||||
if result.update_available {
|
if result.update_available {
|
||||||
ui.colored_label(appearance.insert_color, "Update available");
|
ui.colored_label(appearance.insert_color, "Update available");
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
if result.found_binary
|
if let Some(bin_name) = &result.found_binary {
|
||||||
&& ui
|
if ui
|
||||||
.add_enabled(!state.update_running, egui::Button::new("Automatic"))
|
.add_enabled(!state.update_running, egui::Button::new("Automatic"))
|
||||||
.on_hover_text_at_pointer(
|
.on_hover_text_at_pointer(
|
||||||
"Automatically download and replace the current build",
|
"Automatically download and replace the current build",
|
||||||
)
|
)
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
state.queue_update = true;
|
state.queue_update = Some(bin_name.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ui
|
if ui
|
||||||
.button("Manual")
|
.button("Manual")
|
||||||
|
|
Loading…
Reference in New Issue