From 6a3407796d4b1968a6aa896f0527f56aa2c84765 Mon Sep 17 00:00:00 2001 From: zhom <2717306+zhom@users.noreply.github.com> Date: Sat, 31 May 2025 11:07:59 +0400 Subject: [PATCH] chore: version bump and build update --- .github/workflows/rolling-release.yml | 1 + package.json | 2 +- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/Info.plist | 2 +- src-tauri/build.rs | 7 +++++-- src-tauri/src/app_auto_updater.rs | 21 +++++++++++++++++++-- src-tauri/tauri.conf.json | 2 +- 8 files changed, 30 insertions(+), 9 deletions(-) diff --git a/.github/workflows/rolling-release.yml b/.github/workflows/rolling-release.yml index 5e1eb2b..7b4526c 100644 --- a/.github/workflows/rolling-release.yml +++ b/.github/workflows/rolling-release.yml @@ -94,6 +94,7 @@ jobs: uses: tauri-apps/tauri-action@v0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BUILD_TAG: "nightly-${{ steps.commit.outputs.hash }}" GITHUB_REF_NAME: "nightly-${{ steps.commit.outputs.hash }}" GITHUB_SHA: ${{ github.sha }} with: diff --git a/package.json b/package.json index 07be8ff..c7a2882 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "donutbrowser", "private": true, - "version": "0.1.0", + "version": "0.2.0", "type": "module", "scripts": { "dev": "next dev --turbopack", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index ee711e8..f27afd8 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -973,7 +973,7 @@ dependencies = [ [[package]] name = "donutbrowser" -version = "0.1.0" +version = "0.2.0" dependencies = [ "async-trait", "base64 0.22.1", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 2cfc44b..a011ce0 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "donutbrowser" -version = "0.1.0" +version = "0.2.0" description = "A Tauri App" authors = ["zhom@github"] edition = "2021" diff --git a/src-tauri/Info.plist b/src-tauri/Info.plist index 11e1e46..a7aa57b 100644 --- a/src-tauri/Info.plist +++ b/src-tauri/Info.plist @@ -13,7 +13,7 @@ CFBundleVersion 1 CFBundleShortVersionString - 0.1.0 + 0.2.0 CFBundlePackageType APPL CFBundleIconFile diff --git a/src-tauri/build.rs b/src-tauri/build.rs index 7cd4041..6d82cf8 100644 --- a/src-tauri/build.rs +++ b/src-tauri/build.rs @@ -6,8 +6,11 @@ fn main() { } // Inject build version based on environment variables set by CI - if let Ok(tag_name) = std::env::var("GITHUB_REF_NAME") { - // This is set by GitHub Actions to the tag name (e.g., "v1.0.0" or "nightly-abc123") + if let Ok(build_tag) = std::env::var("BUILD_TAG") { + // Custom BUILD_TAG takes highest priority (used for nightly builds) + println!("cargo:rustc-env=BUILD_VERSION={build_tag}"); + } else if let Ok(tag_name) = std::env::var("GITHUB_REF_NAME") { + // This is set by GitHub Actions to the tag name (e.g., "v1.0.0") println!("cargo:rustc-env=BUILD_VERSION={tag_name}"); } else if std::env::var("STABLE_RELEASE").is_ok() { // Fallback for stable releases - use CARGO_PKG_VERSION with 'v' prefix diff --git a/src-tauri/src/app_auto_updater.rs b/src-tauri/src/app_auto_updater.rs index 77ecd6f..56415a4 100644 --- a/src-tauri/src/app_auto_updater.rs +++ b/src-tauri/src/app_auto_updater.rs @@ -47,8 +47,19 @@ impl AppAutoUpdater { /// Check if running a nightly build based on environment variable pub fn is_nightly_build() -> bool { // If STABLE_RELEASE env var is set at compile time, it's a stable build - // Otherwise, it's a nightly build - option_env!("STABLE_RELEASE").is_none() + if option_env!("STABLE_RELEASE").is_some() { + return false; + } + + // Also check if the current version starts with "nightly-" + let current_version = Self::get_current_version(); + if current_version.starts_with("nightly-") { + return true; + } + + // If STABLE_RELEASE is not set and version doesn't start with "nightly-", + // it's still considered a nightly build (dev builds, main branch builds, etc.) + true } /// Get current app version from build-time injection @@ -594,6 +605,10 @@ mod tests { // This will depend on whether STABLE_RELEASE is set during test compilation let is_nightly = AppAutoUpdater::is_nightly_build(); println!("Is nightly build: {is_nightly}"); + + // The result should be true for test builds since STABLE_RELEASE is not set + // unless the test is run in a stable release environment + assert!(is_nightly || option_env!("STABLE_RELEASE").is_some()); } #[test] @@ -672,6 +687,7 @@ mod tests { browser_download_url: "https://example.com/x64.dmg".to_string(), size: 12345, }, + AppReleaseAsset { name: "Donut.Browser_0.1.0_aarch64.dmg".to_string(), browser_download_url: "https://example.com/aarch64.dmg".to_string(), @@ -687,3 +703,4 @@ mod tests { assert!(url.contains(".dmg")); } } + diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index a14d29b..572b435 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "Donut Browser", - "version": "0.1.0", + "version": "0.2.0", "identifier": "com.donutbrowser", "build": { "beforeDevCommand": "pnpm dev",