Skip to content

Commit 425d988

Browse files
committed
fix(ci): Windows NSIS-only + fix cross-platform warnings
- Windows matrix entry changed from default (all targets) to `--bundles nsis`. MSI requires numeric-only pre-release identifiers (e.g. `5.0.0-7`), which conflicts with semver `5.0.0-beta.7`. NSIS (.exe) is the standard user-facing Windows installer; MSI can be added back for stable releases if needed. - Gate macOS-only items behind `#[cfg(target_os = "macos")]` so they don't produce dead_code warnings on Windows/Linux: - tray.rs: MENU_ID_TOGGLE_DOCK, refresh_menu - lifecycle.rs: apply_dock_icon_policy (whole function, not just the inner block) - Fix unused `mut` warnings on Windows: - tray.rs: menu_builder in build_menu (use `let` + cfg rebind) - app_menu.rs: builder in build_view_menu (same pattern)
1 parent 4094b2a commit 425d988

8 files changed

Lines changed: 31 additions & 31 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,13 @@ jobs:
6868
- platform: ubuntu-latest
6969
args: ''
7070
rust_targets: ''
71-
# Windows x64
71+
# Windows x64 — NSIS only; MSI requires numeric-only
72+
# pre-release identifiers (e.g. 5.0.0-7 ok, 5.0.0-beta.7 not)
73+
# which conflicts with semver conventions. NSIS is the standard
74+
# user-facing Windows installer; MSI can be added back for
75+
# stable releases if enterprise deployment needs it.
7276
- platform: windows-latest
73-
args: ''
77+
args: --bundles nsis
7478
rust_targets: ''
7579

7680
runs-on: ${{ matrix.platform }}

‎package-lock.json‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"private": true,
3-
"version": "5.0.0-beta.7",
3+
"version": "5.0.0-beta.8",
44
"scripts": {
55
"start": "cross-env NODE_ENV=development electron ./build/main.js",
66
"pretest": "rimraf ./test/tmp",

‎src-tauri/src/app_menu.rs‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,12 @@ fn build_edit_menu<R: Runtime>(app: &AppHandle<R>) -> Result<Submenu<R>, tauri::
145145
// ---- View ------------------------------------------------------------------
146146

147147
fn build_view_menu<R: Runtime>(app: &AppHandle<R>) -> Result<Submenu<R>, tauri::Error> {
148-
let mut builder = SubmenuBuilder::new(app, "View");
148+
let builder = SubmenuBuilder::new(app, "View");
149149

150-
// macOS keeps Reload + sep; Windows/Linux strips them (Electron
151-
// `template[2].submenu.splice(0, 4)` in the win32/linux branch).
152150
#[cfg(target_os = "macos")]
153-
{
154-
builder = builder
155-
.item(&PredefinedMenuItem::fullscreen(app, None)?)
156-
.separator();
157-
}
151+
let builder = builder
152+
.item(&PredefinedMenuItem::fullscreen(app, None)?)
153+
.separator();
158154

159155
builder
160156
.item(&PredefinedMenuItem::minimize(app, None)?)

‎src-tauri/src/lifecycle.rs‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -241,17 +241,15 @@ fn geometry_is_visible_on_monitors(monitors: &[Monitor], geom: &WindowGeometry)
241241
/// `Accessory` (no Dock icon, tray-only). Safe to call at runtime
242242
/// because P2.B installed a tray icon as a permanent way to summon
243243
/// the window back.
244-
pub fn apply_dock_icon_policy<R: Runtime>(_app: &AppHandle<R>, _hide: bool) {
245-
#[cfg(target_os = "macos")]
246-
{
247-
let policy = if _hide {
248-
tauri::ActivationPolicy::Accessory
249-
} else {
250-
tauri::ActivationPolicy::Regular
251-
};
252-
if let Err(e) = _app.set_activation_policy(policy) {
253-
log::warn!("failed to set activation policy: {e}");
254-
}
244+
#[cfg(target_os = "macos")]
245+
pub fn apply_dock_icon_policy<R: Runtime>(app: &AppHandle<R>, hide: bool) {
246+
let policy = if hide {
247+
tauri::ActivationPolicy::Accessory
248+
} else {
249+
tauri::ActivationPolicy::Regular
250+
};
251+
if let Err(e) = app.set_activation_policy(policy) {
252+
log::warn!("failed to set activation policy: {e}");
255253
}
256254
}
257255

‎src-tauri/src/tray.rs‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const TRAY_WINDOW_HEIGHT: f64 = 600.0;
3939

4040
pub const MENU_ID_SHOW_MAIN: &str = "tray-show-main";
4141
pub const MENU_ID_VERSION: &str = "tray-version";
42+
#[cfg(target_os = "macos")]
4243
pub const MENU_ID_TOGGLE_DOCK: &str = "tray-toggle-dock";
4344
pub const MENU_ID_QUIT: &str = "tray-quit";
4445

@@ -123,22 +124,22 @@ fn build_menu<R: Runtime>(app: &AppHandle<R>) -> Result<Menu<R>, tauri::Error> {
123124
.build(app)?;
124125
let quit = MenuItemBuilder::with_id(MENU_ID_QUIT, "Quit").build(app)?;
125126

126-
let mut menu_builder = MenuBuilder::new(app)
127+
let menu_builder = MenuBuilder::new(app)
127128
.item(&show_main)
128129
.item(&version)
129130
.separator();
130131

131132
#[cfg(target_os = "macos")]
132-
{
133+
let menu_builder = {
133134
let hide_dock = read_hide_dock_icon(app);
134135
let label = if hide_dock {
135136
"Show Dock Icon"
136137
} else {
137138
"Hide Dock Icon"
138139
};
139140
let toggle = MenuItemBuilder::with_id(MENU_ID_TOGGLE_DOCK, label).build(app)?;
140-
menu_builder = menu_builder.item(&toggle).separator();
141-
}
141+
menu_builder.item(&toggle).separator()
142+
};
142143

143144
menu_builder.item(&quit).build()
144145
}
@@ -216,7 +217,8 @@ fn toggle_dock_icon<R: Runtime>(app: &AppHandle<R>) {
216217

217218
/// Rebuild and reattach the tray menu. Cheap — only a few items.
218219
/// Called whenever an item label depends on config that just changed
219-
/// (currently just `hide_dock_icon`).
220+
/// (currently just `hide_dock_icon` on macOS).
221+
#[cfg(target_os = "macos")]
220222
pub fn refresh_menu<R: Runtime>(app: &AppHandle<R>) {
221223
let Some(tray) = app.tray_by_id(TRAY_ID) else {
222224
return;

‎src-tauri/tauri.conf.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://schema.tauri.app/config/2",
33
"productName": "SwitchHosts",
4-
"version": "5.0.0-beta.7",
4+
"version": "5.0.0-beta.8",
55
"identifier": "net.oldj.switchhosts",
66
"build": {
77
"beforeDevCommand": "npm run dev:renderer",

‎src/version.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"5.0.0-beta.7"
1+
"5.0.0-beta.8"

0 commit comments

Comments
 (0)