diff --git a/.github/workflows/nightly-dispatch.yml b/.github/workflows/nightly-dispatch.yml deleted file mode 100644 index a9dc25174..000000000 --- a/.github/workflows/nightly-dispatch.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: Dispatch release-ref nightly - -# Transport only, never authorization. No checkout, payload parsing or release environment. -on: - workflow_run: - workflows: [CADCraft unsigned nightly] - types: [completed] - branches: [main] - -permissions: {} - -jobs: - dispatch: - # SOURCE PREPARATION: literal off until immutable shared tooling and policy qualification. - if: >- - false && github.repository == 'storytold/cadcraft' && - github.event_name == 'workflow_run' - runs-on: ubuntu-latest - timeout-minutes: 5 - permissions: - actions: write - steps: - - name: Dispatch only the exact completed producer run and attempt - shell: python - env: - GH_TOKEN: ${{ github.token }} - run: | - import json - import os - import urllib.request - - def require(value, message): - if not value: - raise RuntimeError(message) - - # These filters reduce noise; the protected release validator repeats admission - # against authenticated API metadata and required attestation/quality evidence. - require(os.environ.get('GITHUB_REPOSITORY') == 'storytold/cadcraft', 'wrong repository') - require(os.environ.get('GITHUB_EVENT_NAME') == 'workflow_run', 'wrong event') - with open(os.environ['GITHUB_EVENT_PATH'], encoding='utf-8') as stream: - event = json.load(stream) - require(event.get('action') == 'completed', 'producer is not complete') - require(event.get('repository', {}).get('full_name') == 'storytold/cadcraft', 'wrong event repository') - producer = event.get('workflow_run', {}) - require(producer.get('head_repository', {}).get('full_name') == 'storytold/cadcraft', 'foreign producer') - require(producer.get('path') == '.github/workflows/nightly.yml', 'wrong producer path') - require(producer.get('head_branch') == 'main', 'wrong producer branch') - require(producer.get('status') == 'completed' and producer.get('conclusion') == 'success', 'producer did not succeed') - # First scheduled attempt only; reviewed manual/re-run authority belongs to release policy. - require(producer.get('event') == 'schedule', 'not an automatic scheduled producer') - run_id, attempt = producer.get('id'), producer.get('run_attempt') - require(type(run_id) is int and run_id > 0, 'invalid producer run id') - require(type(attempt) is int and attempt == 1, 'invalid automatic producer attempt') - body = json.dumps({'ref': 'release', 'inputs': { - 'producer_run_id': str(run_id), 'producer_run_attempt': str(attempt) - }}).encode('utf-8') - request = urllib.request.Request( - 'https://api.github.com/repos/storytold/cadcraft/actions/workflows/nightly-sign.yml/dispatches', - data=body, method='POST', headers={ - 'Authorization': 'Bearer ' + os.environ['GH_TOKEN'], - 'Accept': 'application/vnd.github+json', - 'Content-Type': 'application/json', - 'X-GitHub-Api-Version': '2022-11-28', - 'User-Agent': 'cadcraft-nightly-dispatch' - }) - class NoRedirect(urllib.request.HTTPRedirectHandler): - def redirect_request(self, req, fp, code, msg, headers, newurl): - raise RuntimeError('dispatch redirects are forbidden') - # One bounded request, no retry: duplicate transport is not publication authority. - with urllib.request.build_opener(NoRedirect()).open(request, timeout=20) as response: - require(response.status == 204, 'dispatch was not accepted') - print('Dispatched producer run/attempt to the release-ref validator; not a signing result.') diff --git a/.github/workflows/packaging-lint.yml b/.github/workflows/packaging-lint.yml index 4a8cf040c..6f2ef7374 100644 --- a/.github/workflows/packaging-lint.yml +++ b/.github/workflows/packaging-lint.yml @@ -75,3 +75,5 @@ jobs: packaging/macos/nightly.sh packaging/macos/nightly-lib.sh packaging/macos/nightly-sign.sh packaging/macos/nightly-verify.sh - name: Enforce the nightly serialization and synthetic packaging contracts run: python3 packaging/nightly-tests.py + - name: Render the Arch Nightly handoff from stub binaries + run: bash packaging/linux/nightly-arch-tar-test.sh diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index b016d7ebb..3e9c7b306 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -45,6 +45,12 @@ Generated-in-code assets are original and have no file to list: | `assets/app-icon/cadcraft-256.png` | CADCraft contributors | generated | MIT OR Apache-2.0 | | | `assets/app-icon/cadcraft-1024.png` | CADCraft contributors | generated | MIT OR Apache-2.0 | | | `assets/app-icon/cadcraft-macos-512.png` | CADCraft contributors | generated (macOS margin variant) | MIT OR Apache-2.0 | | +| `assets/app-icon/README.md` | CADCraft contributors | original work for this repository | MIT OR Apache-2.0 | How each icon is generated and which mark each channel uses | +| `assets/app-icon/cadcraft-nightly.png` | CADCraft contributors | generated from `assets/app-icon/cadcraft-1024.png` | MIT OR Apache-2.0 | Nightly mark: same glyph, deeper background `#0c657b`; the Linux nightly tar's icon | +| `assets/app-icon/cadcraft-nightly-1024.png` | CADCraft contributors | generated from `assets/app-icon/cadcraft-1024.png` | MIT OR Apache-2.0 | 1024 master the nightly `.icns` is generated from | +| `assets/app-icon/cadcraft-nightly.ico` | CADCraft contributors | generated from `assets/app-icon/cadcraft-nightly-1024.png` | MIT OR Apache-2.0 | Windows nightly icon (16–256 px entries) for `build.rs` | +| `assets/app-icon/cadcraft-nightly.icns` | CADCraft contributors | generated from `assets/app-icon/cadcraft-nightly-1024.png` | MIT OR Apache-2.0 | macOS nightly bundle icon (`CFBundleIconFile cadcraft-nightly`) | +| `assets/app-icon/nightly-provenance.json` | CADCraft contributors | original work for this repository | MIT OR Apache-2.0 | The exact background transform that produced the nightly set | | `packaging/macos/dmg/background.svg` | @XusBadia | original work for this repository (2026-10-08), "CADCraft macOS DMG window background"; derived from the CADCraft app icon (`assets/app-icon/`, referenced via ``, not copied); text is outlined Inter / JetBrains Mono glyph paths (OFL fonts the project already uses); no third-party material modified | MIT OR Apache-2.0 (same as the code: `LICENSE-MIT`, `LICENSE-APACHE`) | Finder window background of the macOS DMG; `packaging/macos/dmg/generate.py` renders it to `background.tiff` (see `packaging/macos/dmg/README.md`) | | `packaging/macos/dmg/background.tiff` | @XusBadia | Rendered from `packaging/macos/dmg/background.svg` by `packaging/macos/dmg/generate.py` | MIT OR Apache-2.0 (same as the code: `LICENSE-MIT`, `LICENSE-APACHE`) | 1x + 2x HiDPI TIFF for the macOS DMG window; includes the app icon (see its row) and LittleCMS's built-in sRGB profile ("No copyright, use freely") | | `examples/apartment.dxf` | CADCraft contributors | sample drawing made with cadcraft-cli commands | MIT OR Apache-2.0 | Original | diff --git a/apps/cadcraft/src/main.rs b/apps/cadcraft/src/main.rs index ffc2c7649..73fac7da8 100644 --- a/apps/cadcraft/src/main.rs +++ b/apps/cadcraft/src/main.rs @@ -265,7 +265,8 @@ fn saved_window(app_ron: &str) -> bool { /// unusable) is dropped first, so the window opens at its default size. `portable_file`: the /// portable copy's settings file, read instead of the user profile's. fn restores_window(portable_file: Option<&std::path::Path>) -> bool { - let Some(path) = portable_file.map(std::path::PathBuf::from).or_else(|| eframe::storage_dir(os_window::app_id()).map(|dir| dir.join("app.ron"))) else { + let Some(path) = portable_file.map(std::path::PathBuf::from).or_else(|| eframe::storage_dir(os_window::app_id()).map(|dir| dir.join("app.ron"))) + else { return false; }; let Ok(mut ron) = std::fs::read_to_string(&path) else { return false }; @@ -354,15 +355,28 @@ fn built_version() -> &'static str { env!("CADCRAFT_BUILT_VERSION") } -/// `CADCraft `, with ` (nightly-v1)` appended for the nightly channel: the exact line -/// `--version` prints, so a Launcher that compares the two is comparing the same string. +/// The stable line, exactly what clap prints for `--version`: `cadcraft `. fn version_string() -> String { - format!("CADCraft {}", build_flavor::version(build_flavor::COMPILED, built_version())) + format!("cadcraft {}", cadcraft_engine::build_version()) } -/// The same line with the commit, for the log: a bug report's log names the build it came from. +/// The Nightly identity line every nightly script checks: ` (nightly-v1)`, with the +/// prepared nightly version embedded at build time. The app name never gains a "Nightly". +fn nightly_version_line() -> String { + format!("CADCraft {}", build_flavor::version(build_flavor::BuildFlavor::NightlyV1, built_version())) +} + +/// The identity this build reports in its log: the Nightly line on that channel, stable's otherwise. +fn reported_version() -> String { + match build_flavor::COMPILED { + build_flavor::BuildFlavor::Stable => version_string(), + build_flavor::BuildFlavor::NightlyV1 => nightly_version_line(), + } +} + +/// The reported line with the commit, for the log: a bug report's log names the build it came from. fn log_version() -> String { - format!("{} ({})", version_string(), option_env!("CADCRAFT_BUILD_SHA").unwrap_or("dev")) + format!("{} ({})", reported_version(), option_env!("CADCRAFT_BUILD_SHA").unwrap_or("dev")) } /// Whether this start runs the isolated Nightly flavor. @@ -402,11 +416,10 @@ fn prepare_launch() -> Option> { let argv: Vec<_> = std::env::args_os().skip(1).collect(); // Plain `--version`, or the Launcher's `--launch-profile nightly-v1 --profile-root // --version`: answered before root validation, process identity, logging, IPC or any window. - if build_flavor::COMPILED == build_flavor::BuildFlavor::NightlyV1 - && (build_flavor::version_query(&argv) || launch_profile::version_query(&argv)) + if build_flavor::COMPILED == build_flavor::BuildFlavor::NightlyV1 && (build_flavor::version_query(&argv) || launch_profile::version_query(&argv)) { use std::io::Write as _; - let _ = writeln!(std::io::stdout(), "{}", version_string()); + let _ = writeln!(std::io::stdout(), "{}", nightly_version_line()); return None; } let early = launch_profile::parse(argv) @@ -416,7 +429,9 @@ fn prepare_launch() -> Option> { Ok(launch) }) .and_then(|launch| { - launch_profile::prepare(launch, |root| launch_profile::validate_root(root, |key| std::env::var_os(key), std::env::current_exe().ok().as_deref())) + launch_profile::prepare(launch, |root| { + launch_profile::validate_root(root, |key| std::env::var_os(key), std::env::current_exe().ok().as_deref()) + }) }) .unwrap_or_else(|error| { report_launch_profile_error(&error); @@ -494,23 +509,20 @@ fn main() -> eframe::Result { cadcraft_engine::settings_dir::set(vars.config_dir.clone()); // Nightly session health: the owner's lease and unclean-exit record live in the profile, and the // record is finished on the way out (on macOS in `on_exit`, see `nightly_session`). - let (nightly_watch, previous_unclean) = match nightly_session::Session::begin_with_health( - launch_profile::current().root(), - built_version(), - option_env!("CADCRAFT_BUILD_SHA"), - ) { - Ok((watch, unavailable)) => { - if unavailable { - log::warn!("another CADCraft Nightly holds this profile's session lease; this window keeps no health record"); + let (nightly_watch, previous_unclean) = + match nightly_session::Session::begin_with_health(launch_profile::current().root(), built_version(), option_env!("CADCRAFT_BUILD_SHA")) { + Ok((watch, unavailable)) => { + if unavailable { + log::warn!("another CADCraft Nightly holds this profile's session lease; this window keeps no health record"); + } + let unclean = watch.as_ref().is_some_and(nightly_session::Session::previous_unclean); + (std::sync::Arc::new(std::sync::Mutex::new(watch)), unclean) } - let unclean = watch.as_ref().is_some_and(nightly_session::Session::previous_unclean); - (std::sync::Arc::new(std::sync::Mutex::new(watch)), unclean) - } - Err(error) => { - log::warn!("Nightly session state: {error}"); - (std::sync::Arc::new(std::sync::Mutex::new(None)), false) - } - }; + Err(error) => { + log::warn!("Nightly session state: {error}"); + (std::sync::Arc::new(std::sync::Mutex::new(None)), false) + } + }; if previous_unclean { log::warn!("the previous CADCraft Nightly ended without finishing its session record"); } @@ -706,7 +718,10 @@ fn main() -> eframe::Result { #[cfg(test)] mod tests { - use super::{STENCIL_BITS, filters_for_save, follow_desktop, saved_window, stencil_bits, window_options, without_tiny_window}; + use super::{ + STENCIL_BITS, filters_for_save, follow_desktop, nightly_version_line, saved_window, stencil_bits, version_string, window_options, + without_tiny_window, + }; #[test] fn save_dialog_offers_dwg_with_the_drawing_format_first() { @@ -789,6 +804,17 @@ mod tests { assert_eq!(without_tiny_window("not ron"), None); } + /// The two identity lines. Nightly prints the kit's ` (nightly-v1)` -- the app + /// name never gains a "Nightly" -- while stable keeps exactly the line clap prints, which + /// `launch_args` asserts against its own `-V` output. + #[test] + fn the_version_lines_name_the_app_and_its_channel() { + let nightly = nightly_version_line(); + assert_eq!(nightly, format!("CADCraft {} (nightly-v1)", super::built_version())); + assert!(!nightly.contains("Nightly "), "the version line must not rename the app: {nightly}"); + assert_eq!(version_string(), format!("cadcraft {}", cadcraft_engine::build_version())); + } + /// View ▸ Theme ▸ System on Linux: winit reports no theme, so the desktop's answer stands in; /// without one (or where winit answers and the desktop doesn't) the input is left alone. #[test] diff --git a/apps/cadcraft/src/nightly_session.rs b/apps/cadcraft/src/nightly_session.rs index 098e6efd4..cb889ef04 100644 --- a/apps/cadcraft/src/nightly_session.rs +++ b/apps/cadcraft/src/nightly_session.rs @@ -160,7 +160,8 @@ mod tests { fn new() -> Self { static NEXT: AtomicU64 = AtomicU64::new(0); loop { - let path = std::env::temp_dir().join(format!("cadcraft-nightly-session-{}-{}", std::process::id(), NEXT.fetch_add(1, Ordering::Relaxed))); + let path = + std::env::temp_dir().join(format!("cadcraft-nightly-session-{}-{}", std::process::id(), NEXT.fetch_add(1, Ordering::Relaxed))); match std::fs::create_dir(&path) { Ok(()) => return Self(path), Err(error) if error.kind() == io::ErrorKind::AlreadyExists => continue, diff --git a/apps/cadcraft/src/process_identity.rs b/apps/cadcraft/src/process_identity.rs index ba8c06316..9d2e1c179 100644 --- a/apps/cadcraft/src/process_identity.rs +++ b/apps/cadcraft/src/process_identity.rs @@ -16,7 +16,8 @@ pub fn initialize(nightly: bool, app_id: &str) -> Result<(), IdentityError> { .get_or_init(|| { #[cfg(windows)] { - winsafe::SetCurrentProcessExplicitAppUserModelID(id).map_err(|error| format!("cannot set the nightly Windows identity: {error}"))?; + winsafe::SetCurrentProcessExplicitAppUserModelID(id) + .map_err(|error| format!("cannot set the nightly Windows identity: {error}"))?; let actual = winsafe::GetCurrentProcessExplicitAppUserModelID() .map_err(|error| format!("cannot read back the nightly Windows identity: {error}"))?; if actual != id { diff --git a/apps/cadcraft/src/profile_root.rs b/apps/cadcraft/src/profile_root.rs index 483a6bc68..a818d7145 100644 --- a/apps/cadcraft/src/profile_root.rs +++ b/apps/cadcraft/src/profile_root.rs @@ -99,8 +99,13 @@ fn installation_boundary(platform: Platform, exe: &Path) -> Result Option, exe: &Path) -> Result, String> { let mut roots = match platform { Platform::Windows => { - let mut roots = - ["APPDATA", "LOCALAPPDATA"].into_iter().map(|key| required_base(env, key).map(|p| p.join("CADCraft"))).collect::, _>>()?; + let mut roots = ["APPDATA", "LOCALAPPDATA"] + .into_iter() + .map(|key| required_base(env, key).map(|p| p.join("CADCraft"))) + .collect::, _>>()?; + // Stable's eframe storage folder (`eframe::storage_dir`: `app.ron` under + // `%APPDATA%\ai.storyteller.cadcraft\data`), outside the roaming `CADCraft` folder. + roots.push(required_base(env, "APPDATA")?.join(EFRAME_APP_ID)); // The MSI's per-machine folder (cadcraft.wxs). A custom install folder is not known // here; the executable's own folder is fenced below. for key in ["ProgramW6432", "ProgramFiles", "ProgramFiles(x86)"] { @@ -119,6 +124,9 @@ fn forbidden_roots(platform: Platform, env: &impl Fn(&str) -> Option, roots.extend(["/usr/bin/cadcraft", "/usr/local/bin/cadcraft", "/opt/cadcraft"].map(PathBuf::from)); // The stable Flatpak keeps its data in its own per-app folder. roots.push(required_base(env, "HOME")?.join(".var/app/ai.storyteller.cadcraft")); + // Stable's eframe storage folder (`eframe::storage_dir`: window state, Options profile, + // UI and autosave prefs in `app.ron`), which is not the XDG settings folder above. + roots.push(xdg_base(env, "XDG_DATA_HOME", ".local/share")?.join(EFRAME_APP_ID)); roots } Platform::Mac => { @@ -128,6 +136,9 @@ fn forbidden_roots(platform: Platform, env: &impl Fn(&str) -> Option, library.join("Application Support/CADCraft"), library.join("Caches/CADCraft"), library.join("Caches/ai.storyteller.cadcraft"), + // Stable's eframe storage folder (`eframe::storage_dir`: `app.ron` in Application + // Support), beside the settings folder env.rs uses. + library.join("Application Support").join(EFRAME_APP_ID), library.join("Preferences/CADCraft"), library.join("Preferences/ai.storyteller.cadcraft.plist"), library.join("Saved Application State/ai.storyteller.cadcraft.savedState"), @@ -210,7 +221,9 @@ fn validate_for( return Err("nightly-v1 cannot be combined with CADCRAFT_CONFIG_DIR outside its own profile".into()); } } - if platform != Platform::Windows && let Some(id) = env("FLATPAK_ID").filter(|v| !v.is_empty()) { + if platform != Platform::Windows + && let Some(id) = env("FLATPAK_ID").filter(|v| !v.is_empty()) + { // A Flatpak's data folder and runtime socket namespace belong to its app id. The nightly // bundle has an id of its own ([`NIGHTLY_FLATPAK_ID`], named by // `packaging/linux/flatpak-bundle.sh`), so its profile is already the sandbox's own; any @@ -255,6 +268,10 @@ fn validate_for( /// bundle id differ on purpose, as they do for stable. pub const NIGHTLY_FLATPAK_ID: &str = "ai.storyteller.cadcraft.nightly"; +/// The app id eframe derives stable's storage folder from ([`crate::main`]'s `persistence_path`). +/// A profile that sits there would overwrite stable's `app.ron`, so its folder is fenced too. +const EFRAME_APP_ID: &str = "ai.storyteller.cadcraft"; + /// The subfolder autosave and Drawing Recovery write ([`crate::main`], `/autosave`). pub const AUTOSAVE: &str = "autosave"; @@ -274,7 +291,8 @@ mod tests { fn new() -> Self { static NEXT: AtomicU64 = AtomicU64::new(0); let root = loop { - let candidate = std::env::temp_dir().join(format!("cadcraft-profile-policy-{}-{}", std::process::id(), NEXT.fetch_add(1, Ordering::Relaxed))); + let candidate = + std::env::temp_dir().join(format!("cadcraft-profile-policy-{}-{}", std::process::id(), NEXT.fetch_add(1, Ordering::Relaxed))); match std::fs::create_dir(&candidate) { Ok(()) => break std::fs::canonicalize(candidate).unwrap(), Err(error) if error.kind() == std::io::ErrorKind::AlreadyExists => continue, @@ -428,6 +446,14 @@ mod tests { assert_eq!(std::fs::read(stable.join("stable-sentinel")).unwrap(), b"stable bytes"); } let data = PathBuf::from(fixture.get("XDG_DATA_HOME").unwrap()); + // Stable's eframe storage folder holds `app.ron`, so a profile may not sit at or inside it. + let storage = data.join(EFRAME_APP_ID); + std::fs::create_dir_all(&storage).unwrap(); + std::fs::write(storage.join("app.ron"), b"stable window state").unwrap(); + for candidate in [storage.clone(), storage.join("nightly")] { + assert!(fixture.check(Platform::Linux, &candidate).unwrap_err().contains("overlap"), "{}", candidate.display()); + } + assert_eq!(std::fs::read(storage.join("app.ron")).unwrap(), b"stable window state"); let nightly = data.join("ArtCraftLauncher/nightly/profiles/cadcraft"); assert_eq!(fixture.check(Platform::Linux, &nightly).unwrap(), nightly); assert_eq!(std::fs::read_dir(nightly).unwrap().count(), 0); @@ -442,6 +468,7 @@ mod tests { let library = fixture.home().join("Library"); for suffix in [ "Application Support/CADCraft", + "Application Support/ai.storyteller.cadcraft", "Caches/CADCraft", "Caches/ai.storyteller.cadcraft", "Preferences/CADCraft", @@ -467,6 +494,7 @@ mod tests { fixture.env.insert("ProgramFiles".into(), fixture.root.join("program files").into_os_string()); for stable in [ fixture.root.join("roaming/CADCraft"), + fixture.root.join("roaming/ai.storyteller.cadcraft"), fixture.root.join("local/CADCraft"), fixture.root.join("program files/ArtCraft/CADCraft"), ] { @@ -531,13 +559,7 @@ mod tests { fn a_profile_that_cannot_be_written_is_refused_without_a_stable_fallback() { let fixture = Fixture::new(); let private = fixture.root.join("nightly-unwritable"); - let result = validate_for( - Platform::Linux, - &private, - |key| fixture.get(key), - Some(&fixture.exe), - |_| Err(std::io::Error::other("read-only")), - ); + let result = validate_for(Platform::Linux, &private, |key| fixture.get(key), Some(&fixture.exe), |_| Err(std::io::Error::other("read-only"))); assert!(result.unwrap_err().contains("not writable")); assert!(private.exists(), "the profile was created before the probe, and nothing was written into stable"); assert!(!fixture.home().join(".config/cadcraft").exists()); diff --git a/crates/ui-egui/src/chrome.rs b/crates/ui-egui/src/chrome.rs index 6888275ae..77b333105 100644 --- a/crates/ui-egui/src/chrome.rs +++ b/crates/ui-egui/src/chrome.rs @@ -536,7 +536,13 @@ pub fn start_page(app: &mut CadApp, ui: &mut egui::Ui) { let left = Rect::from_min_size(r.min, vec2(300.0, r.height())); p.rect_filled(left, 0.0, t.chrome_dark); p.rect_filled(Rect::from_min_max(pos2(left.right(), r.top()), r.max), 0.0, t.chrome); - p.text(pos2(left.left() + 34.0, left.top() + 70.0), egui::Align2::LEFT_CENTER, crate::os_window::drawn_name(), egui::FontId::proportional(28.0), t.text); + p.text( + pos2(left.left() + 34.0, left.top() + 70.0), + egui::Align2::LEFT_CENTER, + crate::os_window::drawn_name(), + egui::FontId::proportional(28.0), + t.text, + ); p.text( pos2(left.left() + 34.0, left.top() + 98.0), egui::Align2::LEFT_CENTER, diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 07e9c9697..16041f29d 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -60,9 +60,9 @@ pub mod layers; pub mod managers; pub mod menus; pub mod modal; -pub mod os_window; pub mod opening; pub mod options; +pub mod os_window; pub mod palettes; pub mod parametric; pub mod plotstyles; diff --git a/docs/nightly-signing-policy.example.json b/docs/nightly-signing-policy.example.json deleted file mode 100644 index 28a058d37..000000000 --- a/docs/nightly-signing-policy.example.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "schema": "craft-nightly-release-policy/v3", - "repository": "storytold/cadcraft", - "repository_id": null, - "producer_workflow_id": null, - "producer_workflow_path": ".github/workflows/nightly.yml", - "producer_tooling_revision": null, - "producer_workflow_ref": null, - "signer_workflow_path": ".github/workflows/nightly-sign.yml", - "signer_tooling_revision": null, - "release_branch": "release", - "manual_actors": [], - "max_age_seconds": null, - "candidate_policy": { - "schema": "craft-nightly-candidate-policy/v3", - "epoch": null, - "repository": "storytold/cadcraft", - "branch": "main", - "required_workflows": null, - "sonar": { - "organization": null, - "project": null, - "app_id": null, - "check_name": null, - "details_url": null, - "issue_types": null, - "accepted_conditions": null, - "required_conditions": null, - "debt": null - } - }, - "max_artifact_bytes": null, - "automatic_signer_actors": [], - "platforms": { - "windows-x86_64": { - "unsigned_artifact_name": "nightly-unsigned-windows-x86_64", - "trust": { - "publisher_subject": "CN=Learning Machines Inc, O=Learning Machines Inc, L=Atlanta, S=Georgia, C=US" - } - }, - "linux-x86_64": { - "unsigned_artifact_name": "nightly-unsigned-linux-x86_64", - "trust": { - "fingerprint": "2B76741B414AAD6CD33E631213A005C0B9D7C3ED" - } - }, - "macos-aarch64": { - "unsigned_artifact_name": "nightly-unsigned-macos-aarch64", - "trust": { - "apple_team_id": "DJ6XS33FX8" - } - } - } -} diff --git a/docs/releasing.md b/docs/releasing.md index cb2782591..7b4fe0fe4 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -15,9 +15,8 @@ This file describes how CADCraft is released. CADCraft's Windows, Linux and macOS nightly is documented in [`nightly-release-preparation.md`](nightly-release-preparation.md). `.github/workflows/nightly.yml` and `nightly-sign.yml` are enabled for **supervised manual runs only** by the reviewed release -managers: there is no schedule, and `.github/workflows/nightly-dispatch.yml` (the automatic -completion transport) is still literally switched off. No platform secret is granted to the -producer. Stable `release.yml`, its triggers, environment and secrets are unchanged. +managers: there is no schedule, and there is no automatic transport yet — a run is dispatched by +hand, and the completion step is manual too. No platform secret is granted to the producer. Stable `release.yml`, its triggers, environment and secrets are unchanged. The signer-owned files (`.github/workflows/nightly-sign.yml`, `.github/nightly-signing-policy.json`, `packaging/windows/sign.ps1`, the macOS nightly signing diff --git a/packaging/linux/nightly-launch.sh b/packaging/linux/nightly-launch.sh index 613587ed6..1c09e007f 100644 --- a/packaging/linux/nightly-launch.sh +++ b/packaging/linux/nightly-launch.sh @@ -1,14 +1,21 @@ #!/bin/sh -# The launcher inside CADCraft Nightly's flat tar. An unpacked copy starts the GUI the flavor's way -# -- with this channel's own launch profile -- so it never reads or writes stable's settings, -# window state or recovery files. The tar ships the real binary beside it. +# The launcher inside CADCraft Nightly's flat tar. The tar's layout is the kit's: `cadcraft` is this +# script and `cadcraft-bin` the GUI beside it. An unpacked copy starts the GUI with this channel's +# own launch profile, so it never reads or writes stable's settings, window state or recovery files. set -eu here="$(dirname "$0")" +real_bin="$here/cadcraft-bin" +# Every path is resolved beside this script: there is no relative fallback, so a copy unpacked +# anywhere cannot be pointed at another program by its parent folder. +if [ ! -f "$real_bin" ] || [ -L "$real_bin" ]; then + echo "error: cadcraft-bin is missing beside $0" >&2 + exit 2 +fi case "${1-}" in # The Launcher already named the profile (its version query does too); never pass it twice. A # plain version query answers without touching any profile. - --launch-profile | --version | -V) exec "$here/cadcraft" "$@" ;; + --launch-profile | --profile-root | --version | -V) exec "$real_bin" "$@" ;; esac profile_base="${XDG_DATA_HOME:-${HOME:?HOME is required}/.local/share}" -exec "$here/cadcraft" --launch-profile nightly-v1 --profile-root "$profile_base/cadcraft-nightly" -- "$@" +exec "$real_bin" --launch-profile nightly-v1 --profile-root "$profile_base/cadcraft-nightly" -- "$@" diff --git a/packaging/linux/nightly.sh b/packaging/linux/nightly.sh index a6fc57f21..a794c3522 100755 --- a/packaging/linux/nightly.sh +++ b/packaging/linux/nightly.sh @@ -18,12 +18,13 @@ OUTPUT="$DIST/cadcraft-$VERSION-linux-x86_64-nightly.tar.gz" nightly_build_gui STAGE="$NIGHTLY_WORK/stage" mkdir -p "$STAGE" -cp "$NIGHTLY_GUI" "$STAGE/cadcraft" +# The kit's flat tar layout: `cadcraft` is the launcher people run and `cadcraft-bin` the GUI it +# starts with this channel's own profile, so an unpacked copy never writes stable's settings. +cp "$NIGHTLY_GUI" "$STAGE/cadcraft-bin" +chmod 755 "$STAGE/cadcraft-bin" +cp "$ROOT/packaging/linux/nightly-launch.sh" "$STAGE/cadcraft" chmod 755 "$STAGE/cadcraft" -# An unpacked tar is isolated too: the launcher starts the GUI with this channel's own profile. -cp "$ROOT/packaging/linux/nightly-launch.sh" "$STAGE/cadcraft-nightly" -chmod 755 "$STAGE/cadcraft-nightly" -cp "$ROOT/assets/app-icon/cadcraft-256.png" "$STAGE/cadcraft-nightly.png" +cp "$ROOT/assets/app-icon/cadcraft-nightly.png" "$STAGE/cadcraft-nightly.png" nightly_copy_notices "$STAGE" # The private mktemp cwd is the helper authority root, not a CLI path parent. (cd "$NIGHTLY_WORK" && python3 "$ROOT/packaging/nightly-archive.py" linux stage archive.tar.gz) diff --git a/packaging/nightly-archive-tests.py b/packaging/nightly-archive-tests.py index 7b601f27b..87db15bce 100644 --- a/packaging/nightly-archive-tests.py +++ b/packaging/nightly-archive-tests.py @@ -29,7 +29,7 @@ class ArchivePolicy(unittest.TestCase): self.stage = self.root / "stage" self.stage.mkdir() self.output = self.root / "nightly.tar.gz" - self.required = {"cadcraft", "cadcraft-nightly", "cadcraft-nightly.png", "README.md", "LICENSE-MIT", "LICENSE-APACHE", "NOTICE", "ATTRIBUTION.md"} + self.required = {"cadcraft", "cadcraft-bin", "cadcraft-nightly.png", "README.md", "LICENSE-MIT", "LICENSE-APACHE", "NOTICE", "ATTRIBUTION.md"} for name in self.required: (self.stage / name).write_bytes(b"generated fixture: " + name.encode()) (self.stage / "cadcraft").chmod(0o755) diff --git a/packaging/nightly-archive.py b/packaging/nightly-archive.py index 0a500684a..d05f01f4c 100755 --- a/packaging/nightly-archive.py +++ b/packaging/nightly-archive.py @@ -33,7 +33,8 @@ def checked_entries(root, stage): total = 0 for entry in entries: name = entry.name - if name not in {"cadcraft", "cadcraft-nightly", "cadcraft-nightly.png"} and not notice(name): + # `cadcraft` is the launcher and `cadcraft-bin` the GUI it starts with the private profile. + if name not in {"cadcraft", "cadcraft-bin", "cadcraft-nightly.png"} and not notice(name): raise ValueError(f"unexpected nightly member: {name}") if len(name.encode("utf-8")) > 100: raise ValueError(f"nightly member must be a short regular file: {name}") @@ -44,7 +45,7 @@ def checked_entries(root, stage): if name.casefold() in folded: raise ValueError(f"case-colliding nightly member: {name}") folded.add(name.casefold()) - required = {"cadcraft", "cadcraft-nightly", "cadcraft-nightly.png", "README.md", "LICENSE-MIT", "LICENSE-APACHE", "NOTICE", "ATTRIBUTION.md"} + required = {"cadcraft", "cadcraft-bin", "cadcraft-nightly.png", "README.md", "LICENSE-MIT", "LICENSE-APACHE", "NOTICE", "ATTRIBUTION.md"} if not required.issubset({item.name for item in entries}): raise ValueError("required GUI/icon/notices missing") return entries diff --git a/packaging/nightly-launcher-tests.py b/packaging/nightly-launcher-tests.py index 823c7104c..02d2ff3bc 100644 --- a/packaging/nightly-launcher-tests.py +++ b/packaging/nightly-launcher-tests.py @@ -84,12 +84,25 @@ class Launcher(unittest.TestCase): def test_the_plain_tar_launcher_starts_the_profile(self): launcher = LINUX / "nightly-launch.sh" - (self.root / "cadcraft").write_text(RECORDER, encoding="utf-8") - (self.root / "cadcraft").chmod(0o755) - installed = self.launcher("cadcraft-nightly", launcher.read_text(encoding="utf-8")) + (self.root / "cadcraft-bin").write_text(RECORDER, encoding="utf-8") + (self.root / "cadcraft-bin").chmod(0o755) + installed = self.launcher("cadcraft", launcher.read_text(encoding="utf-8")) self.assert_starts_the_profile(installed) self.assert_starts_the_profile(installed, {"XDG_DATA_HOME": str(self.root / "xdg with space")}) + def test_the_tar_launcher_refuses_a_missing_or_aliased_gui(self): + launcher = self.launcher("cadcraft", (LINUX / "nightly-launch.sh").read_text(encoding="utf-8")) + for args in ([], ["--version"]): + with self.subTest(args=args): + result = subprocess.run([str(launcher), *args], capture_output=True, text=True, timeout=60, env={"PATH": "/usr/bin:/bin", "HOME": str(self.home)}) + self.assertEqual(result.returncode, 2, result.stdout) + self.assertIn("cadcraft-bin is missing", result.stderr) + (self.root / "elsewhere").write_text(RECORDER, encoding="utf-8") + (self.root / "elsewhere").chmod(0o755) + (self.root / "cadcraft-bin").symlink_to(self.root / "elsewhere") + result = subprocess.run([str(launcher)], capture_output=True, text=True, timeout=60, env={"PATH": "/usr/bin:/bin", "HOME": str(self.home)}) + self.assertEqual(result.returncode, 2, "an aliased GUI is not started") + def test_the_arch_launcher_starts_the_profile(self): (self.root / ".cadcraft-nightly").mkdir() shutil.copy(self.real, self.root / ".cadcraft-nightly" / "cadcraft") diff --git a/packaging/windows/nightly-signing-tests.ps1 b/packaging/windows/nightly-signing-tests.ps1 index a435a3564..4aa34f2a5 100644 --- a/packaging/windows/nightly-signing-tests.ps1 +++ b/packaging/windows/nightly-signing-tests.ps1 @@ -15,6 +15,15 @@ function Invoke-Refusal([scriptblock] $Operation, [string] $Message) { Assert-Policy ($errorText.Contains($Message)) "expected refusal: $Message; got: $errorText" } function global:cargo { $global:SigningFixtureCargoCalls++; throw 'FIXTURE_COMPILER_BOUNDARY' } +# The source preflight runs `git` in the real checkout; this fixture owns its own identity, so the +# stub answers for the fixture commit instead of whatever this working copy happens to be at. +function global:git { + param([Parameter(ValueFromRemainingArguments=$true)][object[]] $Arguments) + $joined = ($Arguments | ForEach-Object { "$_" }) -join ' ' + if ($joined -match 'rev-parse HEAD$') { $global:LASTEXITCODE = 0; return ('a' * 40) } + if ($joined -match 'status --porcelain$') { $global:LASTEXITCODE = 0; return '' } + throw "the fixture must not run git: $joined" +} function global:Invoke-WebRequest { throw 'fixture must not perform signing downloads' } $global:SigningFixtureCargoCalls = 0 if (-not [IO.Path]::IsPathRooted($FixtureRoot)) { throw 'use an owned absolute FixtureRoot' } @@ -22,6 +31,9 @@ $root = Join-Path $FixtureRoot ('signing-policy-' + [Guid]::NewGuid().ToString(' New-Item -ItemType Directory -Path $root | Out-Null $version = '0.23.1-nightly.20261121.12345.1.gaaaaaaaaaaaa' $env:CADCRAFT_VERSION = $version +# The preflight's other two identities: the fixture commit the version names, and its run date. +$env:CADCRAFT_BUILD_SHA = 'a' * 40 +$env:CADCRAFT_BUILD_DATE = '2026-11-21' function Invoke-Build([switch] $BuildOnly) { $arguments = @{Arch='x64';Version=$version;Target='x86_64-pc-windows-msvc';TargetDir=$root;Dist=(Join-Path $root 'dist')} if ($BuildOnly) { $arguments.BuildOnly = $true } @@ -79,5 +91,8 @@ try { Write-Output 'PASS: stable-optional-policy-preserves-owned-bytes' } finally { Clear-SigningFixtures + # The fixture's own source identity, so it never reaches the caller's environment. + [Environment]::SetEnvironmentVariable('CADCRAFT_BUILD_SHA', $null) + [Environment]::SetEnvironmentVariable('CADCRAFT_BUILD_DATE', $null) Remove-Item -LiteralPath $root -Recurse -Force } diff --git a/packaging/windows/nightly.ps1 b/packaging/windows/nightly.ps1 index a9ed4777a..203ed3c05 100644 --- a/packaging/windows/nightly.ps1 +++ b/packaging/windows/nightly.ps1 @@ -78,17 +78,15 @@ $Root = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path $Source = Get-NightlySourceState $Root Assert-NightlySource $Version $env:CADCRAFT_BUILD_SHA $env:CADCRAFT_BUILD_DATE $Source.Head $Source.Status $oldChannel = $env:CADCRAFT_BUILD_CHANNEL -$oldVersionOverride = $env:CADCRAFT_OVERRIDE_VERSION try { + # `build.rs` reads CADCRAFT_VERSION (already required above), not a PhotoCraft-style override. $env:CADCRAFT_BUILD_CHANNEL = 'nightly-v1' - $env:CADCRAFT_OVERRIDE_VERSION = $Version $env:CADCRAFT_REQUIRE_WINRES = '1' $env:CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS = '-C target-feature=+crt-static' cargo build --release --locked -p cadcraft --target $Target if ($LASTEXITCODE -ne 0) { throw "nightly cargo build failed: $LASTEXITCODE" } } finally { $env:CADCRAFT_BUILD_CHANNEL = $oldChannel - $env:CADCRAFT_OVERRIDE_VERSION = $oldVersionOverride } $Source = Get-NightlySourceState $Root try { Assert-NightlySource $Version $env:CADCRAFT_BUILD_SHA $env:CADCRAFT_BUILD_DATE $Source.Head $Source.Status }