From 941b1c5780a57d8604d9f5645972ae4dfec6bf5d Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Wed, 11 Nov 2026 17:29:30 +0100 Subject: [PATCH] CI: release FreeBSD through the shared workflow now that the repo is public The FreeBSD jobs in release.yml were kept here only while the repo was private, as their comment says, so they ran on a larger runner. The repo is public now. They also install the VM host's qemu without the shared fallback mirrors, so the v0.4.0 release failed at that step while ubuntu.com did not resolve. Remove them and let the shared release workflow build FreeBSD (has-freebsd defaults to true). --- .github/workflows/release.yml | 283 +--------------------------------- 1 file changed, 2 insertions(+), 281 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 49ef2371..9c4a8df2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,8 +10,8 @@ on: type: string default: "" -# Nothing by default; each job names what it needs. Only `release` and `freebsd-draft` write -# (the draft GitHub Release, and the packages the shared release job publishes). +# Nothing by default; each job names what it needs. Only `release` writes (the draft GitHub +# Release, and the packages the shared release job publishes). permissions: {} concurrency: @@ -30,9 +30,6 @@ jobs: app-title: "MaterialCraft" craft-fonts-ref: 3d9ab3a132ed0eff457e424226a435a901da30d3 web-craft-fonts: true - # The shared FreeBSD job needs more memory than a private repo's ubuntu-latest has. The - # freebsd job below builds it here on a larger runner instead. - has-freebsd: false version: ${{ inputs.version }} secrets: APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} @@ -50,279 +47,3 @@ jobs: AZURE_SIGNING_ACCOUNT: ${{ secrets.AZURE_SIGNING_ACCOUNT }} AZURE_CERT_PROFILE: ${{ secrets.AZURE_CERT_PROFILE }} LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }} - - # The jobs below stay here only while this repo is private. They follow the shared workflow's - # FreeBSD job, on a larger runner. When the repo is public, remove them and has-freebsd: false. - version: - timeout-minutes: 10 - name: version - runs-on: ubuntu-latest - permissions: - contents: read - outputs: - version: ${{ steps.v.outputs.version }} - date: ${{ steps.v.outputs.date }} - prerelease: ${{ steps.v.outputs.prerelease }} - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - id: v - name: Resolve version - uses: storytold/craft-common-actions/actions/resolve-version@main - with: - input-version: ${{ inputs.version }} - app-title: "MaterialCraft" - - freebsd: - name: FreeBSD ${{ matrix.arch }} - needs: [version] - # A private repo's ubuntu-latest has about 7 GB, too little for the VM's 12 GB. - runs-on: github-ubuntu-16core - permissions: - contents: read - timeout-minutes: 300 - strategy: - fail-fast: false - matrix: - arch: [x86_64, aarch64] - env: - APP_NAME: materialcraft - CARGO_HOME: /var/tmp/craft-cargo - CARGO_TARGET_DIR: /var/tmp/craft-target - CARGO_BUILD_JOBS: 4 - CARGO_TERM_COLOR: always - CARGO_INCREMENTAL: 0 - RUST_BACKTRACE: 1 - VERSION: ${{ needs.version.outputs.version }} - BUILD_DATE: ${{ needs.version.outputs.date }} - BUILD_SHA: ${{ github.sha }} - MATERIALCRAFT_VERSION: ${{ needs.version.outputs.version }} - MATERIALCRAFT_BUILD_DATE: ${{ needs.version.outputs.date }} - MATERIALCRAFT_BUILD_SHA: ${{ github.sha }} - INPUT_VERSION: ${{ inputs.version }} - steps: - - name: Check the FreeBSD architecture - env: - ARCH: ${{ matrix.arch }} - run: | - # The guest is always x86_64 and only aarch64 is cross-compiled: any other value - # would build x86_64 binaries and package them under its own name. - case "$ARCH" in - x86_64 | aarch64) ;; - *) - echo "::error::unsupported FreeBSD architecture '$ARCH' in freebsd-architectures; use x86_64 or aarch64" - exit 1 - ;; - esac - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - name: Check out craft-fonts - uses: storytold/craft-common-actions/actions/checkout-craft-fonts@main - with: - ref: 3d9ab3a132ed0eff457e424226a435a901da30d3 - - name: Check out craft-i18n - uses: storytold/craft-common-actions/actions/checkout-craft-i18n@main - - name: Start the FreeBSD VM - uses: vmactions/freebsd-vm@c46abacb49f09938ca4e1702d15d836285d694cc # v1.5.9 - with: - release: "15.1" - # Always an x86_64 guest, which KVM accelerates: aarch64 is cross-compiled in it, - # because an emulated aarch64 guest takes over 5 hours for most apps (#39). - usesh: true - cpu: 4 - mem: 12288 - copyback: false - envs: "APP_NAME CARGO_HOME CARGO_TARGET_DIR CARGO_INCREMENTAL CARGO_BUILD_JOBS VERSION BUILD_DATE BUILD_SHA INPUT_VERSION MATERIALCRAFT_VERSION MATERIALCRAFT_BUILD_DATE MATERIALCRAFT_BUILD_SHA" - prepare: | - # Keep rustup/proxies outside the Cargo data cache. - unset CARGO_HOME CARGO_TARGET_DIR - if [ "${{ matrix.arch }}" = aarch64 ]; then - # The host compiler and the aarch64 standard library come from the amd64 and - # aarch64 lang/rust packages, which must be the same build. "latest" can build - # them days apart; the quarterly branch keeps them in step. - mkdir -p /usr/local/etc/pkg/repos - printf 'FreeBSD-ports: { url: "https://pkg.FreeBSD.org/${ABI}/quarterly" }\n' > /usr/local/etc/pkg/repos/FreeBSD.conf - pkg update -f -q - fi - 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 - # aarch64-unknown-freebsd is a tier-3 Rust target: rustup publishes no toolchain - # or standard library for it ("installer for platform not found"), so use - # FreeBSD's lang/rust package. - if [ "${{ matrix.arch }}" = aarch64 ]; then - pkg install -y rust - else - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable - fi - - name: Set up the aarch64 cross toolchain - if: matrix.arch == 'aarch64' - shell: freebsd {0} - run: | - set -eu - # Stable Rust, no -Zbuild-std: the aarch64 standard library is copied from FreeBSD's - # aarch64 lang/rust package, and C code links with base clang and lld against an - # arm64 sysroot (base.txz plus the libraries the prepare step installs). - target=aarch64-unknown-freebsd - X=/var/tmp/craft-cross - S=$X/sysroot - mkdir -p "$X/db" "$X/cache" "$S" - release=$(freebsd-version -u | sed 's/-p[0-9]*$//') - P="-o ABI=FreeBSD:${release%%.*}:aarch64 -o OSVERSION=$(uname -U) -o PKG_DBDIR=$X/db -o PKG_CACHEDIR=$X/cache -o IGNORE_OSVERSION=yes" - pkg $P update -q - host=$(pkg query %v rust) - cross=$(pkg $P rquery %v rust) - if [ "$host" != "$cross" ]; then - echo "error: lang/rust is $host for amd64 but $cross for aarch64; the standard library must match the compiler" >&2 - exit 1 - fi - pkg $P fetch -y -q rust - # pkg links each name-version.pkg to its hashed file. - tar -xf "$X/cache/rust-$cross.pkg" -C "$X" --include "*usr/local/lib/rustlib/$target/*" - cp -R "$X/usr/local/lib/rustlib/$target" /usr/local/lib/rustlib/ - base=https://download.freebsd.org/releases/arm64/aarch64/$release - fetch -q -o "$X/MANIFEST" "$base/MANIFEST" - fetch -q -o "$X/base.txz" "$base/base.txz" - if [ "$(awk '$1 == "base.txz" { print $2 }' "$X/MANIFEST")" != "$(sha256 -q "$X/base.txz")" ]; then - echo "error: arm64 base.txz does not match its MANIFEST" >&2 - exit 1 - fi - tar -xf "$X/base.txz" -C "$S" ./lib ./usr/lib ./usr/include ./usr/libdata - # The libraries the prepare step installs; the build tools and fonts stay host-only. - pkg $P fetch -y -q -d libxkbcommon wayland libX11 libXcursor libXrandr libXi libxcb mesa-libs vulkan-loader gtk3 fontconfig freetype2 alsa-lib - for p in "$X"/cache/*.pkg; do - [ ! -L "$p" ] || continue - case "$p" in */rust-*) continue ;; esac - tar -xf "$p" -C "$S" --exclude '+*' - done - for tool in cc c++; do - printf '#!/bin/sh\nexec %s --target=%s%s --sysroot=%s -fuse-ld=lld -I%s/usr/local/include -L%s/usr/local/lib -Wl,-rpath-link,%s/usr/local/lib "$@"\n' \ - "$tool" "$target" "${release%%-*}" "$S" "$S" "$S" "$S" > "$X/$tool" - chmod +x "$X/$tool" - done - cat > "$X/env" </release. - rel="${CARGO_BUILD_TARGET:+$CARGO_BUILD_TARGET/}release" - export CRAFT_FONTS_DIR="$PWD/craft-fonts" CRAFT_FONTS_REQUIRED=1 - if [ -f craft-i18n.rev ]; then export CRAFT_I18N_DIR="$PWD/craft-i18n" CRAFT_I18N_REQUIRED=1; fi - if [ -f packaging/freebsd/package.sh ]; then - bash packaging/freebsd/package.sh - else - set -- -p "$APP_NAME" - if cargo metadata --format-version 1 --no-deps | python3 -c 'import json, sys; sys.exit(not any(p["name"] == sys.argv[1] for p in json.load(sys.stdin)["packages"]))' "$APP_NAME-cli"; then - set -- "$@" -p "$APP_NAME-cli" - fi - cargo build --release --locked "$@" - name="$APP_NAME-$VERSION-freebsd-${{ matrix.arch }}" - mkdir -p "dist/release/$name" - cp "target/$rel/$APP_NAME" "dist/release/$name/" 2>/dev/null || cp "/var/tmp/craft-target/$rel/$APP_NAME" "dist/release/$name/" - if [ -f "target/$rel/$APP_NAME-cli" ]; then - cp "target/$rel/$APP_NAME-cli" "dist/release/$name/" - elif [ -f "/var/tmp/craft-target/$rel/$APP_NAME-cli" ]; then - cp "/var/tmp/craft-target/$rel/$APP_NAME-cli" "dist/release/$name/" - fi - cp README.md LICENSE-MIT LICENSE-APACHE NOTICE ATTRIBUTION.md "dist/release/$name/" 2>/dev/null || true - if [ -f "packaging/linux/ai.storyteller.$APP_NAME.desktop" ]; then - cp "packaging/linux/ai.storyteller.$APP_NAME.desktop" "dist/release/$name/" - fi - mkdir -p "dist/release/$name/icons" - cp -R assets/app-icon/hicolor "dist/release/$name/icons/" 2>/dev/null || true - tar -C dist/release -czf "dist/release/$name.tar.gz" "$name" - rm -rf "dist/release/$name" - fi - # The guest is x86_64 either way: a package.sh that names its archive after uname -m - # instead of CARGO_BUILD_TARGET would ship an x86_64-labelled aarch64 build, or worse. - found= - for archive in dist/release/*-freebsd-*.tar.gz; do - [ -f "$archive" ] || continue - case "$archive" in - *-freebsd-${{ matrix.arch }}.tar.gz) found=1 ;; - *) - echo "error: $archive is not a FreeBSD ${{ matrix.arch }} archive; packaging/freebsd/package.sh must honor CARGO_BUILD_TARGET" >&2 - exit 1 - ;; - esac - done - if [ -z "$found" ]; then - echo "error: no FreeBSD ${{ matrix.arch }} archive was produced" >&2 - exit 1 - fi - - name: Copy release archives from the VM - run: | - mkdir -p dist/release - rsync -a --timeout=1800 --rsync-path='env PATH=/usr/local/bin:/usr/bin:/bin rsync' \ - -e 'ssh -o ServerAliveInterval=30 -o ServerAliveCountMax=60 -o ConnectTimeout=120' \ - "freebsd:$GITHUB_WORKSPACE/dist/release/" dist/release/ - - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - with: - name: release-freebsd-${{ matrix.arch }} - path: dist/release/* - if-no-files-found: error - - name: Save FreeBSD release Cargo cache - if: github.event_name != 'pull_request' && github.event_name != 'pull_request_target' && steps.cargo-cache.outputs.key != '' && steps.cargo-cache.outputs.cache-hit != 'true' - continue-on-error: true - timeout-minutes: 10 - uses: storytold/craft-common-actions/actions/freebsd-cargo-cache@main - with: - phase: save - profile: release - configuration: ${{ toJSON(inputs) }} - source-hash: ${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', '**/build.rs', '.cargo/**', 'rust-toolchain*', 'packaging/**', '.github/workflows/release.yml') }} - key: ${{ steps.cargo-cache.outputs.key }} - - # The shared draft job can run before FreeBSD finishes, so add its archives afterwards. - freebsd-draft: - timeout-minutes: 10 - name: Add FreeBSD to the draft release - needs: [version, freebsd, release] - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 - with: - pattern: release-freebsd-* - path: artifacts - merge-multiple: true - - name: Upload the archives and update the checksums - working-directory: artifacts - env: - VERSION: ${{ needs.version.outputs.version }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_REPO: ${{ github.repository }} - run: | - tag="v$VERSION" - [ "$(gh release view "$tag" --json isDraft --jq .isDraft)" = true ] - gh release download "$tag" --pattern SHA256SUMS.txt --dir "$RUNNER_TEMP" - # The shared draft job also picks up any archive that finished before it ran. - # Written outside this directory, or the * below would list the checksum file itself. - { grep -v -- '-freebsd-' "$RUNNER_TEMP/SHA256SUMS.txt" || true; sha256sum -- *; } | sort -k2 >"$RUNNER_TEMP/SHA256SUMS.new" - mv "$RUNNER_TEMP/SHA256SUMS.new" SHA256SUMS.txt - gh release upload "$tag" --clobber -- * - cat SHA256SUMS.txt