PhotoCraft: An open-source, photo editor written by scratch in pure Rust
FreeBSD release tarball and README platform lines (#284) (#284)
Brandon Thomasa96a621deea9
diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.ymlindex 9dc8fe0b9..00aac09ab 100644--- a/.github/workflows/freebsd.yml+++ b/.github/workflows/freebsd.yml@@ -1,5 +1,8 @@# Builds and tests the workspace on FreeBSD, inside a FreeBSD VM on a Linux runner# (GitHub has no FreeBSD runners). GPU tests skip themselves when the VM has no adapter.+# It then runs packaging/freebsd/package.sh, the script the release job runs, and checks the+# tarball, so a broken FreeBSD package fails here before it can fail a release. Nothing is+# uploaded and no secrets are used.name: FreeBSDon:@@ -11,6 +14,9 @@ on:- Cargo.lock- "**/Cargo.toml"- .github/workflows/freebsd.yml+ - .github/workflows/release.yml+ - packaging/freebsd/**+ - packaging/env.shworkflow_dispatch:concurrency:@@ -22,12 +28,12 @@ permissions:jobs:freebsd:- name: FreeBSD 14 (build + test)+ name: FreeBSD 14 (build + test + package)runs-on: ubuntu-latesttimeout-minutes: 300steps:- uses: actions/checkout@v4- - name: Build and test in a FreeBSD VM+ - name: Build, test and package in a FreeBSD VMuses: vmactions/freebsd-vm@c46abacb49f09938ca4e1702d15d836285d694cc # v1with:release: "14.3"@@ -37,12 +43,18 @@ jobs:# Nothing to bring back; copying the target dir out of the VM fails on large builds.copyback: falseprepare: |- pkg install -y git curl pkgconf cmake python3 libxkbcommon wayland libX11 libXcursor libXrandr libXi libxcb mesa-libs vulkan-loader gtk3 fontconfig freetype2 alsa-lib+ pkg install -y bash git curl pkgconf cmake python3 libxkbcommon wayland libX11 libXcursor libXrandr libXi libxcb mesa-libs vulkan-loader gtk3 fontconfig freetype2 alsa-libcurl -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimalrun: |+ set -e. "$HOME/.cargo/env"# The checkout is synced in under another owner; let tests that call git read it.git config --global --add safe.directory "*"rustc --versionCARGO_PROFILE_DEV_DEBUG=0 cargo build --workspace --all-targets --lockedCARGO_PROFILE_DEV_DEBUG=0 cargo test --workspace --locked+ # The release package, as release.yml builds it. Free the debug build's disk first.+ rm -rf target/debug+ CARGO_BUILD_JOBS=4 bash packaging/freebsd/package.sh+ tar -tzf dist/release/photocraft-*-freebsd-x86_64.tar.gz \+ | grep -E '/bin/photocraft$|/bin/photocraft-cli$|/share/applications/ai\.storyteller\.photocraft\.desktop$|/share/doc/photocraft/LICENSE-MIT$'diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 49c317cb7..c16fbfb04 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -239,6 +239,50 @@ jobs:path: dist/release/*.flatpakif-no-files-found: error+ freebsd:+ name: FreeBSD x86_64+ needs: version+ # GitHub has no FreeBSD runners: build in a FreeBSD 14.3 VM, the same image and packages as+ # .github/workflows/freebsd.yml.+ runs-on: ubuntu-latest+ timeout-minutes: 180+ # No `environment: release`: this job signs nothing, so it gets no release secrets.+ env:+ PHOTOCRAFT_VERSION: ${{ needs.version.outputs.version }}+ PHOTOCRAFT_BUILD_DATE: ${{ needs.version.outputs.date }}+ steps:+ - uses: actions/checkout@v4+ - name: Build and package in a FreeBSD VM (tar.gz)+ # vmactions/freebsd-vm v1.5.9, pinned by commit (it runs our build).+ uses: vmactions/freebsd-vm@c46abacb49f09938ca4e1702d15d836285d694cc+ with:+ release: "14.3"+ usesh: true+ cpu: 4+ mem: 12288+ # Passed into the VM by name; never templated into the script below.+ envs: "PHOTOCRAFT_VERSION PHOTOCRAFT_BUILD_DATE PHOTOCRAFT_BUILD_SHA INPUT_VERSION"+ # The FreeBSD CI packages, plus bash for the packaging script.+ prepare: |+ pkg install -y bash git curl pkgconf cmake python3 libxkbcommon wayland libX11 libXcursor libXrandr libXi libxcb mesa-libs vulkan-loader gtk3 fontconfig freetype2 alsa-lib+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable+ run: |+ set -e+ . "$HOME/.cargo/env"+ git config --global --add safe.directory "$PWD"+ # Build outside the checkout so only dist/ is copied back out of the VM (copying the+ # target dir back fails on large builds). 4 jobs: more runs the VM out of memory.+ export CARGO_TARGET_DIR=/var/tmp/photocraft-target CARGO_BUILD_JOBS=4+ if [ -n "$INPUT_VERSION" ]; then cargo xtask version set "$PHOTOCRAFT_VERSION"; fi+ bash packaging/freebsd/package.sh+ tar -tzf dist/release/photocraft-*-freebsd-x86_64.tar.gz \+ | grep -E '/bin/photocraft$|/bin/photocraft-cli$|/share/applications/ai\.storyteller\.photocraft\.desktop$|/share/doc/photocraft/LICENSE-MIT$'+ - uses: actions/upload-artifact@v4+ with:+ name: release-freebsd-x86_64+ path: dist/release/*+ if-no-files-found: error+web:name: Web (wasm)needs: version@@ -274,7 +318,7 @@ jobs:release:name: Draft GitHub Release- needs: [version, macos, windows, linux, flatpak, web]+ needs: [version, macos, windows, linux, flatpak, freebsd, web]runs-on: ubuntu-latestenvironment: releasepermissions:diff --git a/README.md b/README.mdindex 9ad42921f..321bc7e4f 100644--- a/README.md+++ b/README.md@@ -17,7 +17,7 @@<p align="center"><img alt="100% Rust" src="https://img.shields.io/badge/100%25-Rust-b7410e?style=flat-square&logo=rust">- <img alt="macOS · Windows · Linux · Web" src="https://img.shields.io/badge/macOS%20%C2%B7%20Windows%20%C2%B7%20Linux%20%C2%B7%20Web-native-2f7bf5?style=flat-square">+ <img alt="macOS · Windows · Linux · FreeBSD · Web" src="https://img.shields.io/badge/macOS%20%C2%B7%20Windows%20%C2%B7%20Linux%20%C2%B7%20FreeBSD%20%C2%B7%20Web-native-2f7bf5?style=flat-square"><img alt="License: MIT OR Apache-2.0" src="https://img.shields.io/badge/license-MIT%20%2F%20Apache--2.0-3a3a3a?style=flat-square"><img alt="Status: early alpha" src="https://img.shields.io/badge/status-early%20alpha-d69e2e?style=flat-square"></p>@@ -257,13 +257,21 @@ cargo test --workspace # the test suiteNew contributors and AI agents: start with [`AGENTS.md`](AGENTS.md), then [`docs/`](docs/).-Installers for macOS, Windows, Linux and the web are attached to each [GitHub release](https://github.com/storytold/photocraft/releases). On Linux you can pick an AppImage, a `.deb`, an `.rpm`, a tarball or a Flatpak bundle. The bundle needs the freedesktop runtime from [Flathub](https://flathub.org/setup), which `flatpak` offers to install along with it:+Installers for macOS, Windows, Linux, FreeBSD and the web are attached to each [GitHub release](https://github.com/storytold/photocraft/releases). On Linux you can pick an AppImage, a `.deb`, an `.rpm`, a tarball or a Flatpak bundle. The bundle needs the freedesktop runtime from [Flathub](https://flathub.org/setup), which `flatpak` offers to install along with it:```shflatpak install --user photocraft-<version>-linux-x86_64.flatpak # or -linux-aarch64flatpak run ai.storyteller.photocraft```+On FreeBSD 14 (x86_64), the release has a tarball laid out like `/usr/local`. Install the runtime libraries, then unpack it there:++```sh+pkg install libxkbcommon wayland libX11 libXcursor libXrandr libXi libxcb mesa-libs vulkan-loader gtk3 fontconfig freetype2 alsa-lib+tar -xzf photocraft-<version>-freebsd-x86_64.tar.gz --strip-components 1 -C /usr/local+photocraft+```+Maintainers: [`docs/releasing.md`](docs/releasing.md) explains how releases are built, signed and published.> [!IMPORTANT]diff --git a/docs/releasing.md b/docs/releasing.mdindex ad723b8d2..daa437033 100644--- a/docs/releasing.md+++ b/docs/releasing.md@@ -1,8 +1,9 @@# Releasing PhotoCraftEvery push to the `release` branch runs `.github/workflows/release.yml`. The workflow builds-signed installers for macOS, Windows, Linux and the web, then creates or updates a **draft**-GitHub Release named `PhotoCraft v<version>`. Nobody sees a draft until a maintainer publishes it.+signed installers for macOS, Windows, Linux and the web, plus a FreeBSD tarball, then creates+or updates a **draft** GitHub Release named `PhotoCraft v<version>`. Nobody sees a draft until a+maintainer publishes it.This is PhotoCraft's implementation of the shared[release playbook](release-playbook.md). User-facing names say **PhotoCraft**. Files, binaries@@ -52,6 +53,7 @@ in the dialog.| Windows 10+ x86 (32-bit) | `photocraft-<v>-windows-x86.msi`, `photocraft-<v>-windows-x86-portable.zip` | `windows-latest` || Linux x86_64 | `photocraft-<v>-linux-x86_64.{AppImage,deb,rpm,tar.gz,flatpak}` | `ubuntu-22.04` (Flatpak: `ubuntu-24.04`) || Linux aarch64 | `photocraft-<v>-linux-aarch64.{AppImage,deb,rpm,tar.gz,flatpak}` | `ubuntu-22.04-arm` (Flatpak: `ubuntu-24.04-arm`) |+| FreeBSD 14 x86_64 | `photocraft-<v>-freebsd-x86_64.tar.gz` | FreeBSD 14.3 VM on `ubuntu-latest` || Web | `photocraft-web-<v>.zip` (static site; see [`packaging/web/README.md`](../packaging/web/README.md)) | `ubuntu-latest` |Every binary reports its version, the commit and the build date: `photocraft --version`,@@ -187,6 +189,34 @@ one is missing, prints the package to install and exits with status 1 instead ofLocally (on Linux): install [nfpm](https://nfpm.goreleaser.com/install/), then`packaging/linux/package.sh` (or `--formats "deb tar"`).+### FreeBSD++GitHub has no FreeBSD runners, so the `freebsd` job runs `packaging/freebsd/package.sh` in a+FreeBSD 14.3 VM (`vmactions/freebsd-vm`, pinned by commit), with the same packages as the+FreeBSD CI workflow (`.github/workflows/freebsd.yml`) plus `bash`. The script builds both+binaries with `CARGO_BUILD_JOBS=4` (more runs the 12 GB VM out of memory) and writes+`photocraft-<v>-freebsd-x86_64.tar.gz`. FreeBSD's `uname -m` says `amd64`; the file name uses+`x86_64` like the other artifacts. The tarball is a `/usr/local`-style tree: `bin/photocraft`,+`bin/photocraft-cli`, and under `share/` the same desktop entry, MIME type, AppStream metainfo+and hicolor icons as Linux, plus the licences, `NOTICE` and `ATTRIBUTION.md` in+`share/doc/photocraft/`. Users install it with:++```sh+pkg install libxkbcommon wayland libX11 libXcursor libXrandr libXi libxcb mesa-libs vulkan-loader gtk3 fontconfig freetype2 alsa-lib+tar -xzf photocraft-<v>-freebsd-x86_64.tar.gz --strip-components 1 -C /usr/local+```++The job signs nothing, so it runs outside the `release` environment and gets no secrets. The+version, build date and commit reach the VM through the action's `envs:` (by name, never+templated into the script), and the build happens in `/var/tmp` so only `dist/` is copied back+out of the VM. The binaries aren't signed: FreeBSD has no code-signing scheme for loose+binaries, so check the tarball against `SHA256SUMS.txt`.++The FreeBSD CI workflow runs the same script after its build and test (on pushes to `main`, and+on PRs that touch `packaging/freebsd/`, `freebsd.yml` or `release.yml`), so the release job+isn't the first place it runs. Locally, on any OS, `packaging/freebsd/package.sh --dry-run` stages the tree from stub binaries+and lists the tarball, which checks the layout without a FreeBSD machine.+### Web`packaging/web/package.sh` runs `trunk build --release` (see `apps/photocraft-web/Trunk.toml`)@@ -200,9 +230,9 @@ caching, the iframe snippet and the `?webgl` / `?cpu` flags.## SecretsAll secrets live in the repository's **`release` environment** (*Settings → Environments →-release*). Restrict its deployment branches to `release`. Every job in `release.yml` declares-`environment: release`, so only pushes to that branch, or manual runs on it, can read the-secrets. Each secret is optional. If one is missing, that platform's artifacts are unsigned and+release*). Restrict its deployment branches to `release`. Every job in `release.yml` that+signs or publishes declares `environment: release` (the Flatpak and FreeBSD jobs sign nothing+and don't), so only pushes to that branch, or manual runs on it, can read the secrets. Each secret is optional. If one is missing, that platform's artifacts are unsigned andthe run shows a `::warning::`.| Secret | Used for |diff --git a/docs/scorecard.md b/docs/scorecard.mdindex fdc783aff..9e28004b8 100644--- a/docs/scorecard.md+++ b/docs/scorecard.md@@ -13,7 +13,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js| [Type](#type) | 0 | 3 | 6 | || [Automation](#automation) | 1 | 3 | 7 | 626 of 626 menu items live (100.0%) || [Reliability](#reliability) | 2 | 1 | 4 | never-crash lints on 26 of 26 crates; panic_hunt present |-| [Distribution](#distribution) | 4 | 2 | 4 | |+| [Distribution](#distribution) | 4 | 3 | 4 | || [Open bugs](#open-bugs) | 0 | 3 | 29 | |## Performance@@ -235,7 +235,8 @@ Never-crash attribute on 26 of 26 crate roots.| DIST-2 | Windows x64 and x86 builds | partial | | release.yml:113-114; signing skipped with a warning until the signing material exists || DIST-3 | Linux x86_64 and aarch64: AppImage, deb, rpm, tar.gz | done | | release.yml:162-163,186 || DIST-4 | Flatpak single-file bundles, x86_64 and aarch64 | done | | release.yml:204-216 (#163) |-| DIST-5 | Web build (wasm32, trunk) | done | | release.yml:255 |+| DIST-5 | Web build (wasm32, trunk) | done | | release.yml:312 |+| DIST-6 | FreeBSD 14 x86_64 tar.gz (/usr/local tree) built in a FreeBSD VM | partial | | release.yml:242-283 (freebsd job) + packaging/freebsd/package.sh; layout checked with --dry-run, not yet produced by a release run || DIST-220-1 | Help > Check for Updates plus an opt-out periodic release-feed check on all desktops | missing | [#220](https://github.com/storytold/photocraft/issues/220) | No update check in crates || DIST-220-2 | Windows ARM64 (aarch64-pc-windows-msvc) in the release matrix, signed like x64 | missing | [#220](https://github.com/storytold/photocraft/issues/220) | release.yml:113-114 only x86_64 and i686 msvc || DIST-220-3 | In-app bug report with reviewable diagnostics that opens a prefilled issue | missing | [#220](https://github.com/storytold/photocraft/issues/220) | No bug report dialog in crates |diff --git a/packaging/freebsd/package.sh b/packaging/freebsd/package.shnew file mode 100755index 000000000..df9740aba--- /dev/null+++ b/packaging/freebsd/package.sh@@ -0,0 +1,103 @@+#!/usr/bin/env bash+# Build and package PhotoCraft for FreeBSD:+#+# $DIST/photocraft-<version>-freebsd-x86_64.tar.gz a /usr/local-style tree:+# photocraft-<version>-freebsd-x86_64/{bin, share/applications, share/icons, share/mime,+# share/metainfo, share/doc/photocraft}+#+# Install by copying the tree's contents into /usr/local:+# tar -xzf photocraft-<version>-freebsd-x86_64.tar.gz --strip-components 1 -C /usr/local+#+# Usage: packaging/freebsd/package.sh [--skip-build] [--dry-run]+# --dry-run stage the tree from stub binaries and list it, without building (works on any OS)+#+# Needs: bash, cargo, and the packages installed in .github/workflows/freebsd.yml.+set -euo pipefail+# shellcheck source=../env.sh+. "$(dirname "${BASH_SOURCE[0]}")/../env.sh"+LINUX="$ROOT/packaging/linux"+APP_ID=ai.storyteller.photocraft++SKIP_BUILD=0+DRY_RUN=0+while [ $# -gt 0 ]; do+ case "$1" in+ --skip-build) SKIP_BUILD=1; shift ;;+ --dry-run) DRY_RUN=1; SKIP_BUILD=1; shift ;;+ -h | --help) sed -n '2,15p' "$0"; exit 0 ;;+ *) echo "unknown argument: $1" >&2; exit 2 ;;+ esac+done++# FreeBSD's uname says amd64; release file names use x86_64 like the Linux and Windows ones.+MACHINE="$(uname -m)"+case "$MACHINE" in+ amd64 | x86_64) ARCH=x86_64 ;;+ arm64 | aarch64) ARCH=aarch64 ;;+ *) echo "unsupported architecture $MACHINE" >&2; exit 2 ;;+esac+if [ "$DRY_RUN" = 0 ] && [ "$(uname -s)" != FreeBSD ]; then+ echo "error: build on FreeBSD (or pass --dry-run to check the tree layout)" >&2+ exit 2+fi+BASENAME="photocraft-$VERSION-freebsd-$ARCH"++echo "==> PhotoCraft $VERSION for FreeBSD $ARCH"++# The release VM has 12 GB; full parallelism on the biggest crates runs it out of memory.+export CARGO_BUILD_JOBS="${CARGO_BUILD_JOBS:-4}"+if [ "$SKIP_BUILD" = 0 ]; then+ (cd "$ROOT" && cargo build --release --locked -p photocraft -p photocraft-cli)+fi+WORK="$CARGO_TARGET_DIR/freebsd-package"+STAGE="$WORK/$BASENAME"+rm -rf "$WORK"+mkdir -p "$WORK"++BIN="$CARGO_TARGET_DIR/release"+OUT_DIR="$DIST"+if [ "$DRY_RUN" = 1 ]; then+ # Stub binaries, and the tarball stays in the work dir so dist/ only ever holds real builds.+ BIN="$WORK/stub-bin"+ OUT_DIR="$WORK"+ mkdir -p "$BIN"+ for b in photocraft photocraft-cli; do+ printf '#!/bin/sh\necho "%s %s (dry-run stub)"\n' "$b" "$VERSION" >"$BIN/$b"+ chmod 755 "$BIN/$b"+ done+fi++# ---- stage a /usr/local-style tree --------------------------------------------------------------+# FreeBSD's install(1) has no -D: create the directories first.+mkdir -p "$STAGE/bin" "$STAGE/share/applications" "$STAGE/share/mime/packages" \+ "$STAGE/share/metainfo" "$STAGE/share/icons" "$STAGE/share/doc/photocraft"+install -m 755 "$BIN/photocraft" "$BIN/photocraft-cli" "$STAGE/bin/"+strip "$STAGE/bin/photocraft" "$STAGE/bin/photocraft-cli" 2>/dev/null || true+# The desktop entry, MIME type, metainfo and icons are the freedesktop files Linux ships.+install -m 644 "$LINUX/$APP_ID.desktop" "$STAGE/share/applications/$APP_ID.desktop"+install -m 644 "$LINUX/$APP_ID.mime.xml" "$STAGE/share/mime/packages/$APP_ID.xml"+sed -e "s/@VERSION@/$VERSION/g" -e "s/@DATE@/$PHOTOCRAFT_BUILD_DATE/g" \+ "$LINUX/$APP_ID.metainfo.xml.in" >"$STAGE/share/metainfo/$APP_ID.metainfo.xml"+cp -R "$ROOT/assets/app-icon/hicolor" "$STAGE/share/icons/"+copy_docs "$STAGE/share/doc/photocraft"+for f in NOTICE ATTRIBUTION.md; do+ if [ -f "$ROOT/$f" ]; then install -m 644 "$ROOT/$f" "$STAGE/share/doc/photocraft/"; fi+done++for f in bin/photocraft bin/photocraft-cli "share/applications/$APP_ID.desktop" \+ "share/icons/hicolor/256x256/apps/$APP_ID.png" "share/icons/hicolor/scalable/apps/$APP_ID.svg" \+ share/doc/photocraft/LICENSE-MIT share/doc/photocraft/LICENSE-APACHE; do+ if [ ! -e "$STAGE/$f" ]; then echo "error: $f is missing from the package" >&2; exit 1; fi+done++# ---- .tar.gz ------------------------------------------------------------------------------------+mkdir -p "$OUT_DIR"+tar -C "$WORK" -czf "$OUT_DIR/$BASENAME.tar.gz" "$BASENAME"+echo "wrote $OUT_DIR/$BASENAME.tar.gz"++"$STAGE/bin/photocraft-cli" --version+if [ "$DRY_RUN" = 1 ]; then+ echo "==> dry run: tarball contents"+ tar -tzvf "$OUT_DIR/$BASENAME.tar.gz"+fi+echo "==> done"diff --git a/scorecard/distribution.toml b/scorecard/distribution.tomlindex 6eaea804c..cd0b4e060 100644--- a/scorecard/distribution.toml+++ b/scorecard/distribution.toml@@ -32,7 +32,13 @@ note = "release.yml:204-216 (#163)"id = "DIST-5"target = "Web build (wasm32, trunk)"status = "done"-note = "release.yml:255"+note = "release.yml:312"++[[item]]+id = "DIST-6"+target = "FreeBSD 14 x86_64 tar.gz (/usr/local tree) built in a FreeBSD VM"+status = "partial"+note = "release.yml:242-283 (freebsd job) + packaging/freebsd/package.sh; layout checked with --dry-run, not yet produced by a release run"[[item]]id = "DIST-220-1"