Compare commits

...
3 Commits
Author SHA1 Message Date
Twyco dc9f400f34 fix(KAN-65): recover verified S3 writes from empty error responses
CI/CD / test_and_check_app (push) Successful in 6m31s
macOS release to Hetzner / Validate release ref and configuration (push) Successful in 21s
CI/CD / Publish immutable image (push) Successful in 1m18s
macOS release to Hetzner / Sign, notarize, verify and publish macOS (push) Failing after 4m57s
CI/CD / preconditions (push) Successful in 2s
macOS checks / Native Rust tests and unsigned build (push) Successful in 1m35s
Native JavaScript checks / Native launcher and release tests (push) Successful in 58s
2026-09-27 23:05:35 +02:00
Twyco 48f5fc410b Merge pull request 'KAN-65: Show the actual macOS build number in About and updates' (#160) from fix/KAN-65-about-build-number into main
CI/CD / preconditions (push) Canceled after 0s
CI/CD / test_and_check_app (push) Canceled after 0s
CI/CD / Publish immutable image (push) Canceled after 0s
Native JavaScript checks / Native launcher and release tests (push) Canceled after 0s
macOS checks / Native Rust tests and unsigned build (push) Canceled after 11s
macOS release to Hetzner / Validate release ref and configuration (push) Successful in 21s
macOS release to Hetzner / Sign, notarize, verify and publish macOS (push) Failing after 4m21s
Reviewed-on: #160
2026-09-27 20:49:33 +00:00
Twyco f6725ac025 fix(KAN-65): show the installed macOS build number
macOS checks / Native Rust tests and unsigned build (pull_request) Successful in 2m0s
CI/CD / preconditions (pull_request) Successful in 2s
Native JavaScript checks / Native launcher and release tests (pull_request) Successful in 58s
CI/CD / test_and_check_app (pull_request) Successful in 6m28s
CI/CD / Publish immutable image (pull_request) Skipped
2026-09-27 22:42:01 +02:00
11 changed files with 224 additions and 32 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "kanbangit-native", "name": "kanbangit-native",
"version": "0.1.2", "version": "0.1.4",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
@@ -24,5 +24,5 @@
"devDependencies": { "devDependencies": {
"@tauri-apps/cli": "2.11.4" "@tauri-apps/cli": "2.11.4"
}, },
"releaseNotes": "macOS updates can now be checked automatically or from the KanbanGit menu. Install releases from a drag-and-drop DMG. About KanbanGit shows the app version and build. Updates preserve your server settings and stored sessions and restart only after confirmation." "releaseNotes": "About KanbanGit and Software updates show the installed app build number correctly. Release publishing now handles Hetzner responses with empty error messages when updating the feed."
} }
+25 -9
View File
@@ -63,6 +63,14 @@ export function storageConfiguration(env = process.env) {
const sha256 = (data) => createHash('sha256').update(data).digest('hex'); const sha256 = (data) => createHash('sha256').update(data).digest('hex');
function requiresExistingObjectCheck(error) {
// AWS CLI can crash while formatting Hetzner's empty error Message.
// This only permits a readback; content checks and conditional writes still apply.
return /\(PreconditionFailed\)|\(412\)|argument of type 'NoneType' is not (?:a container or )?iterable/.test(
error.message,
);
}
export async function publishMacos({ export async function publishMacos({
env = process.env, env = process.env,
directory, directory,
@@ -116,13 +124,21 @@ export async function publishMacos({
's3api', 's3api',
]; ];
function s3(operation, args) { function s3(operation, args) {
return run('aws', [ try {
...common, return run('aws', [
operation, ...common,
'--bucket', operation,
storage.bucket, '--bucket',
...args, storage.bucket,
]); ...args,
]);
} catch (error) {
const keyIndex = args.indexOf('--key');
const key = keyIndex >= 0 ? ` ${args[keyIndex + 1]}` : '';
throw new Error(`S3 ${operation}${key}: ${error.message}`, {
cause: error,
});
}
} }
const versioningOutput = s3('get-bucket-versioning', [ const versioningOutput = s3('get-bucket-versioning', [
'--output', '--output',
@@ -213,7 +229,7 @@ export async function publishMacos({
`sha256=${sha256(contents)}`, `sha256=${sha256(contents)}`,
]); ]);
} catch (error) { } catch (error) {
if (!/\(PreconditionFailed\)|\(412\)/.test(error.message)) { if (!requiresExistingObjectCheck(error)) {
throw error; throw error;
} }
const existing = join(staging, `existing-${name}`); const existing = join(staging, `existing-${name}`);
@@ -301,7 +317,7 @@ export async function publishMacos({
try { try {
publishLatest(['--if-none-match', '*']); publishLatest(['--if-none-match', '*']);
} catch (error) { } catch (error) {
if (!/\(PreconditionFailed\)|\(412\)/.test(error.message)) { if (!requiresExistingObjectCheck(error)) {
throw error; throw error;
} }
const previousFile = join(staging, 'previous-latest.json'); const previousFile = join(staging, 'previous-latest.json');
+1 -1
View File
@@ -1770,7 +1770,7 @@ dependencies = [
[[package]] [[package]]
name = "kanbangit-native" name = "kanbangit-native"
version = "0.1.2" version = "0.1.4"
dependencies = [ dependencies = [
"semver", "semver",
"serde", "serde",
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "kanbangit-native" name = "kanbangit-native"
version = "0.1.2" version = "0.1.4"
description = "KanbanGit native application" description = "KanbanGit native application"
edition = "2021" edition = "2021"
publish = false publish = false
+23 -6
View File
@@ -285,6 +285,16 @@ pub fn context<R: tauri::Runtime>() -> tauri::Context<R> {
tauri::generate_context!() tauri::generate_context!()
} }
fn about_metadata(version: String) -> AboutMetadata<'static> {
AboutMetadata {
name: Some(en::APP_NAME.into()),
version: Some(version),
#[cfg(target_os = "macos")]
short_version: Some(crate::metadata::build_number().into()),
..Default::default()
}
}
pub fn builder() -> tauri::Builder<tauri::Wry> { pub fn builder() -> tauri::Builder<tauri::Wry> {
tauri::Builder::default().setup(|app| { tauri::Builder::default().setup(|app| {
let (server, phase) = match Server::load(&configuration_path(app.handle())?) { let (server, phase) = match Server::load(&configuration_path(app.handle())?) {
@@ -301,12 +311,7 @@ pub fn builder() -> tauri::Builder<tauri::Wry> {
&SubmenuBuilder::new(app, en::APP_NAME) &SubmenuBuilder::new(app, en::APP_NAME)
.about_with_text( .about_with_text(
en::ABOUT, en::ABOUT,
Some(AboutMetadata { Some(about_metadata(app.package_info().version.to_string())),
name: Some(en::APP_NAME.into()),
short_version: Some(app.package_info().version.to_string()),
version: app.config().bundle.macos.bundle_version.clone(),
..Default::default()
}),
) )
.text("check-updates", en::CHECK_UPDATES) .text("check-updates", en::CHECK_UPDATES)
.item(&MenuItem::with_id( .item(&MenuItem::with_id(
@@ -439,6 +444,18 @@ pub fn builder() -> tauri::Builder<tauri::Wry> {
mod tests { mod tests {
use super::*; use super::*;
#[cfg(target_os = "macos")]
#[test]
fn about_shows_app_version_followed_by_the_actual_build_number() {
let metadata = about_metadata("9.8.7".into());
assert_eq!(metadata.version.as_deref(), Some("9.8.7"));
assert_eq!(
metadata.short_version.as_deref(),
Some(crate::metadata::build_number())
);
assert_ne!(metadata.version, metadata.short_version);
}
#[test] #[test]
fn external_links_accept_only_web_urls_without_credentials() { fn external_links_accept_only_web_urls_without_credentials() {
for input in [ for input in [
+2
View File
@@ -6,6 +6,8 @@ mod desktop;
mod ios; mod ios;
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
mod locale; mod locale;
#[cfg(target_os = "macos")]
mod metadata;
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
mod server; mod server;
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
+69
View File
@@ -0,0 +1,69 @@
use std::{path::Path, sync::LazyLock};
fn build_from_executable(executable: &Path) -> Option<String> {
let macos = executable.parent()?;
let contents = macos.parent()?;
if macos.file_name()? != "MacOS" || contents.file_name()? != "Contents" {
return None;
}
let output = std::process::Command::new("/usr/bin/plutil")
.args(["-extract", "CFBundleVersion", "raw", "-o", "-"])
.arg(contents.join("Info.plist"))
.output()
.ok()?;
if !output.status.success() {
return Some("unknown".into());
}
let build = String::from_utf8(output.stdout).ok()?;
Some(build.trim().to_owned())
}
pub fn build_number() -> &'static str {
static BUILD: LazyLock<String> = LazyLock::new(|| {
std::env::current_exe()
.ok()
.and_then(|executable| build_from_executable(&executable))
.unwrap_or_else(|| {
// Tauri omits macOS bundle settings from its generated runtime config.
let config: serde_json::Value =
serde_json::from_str(include_str!("../tauri.conf.json")).unwrap();
config["bundle"]["macOS"]["bundleVersion"]
.as_str()
.unwrap_or("unknown")
.to_owned()
})
});
&BUILD
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn installed_build_comes_from_the_app_plist_instead_of_the_app_version() {
let root = std::env::temp_dir().join(format!("kanbangit-build-{}", std::process::id()));
let contents = root.join("KanbanGit.app/Contents");
std::fs::create_dir_all(contents.join("MacOS")).unwrap();
let executable = contents.join("MacOS/kanbangit-native");
std::fs::write(contents.join("Info.plist"), r#"<?xml version="1.0" encoding="UTF-8"?><plist version="1.0"><dict><key>CFBundleShortVersionString</key><string>0.1.3</string><key>CFBundleVersion</key><string>42</string></dict></plist>"#).unwrap();
assert_eq!(build_from_executable(&executable).as_deref(), Some("42"));
std::fs::remove_file(contents.join("Info.plist")).unwrap();
assert_eq!(
build_from_executable(&executable).as_deref(),
Some("unknown")
);
std::fs::remove_dir_all(root).unwrap();
}
#[test]
fn unbundled_execution_uses_the_configured_build() {
assert!(build_from_executable(Path::new("/tmp/target/debug/kanbangit-native")).is_none());
let config: serde_json::Value =
serde_json::from_str(include_str!("../tauri.conf.json")).unwrap();
assert_eq!(
build_number(),
config["bundle"]["macOS"]["bundleVersion"].as_str().unwrap()
);
}
}
+1 -7
View File
@@ -442,13 +442,7 @@ pub fn setup(app: &AppHandle) -> tauri::Result<()> {
view: View { view: View {
phase: if error.is_some() { "error" } else { "idle" }, phase: if error.is_some() { "error" } else { "idle" },
current_version: app.package_info().version.to_string(), current_version: app.package_info().version.to_string(),
build: app build: crate::metadata::build_number().into(),
.config()
.bundle
.macos
.bundle_version
.clone()
.unwrap_or_else(|| app.package_info().version.to_string()),
version: None, version: None,
notes: None, notes: None,
downloaded: 0, downloaded: 0,
+2 -2
View File
@@ -1,7 +1,7 @@
{ {
"$schema": "https://schema.tauri.app/config/2", "$schema": "https://schema.tauri.app/config/2",
"productName": "KanbanGit", "productName": "KanbanGit",
"version": "0.1.2", "version": "0.1.4",
"identifier": "de.kanbangit.desktop", "identifier": "de.kanbangit.desktop",
"build": { "build": {
"frontendDist": "../ui" "frontendDist": "../ui"
@@ -25,7 +25,7 @@
], ],
"macOS": { "macOS": {
"minimumSystemVersion": "14.0", "minimumSystemVersion": "14.0",
"bundleVersion": "2", "bundleVersion": "4",
"dmg": { "dmg": {
"windowSize": { "windowSize": {
"width": 660, "width": 660,
+10
View File
@@ -16,8 +16,16 @@ fn main() {
}; };
use tauri::webview::PageLoadEvent; use tauri::webview::PageLoadEvent;
let passed = Arc::new(AtomicBool::new(false)); let passed = Arc::new(AtomicBool::new(false));
let config: serde_json::Value =
serde_json::from_str(include_str!("../tauri.conf.json")).unwrap();
let expected_installed = format!(
"Installed version {} (build {})",
config["version"].as_str().unwrap(),
config["bundle"]["macOS"]["bundleVersion"].as_str().unwrap()
);
let plugin = tauri::plugin::Builder::<tauri::Wry>::new("updater-smoke") let plugin = tauri::plugin::Builder::<tauri::Wry>::new("updater-smoke")
.js_init_script(format!("window.expectedInstalled = {};", serde_json::to_string(&expected_installed).unwrap()))
.on_page_load(|window, payload| { .on_page_load(|window, payload| {
if window.label() != "updates" || payload.event() != PageLoadEvent::Finished { return; } if window.label() != "updates" || payload.event() != PageLoadEvent::Finished { return; }
window.eval(r#" window.eval(r#"
@@ -26,6 +34,8 @@ fn main() {
for (let i = 0; i < 100 && !window.updateStatus; i++) await new Promise(r => setTimeout(r, 50)); for (let i = 0; i < 100 && !window.updateStatus; i++) await new Promise(r => setTimeout(r, 50));
if (!window.updateStatus) throw new Error('Update UI did not load'); if (!window.updateStatus) throw new Error('Update UI did not load');
const $ = id => document.getElementById(id); const $ = id => document.getElementById(id);
for (let i = 0; i < 100 && !$('installed').textContent; i++) await new Promise(r => setTimeout(r, 50));
if ($('installed').textContent !== window.expectedInstalled) throw new Error('Actual installed version/build failed: ' + $('installed').textContent);
const state = { phase: 'current', currentVersion: '0.1.2', build: '2', version: null, notes: null, downloaded: 0, total: null, error: null, preferences: { automatic: true, intervalHours: 6 } }; const state = { phase: 'current', currentVersion: '0.1.2', build: '2', version: null, notes: null, downloaded: 0, total: null, error: null, preferences: { automatic: true, intervalHours: 6 } };
window.updateStatus(state); window.updateStatus(state);
if (!$('installed').textContent.includes('0.1.2 (build 2)') || !$('install').hidden || $('check').disabled) throw new Error('Current version state failed'); if (!$('installed').textContent.includes('0.1.2 (build 2)') || !$('install').hidden || $('check').disabled) throw new Error('Current version state failed');
+88 -4
View File
@@ -8,7 +8,10 @@ import test from 'node:test';
import { publishMacos, storageConfiguration } from '../publish-macos.mjs'; import { publishMacos, storageConfiguration } from '../publish-macos.mjs';
import { signedFixture } from './updater-fixture.mjs'; import { signedFixture } from './updater-fixture.mjs';
function fixture(t) { function fixture(
t,
conflictMessage = 'aws failed: (PreconditionFailed) object exists',
) {
const directory = mkdtempSync(join(tmpdir(), 'kanbangit-upload-test-')); const directory = mkdtempSync(join(tmpdir(), 'kanbangit-upload-test-'));
t.after(() => rmSync(directory, { recursive: true, force: true })); t.after(() => rmSync(directory, { recursive: true, force: true }));
const metadata = { const metadata = {
@@ -60,9 +63,7 @@ function fixture(t) {
} }
if (objects.has(key)) { if (objects.has(key)) {
if (!args.includes('--if-match')) { if (!args.includes('--if-match')) {
throw new Error( throw new Error(conflictMessage);
'aws failed: (PreconditionFailed) object exists',
);
} }
assert.equal(value('--if-match'), '"previous-etag"'); assert.equal(value('--if-match'), '"previous-etag"');
} }
@@ -427,3 +428,86 @@ test('concurrent feed replacement fails without overwriting the winner', async (
await assert.rejects(publishMacos(f), /concurrent publication/); await assert.rejects(publishMacos(f), /concurrent publication/);
assert.equal(JSON.parse(f.objects.get(key)).version, '2.0.0'); assert.equal(JSON.parse(f.objects.get(key)).version, '2.0.0');
}); });
for (const message of [
"aws failed (exit 255). aws: [ERROR]: argument of type 'NoneType' is not a container or iterable",
"aws failed (exit 255). argument of type 'NoneType' is not iterable",
]) {
test(`empty S3 error message permits verified promotion and identical retry: ${message}`, async (t) => {
const f = fixture(t, message);
const key = `releases/macos/${f.metadata.target}/latest.json`;
f.objects.set(key, Buffer.from(JSON.stringify({ version: '1.0.0' })));
await publishMacos(f);
assert.equal(JSON.parse(f.objects.get(key)).version, '1.2.3');
const published = [...f.objects.entries()];
await publishMacos(f);
assert.deepEqual([...f.objects.entries()], published);
});
test(`empty S3 error cannot bypass immutable content checks: ${message}`, async (t) => {
const f = fixture(t, message);
const key = `releases/macos/${f.metadata.target}/1.2.3/${f.metadata.filename}`;
f.objects.set(key, Buffer.from('different existing release'));
await assert.rejects(publishMacos(f), /bump the app version/);
assert.equal(f.objects.size, 1);
assert.equal(
f.objects.get(key).toString(),
'different existing release',
);
});
for (const previous of [
{ version: '2.0.0' },
{ version: '1.2.3', notes: 'different' },
]) {
test(`empty S3 error cannot bypass feed conflict checks ${previous.version}: ${message}`, async (t) => {
const f = fixture(t, message);
const key = `releases/macos/${f.metadata.target}/latest.json`;
const original = Buffer.from(JSON.stringify(previous));
f.objects.set(key, original);
await assert.rejects(publishMacos(f), /downgrade|differs/);
assert.deepEqual(f.objects.get(key), original);
});
}
test(`empty S3 error aborts when existing contents cannot be read: ${message}`, async (t) => {
const f = fixture(t, message);
const run = f.run;
f.run = (command, args) => {
if (args.includes('put-object')) {
throw new Error(message);
}
if (args.includes('get-object')) {
throw new Error('AccessDenied');
}
return run(command, args);
};
await assert.rejects(publishMacos(f), /S3 get-object .*AccessDenied/);
assert.equal(f.objects.size, 0);
});
test(`empty S3 error during conditional replacement preserves a concurrent winner: ${message}`, async (t) => {
const f = fixture(t, message);
const key = `releases/macos/${f.metadata.target}/latest.json`;
f.objects.set(key, Buffer.from(JSON.stringify({ version: '1.0.0' })));
const run = f.run;
let attempts = 0;
f.run = (command, args) => {
if (args.includes('--if-match')) {
attempts++;
f.objects.set(
key,
Buffer.from(JSON.stringify({ version: '2.0.0' })),
);
throw new Error(message);
}
return run(command, args);
};
await assert.rejects(
publishMacos(f),
/S3 put-object .*latest.json: .*NoneType/,
);
assert.equal(attempts, 1);
assert.equal(JSON.parse(f.objects.get(key)).version, '2.0.0');
});
}