Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

ci(macos): package the arch the job builds, and name DMGs after the machine

Etienne Lescot099c9e05299b
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 76ac9ef39..2a2c0a9e6 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -224,18 +224,42 @@ jobs:
VERSION="$(node -e "console.log(require('./package.json').version)")"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
+ # `--${{ matrix.arch }}` above does NOT restrict the architecture: the
+ # `arch` list in electron-builder.json5's `mac.target` names both x64 and
+ # arm64 and the config wins, so BOTH bundles are produced in every job —
+ # x64 in release/<ver>/mac/, arm64 in release/<ver>/mac-arm64/. The old
+ # `find release/<ver> ... | head -n1` took whichever came first in
+ # directory order (x64, in practice), so the arm64 job could package the
+ # x64 bundle into a DMG named `-arm64-`. Nothing downstream compared the
+ # name against the contents, so that would have published silently.
- name: Find .app bundle
id: find_app
run: |
VERSION="${{ steps.version.outputs.version }}"
- APP_BUNDLE="$(find "release/${VERSION}" -maxdepth 4 -name "*.app" -type d | head -n1)"
+ if [[ "${{ matrix.arch }}" == "arm64" ]]; then ARCH_DIR="mac-arm64"; else ARCH_DIR="mac"; fi
+ APP_BUNDLE="$(find "release/${VERSION}/${ARCH_DIR}" -maxdepth 2 -name "*.app" -type d | head -n1)"
if [[ -z "$APP_BUNDLE" ]]; then
- echo "::error::No .app bundle found in release/${VERSION}/"
+ echo "::error::No .app bundle found in release/${VERSION}/${ARCH_DIR}/"
find "release/${VERSION}" -maxdepth 4 -print || true
exit 1
fi
echo "app_bundle=$APP_BUNDLE" >> "$GITHUB_OUTPUT"
+ # The guard for the above: refuse to build a DMG whose name would not
+ # match its contents. An Intel bundle on an Apple Silicon Mac runs under
+ # Rosetta 2 — compositor, encoder and whisper all translated — which is
+ # slow enough to be unusable, so a mislabelled DMG is a real user harm.
+ - name: Verify .app architecture matches the job
+ run: |
+ BIN="${{ steps.find_app.outputs.app_bundle }}/Contents/MacOS/Openscreen"
+ if [[ "${{ matrix.arch }}" == "arm64" ]]; then EXPECTED="arm64"; else EXPECTED="x86_64"; fi
+ ACTUAL="$(lipo -archs "$BIN")"
+ echo "job arch=${{ matrix.arch }} expected=${EXPECTED} actual=${ACTUAL}"
+ if [[ " ${ACTUAL} " != *" ${EXPECTED} "* ]]; then
+ echo "::error::The ${{ matrix.arch }} job produced a '${ACTUAL}' bundle — refusing to publish a mislabelled DMG"
+ exit 1
+ fi
+
- name: Verify .app code signature
if: steps.signing.outputs.enabled == 'true'
run: codesign --verify --deep --strict "${{ steps.find_app.outputs.app_bundle }}"
@@ -245,7 +269,17 @@ jobs:
run: |
VERSION="${{ steps.version.outputs.version }}"
ARCH="${{ matrix.arch }}"
- DMG_NAME="Openscreen-Mac-${ARCH}-${VERSION}.dmg"
+ # Name the DMG after the machine, not the instruction set. "x64" reads
+ # to most people as "the normal 64-bit one" and "arm64" as the exotic
+ # variant, which is exactly backwards on any Mac sold since 2020 — and
+ # picking the wrong one silently costs Rosetta 2. `Intel` and
+ # `Apple-Silicon` are what About This Mac shows the user.
+ case "$ARCH" in
+ arm64) ARCH_LABEL="Apple-Silicon" ;;
+ x64) ARCH_LABEL="Intel" ;;
+ *) ARCH_LABEL="$ARCH" ;;
+ esac
+ DMG_NAME="Openscreen-macOS-${ARCH_LABEL}-${VERSION}.dmg"
RELEASE_DIR="release/${VERSION}"
DMG_OUTPUT="${RELEASE_DIR}/${DMG_NAME}"
STAGING="${RELEASE_DIR}/dmg-staging"
diff --git a/.github/workflows/update-homebrew-cask.yml b/.github/workflows/update-homebrew-cask.yml
index 60661a3bb..cc81ddcb3 100644
--- a/.github/workflows/update-homebrew-cask.yml
+++ b/.github/workflows/update-homebrew-cask.yml
@@ -48,15 +48,22 @@ jobs:
TIMEOUT_MINUTES=12
POLL_INTERVAL=30
MAX_ATTEMPTS=$(( (TIMEOUT_MINUTES * 60) / POLL_INTERVAL ))
- VERSION="${TAG#v}"
- ARM_DMG="Openscreen-Mac-arm64-${VERSION}.dmg"
- X64_DMG="Openscreen-Mac-x64-${VERSION}.dmg"
+ # Match on the arch marker, not on an exact filename. build.yml names
+ # the DMGs `Openscreen-macOS-Apple-Silicon-<ver>.dmg` and
+ # `-Intel-`; older releases used `-Mac-arm64-` / `-Mac-x64-`. An
+ # exact-name wait would poll for the full 12 minutes and warn, on a
+ # release whose assets were there the whole time. These are the same
+ # patterns the "Find macOS DMG assets" step below already matches on,
+ # so the two steps cannot disagree about what counts as present.
for i in $(seq 1 $MAX_ATTEMPTS); do
- if gh release view "$TAG" --repo "$REPO" --json assets --jq \
- --arg arm "$ARM_DMG" --arg x64 "$X64_DMG" \
- '[.assets[] | select(.name == $arm or .name == $x64)] | length' 2>/dev/null | grep -q '^2$'; then
- echo "Both DMG assets present: $ARM_DMG and $X64_DMG"
+ NAMES=$(gh release view "$TAG" --repo "$REPO" --json assets --jq '.assets[].name' 2>/dev/null || true)
+ DMGS=$(echo "$NAMES" | grep -iE '\.dmg$' || true)
+ ARM_FOUND=$(echo "$DMGS" | grep -icE '(arm64|apple[-_. ]?silicon)' || true)
+ X64_FOUND=$(echo "$DMGS" | grep -icE '(x64|x86[-_]?64|intel)' || true)
+ if [[ "$ARM_FOUND" -ge 1 && "$X64_FOUND" -ge 1 ]]; then
+ echo "Both DMG assets present:"
+ echo "$DMGS"
exit 0
fi
echo "Waiting for DMG assets... (attempt $i/$MAX_ATTEMPTS)"