Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
208 changes: 208 additions & 0 deletions .github/workflows/release-desktop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
# Signed, notarized release of the macOS desktop app (desktop-app/), published as a
# GitHub Release. It reuses the CLI release's Developer ID (Eigen Labs, SLDQ2GJ6TL)
# and notarization secrets (release-provider.yml); no other credentials are needed.
#
# - Tag desktop-vX.Y.Z (must equal desktop-app/package.json "version"): build, sign,
# notarize, verify and publish Release desktop-vX.Y.Z with the DMG, zip and
# SHA256SUMS. The release is not marked Latest, so CLI releases keep that slot.
# - Manual dispatch: the same build and verification, attached to the run as an
# artifact instead of being published (dry run).
#
# The app installs the latest published CLI on first run and drives it through the
# `darkbloom desktop` API, so a release is refused while that CLI predates it.
name: Release Desktop App

on:
push:
tags: ['desktop-v*']
workflow_dispatch:

permissions:
contents: write # gh release create

concurrency:
group: release-desktop-${{ github.ref }}
cancel-in-progress: false

env:
APPLE_TEAM_ID: 'SLDQ2GJ6TL'
# The CLI release the app's bundled installer will download (the same endpoint it uses).
CLI_RELEASE_URL: 'https://api.darkbloom.dev/v1/releases/latest'

jobs:
release:
runs-on: blacksmith-12vcpu-macos-27
timeout-minutes: 90
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0 # CLI release tags, for the compatibility check
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: '22'
cache: npm
cache-dependency-path: desktop-app/package-lock.json

- name: Resolve the version
run: |
set -euo pipefail
version=$(node -p "require('./desktop-app/package.json').version")
publish=false
if [ "$GITHUB_REF_TYPE" = tag ]; then
if [ "$GITHUB_REF_NAME" != "desktop-v$version" ]; then
echo "::error::Tag $GITHUB_REF_NAME does not match desktop-app/package.json version $version (expected desktop-v$version)"
exit 1
fi
publish=true
if gh release view "desktop-v$version" >/dev/null 2>&1; then
echo "::error::Release desktop-v$version already exists"
exit 1
fi
fi
echo "VERSION=$version" >> "$GITHUB_ENV"
echo "PUBLISH=$publish" >> "$GITHUB_ENV"
echo "Desktop $version (publish: $publish)"
env:
GH_TOKEN: ${{ github.token }}

- name: Require a published CLI with the desktop API
run: |
set -euo pipefail
cli=$(curl -fsSL "$CLI_RELEASE_URL" | python3 -c 'import json,sys; print(json.load(sys.stdin)["version"])')
echo "Latest published CLI: $cli"
if git cat-file -e "v$cli:provider-swift/Sources/darkbloom/Desktop/DesktopCommand.swift" 2>/dev/null; then
echo "CLI v$cli includes the desktop API."
echo "CLI_VERSION=$cli" >> "$GITHUB_ENV"
elif [ "$PUBLISH" = true ]; then
echo "::error::The latest published CLI (v$cli) has no 'darkbloom desktop' command; new installs could not finish setup. Release a CLI from master first."
exit 1
else
echo "::warning::The latest published CLI (v$cli) has no 'darkbloom desktop' command; a release would be refused."
echo "CLI_VERSION=$cli" >> "$GITHUB_ENV"
fi

- name: Import the Developer ID certificate
env:
P12_BASE64: ${{ secrets.APPLE_CERTIFICATE_P12 }}
P12_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
run: |
set -euo pipefail
if [ -z "$P12_BASE64" ] || [ -z "$P12_PASSWORD" ]; then
echo "::error::APPLE_CERTIFICATE_P12 / APPLE_CERTIFICATE_PASSWORD are not configured"
exit 1
fi
echo "$P12_BASE64" | base64 --decode > "$RUNNER_TEMP/cert.p12"
KEYCHAIN_PATH="$RUNNER_TEMP/desktop-build.keychain-db"
KEYCHAIN_PASSWORD=$(uuidgen)
security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
KEYCHAINS=("$KEYCHAIN_PATH")
while read -r keychain; do
keychain="${keychain#\"}"
KEYCHAINS+=("${keychain%\"}")
done < <(security list-keychains -d user)
security list-keychains -d user -s "${KEYCHAINS[@]}"
security import "$RUNNER_TEMP/cert.p12" -k "$KEYCHAIN_PATH" \
-P "$P12_PASSWORD" -T /usr/bin/codesign -f pkcs12
rm -f "$RUNNER_TEMP/cert.p12"
security set-key-partition-list -S apple-tool:,apple: -s -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" >/dev/null
# Sign with exactly the Eigen Labs Developer ID Application identity, by fingerprint.
identity=$(security find-identity -v -p codesigning "$KEYCHAIN_PATH" \
| awk -v team="($APPLE_TEAM_ID)" '/Developer ID Application/ && index($0, team) { print $2; exit }')
if [ -z "$identity" ]; then
echo "::error::No Developer ID Application identity for team $APPLE_TEAM_ID in the imported certificate"
exit 1
fi
echo "KEYCHAIN_PATH=$KEYCHAIN_PATH" >> "$GITHUB_ENV"
echo "CSC_NAME=$identity" >> "$GITHUB_ENV"

- name: Build, sign and notarize the app
working-directory: desktop-app
env:
DARKBLOOM_DESKTOP_RELEASE: '1'
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }}
run: |
set -euo pipefail
npm ci
npm run dist

- name: Notarize and staple the DMG
working-directory: desktop-app/release
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }}
run: |
set -euo pipefail
DMG="Darkbloom-$VERSION-arm64.dmg"
xcrun notarytool submit "$DMG" --apple-id "$APPLE_ID" --password "$APPLE_APP_PASSWORD" \
--team-id "$APPLE_TEAM_ID" --wait --output-format json > "$RUNNER_TEMP/notary.json"
status=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["status"])' "$RUNNER_TEMP/notary.json")
if [ "$status" != Accepted ]; then
id=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1])).get("id",""))' "$RUNNER_TEMP/notary.json")
echo "::error::DMG notarization $id finished with status $status"
xcrun notarytool log "$id" --apple-id "$APPLE_ID" --password "$APPLE_APP_PASSWORD" \
--team-id "$APPLE_TEAM_ID" || true
exit 1
fi
xcrun stapler staple "$DMG"

- name: Verify the release
working-directory: desktop-app/release
run: |
set -euo pipefail
APP="mac-arm64/Darkbloom.app"
DMG="Darkbloom-$VERSION-arm64.dmg"
ZIP="Darkbloom-$VERSION-arm64.zip"
for file in "$DMG" "$ZIP"; do [ -f "$file" ] || { echo "::error::missing $file"; exit 1; }; done
codesign --verify --deep --strict --verbose=2 "$APP"
team=$(codesign -dv "$APP" 2>&1 | sed -n 's/^TeamIdentifier=//p')
[ "$team" = "$APPLE_TEAM_ID" ] || { echo "::error::App signed by team $team, expected $APPLE_TEAM_ID"; exit 1; }
[ "$(defaults read "$PWD/$APP/Contents/Info" CFBundleShortVersionString)" = "$VERSION" ]
[ "$(defaults read "$PWD/$APP/Contents/Info" CFBundleIdentifier)" = io.darkbloom.desktop ]
spctl --assess --type execute --verbose=2 "$APP" 2>&1 | tee "$RUNNER_TEMP/spctl.txt"
grep -q "source=Notarized Developer ID" "$RUNNER_TEMP/spctl.txt"
xcrun stapler validate "$APP"
xcrun stapler validate "$DMG"
spctl --assess --type open --context context:primary-signature --verbose=2 "$DMG"
hdiutil verify "$DMG"
bash -n "$APP/Contents/Resources/bootstrap/install-runtime.sh"
shasum -a 256 "$DMG" "$ZIP" > SHA256SUMS
cat SHA256SUMS

- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: darkbloom-desktop-${{ env.VERSION }}
path: |
desktop-app/release/Darkbloom-*-arm64.dmg
desktop-app/release/Darkbloom-*-arm64.zip
desktop-app/release/SHA256SUMS
if-no-files-found: error

- name: Publish the GitHub Release
if: env.PUBLISH == 'true'
working-directory: desktop-app/release
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
cat > "$RUNNER_TEMP/notes.md" <<EOF
Darkbloom for Mac $VERSION, signed and notarized by Eigen Labs (Developer ID $APPLE_TEAM_ID).

**Install:** download \`Darkbloom-$VERSION-arm64.dmg\`, open it, drag Darkbloom to Applications and open it. The first screen installs the Darkbloom CLI when you click **Install CLI**, then checks this Mac, links your account and starts serving.

Requires Apple silicon and macOS 27 or later for new providers. Installs the latest Darkbloom CLI (v$CLI_VERSION at release time).

Verify a download with \`shasum -a 256 -c SHA256SUMS\`.
EOF
gh release create "desktop-v$VERSION" \
"Darkbloom-$VERSION-arm64.dmg" "Darkbloom-$VERSION-arm64.zip" SHA256SUMS \
--title "Darkbloom for Mac $VERSION" --notes-file "$RUNNER_TEMP/notes.md" \
--verify-tag --latest=false

- name: Remove the signing keychain
if: always()
run: |
if [ -n "${KEYCHAIN_PATH:-}" ]; then security delete-keychain "$KEYCHAIN_PATH" || true; fi
3 changes: 3 additions & 0 deletions changelog.d/desktop-release-pipeline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Desktop app releases

- Add `release-desktop.yml`: a `desktop-vX.Y.Z` tag builds the macOS desktop app, signs it with the Eigen Labs Developer ID used for the CLI, notarizes and staples the app and DMG, verifies them, and publishes the DMG, zip and `SHA256SUMS` as a GitHub Release (not marked Latest). A manual run does the same as a dry run without publishing. Releases are refused while the latest published CLI lacks the `darkbloom desktop` API.
25 changes: 23 additions & 2 deletions desktop-app/electron-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,33 @@ import { publishConfig, updateFeedEnv } from './src/main/updateFeed';
// The GUI update feed is opt-in at build time (see src/main/updateFeed.ts).
// Without DARKBLOOM_DESKTOP_UPDATE_URL, `publish: null` embeds no app-update.yml
// and stops electron-builder from inferring a GitHub feed from GH_TOKEN.
// A release build (DARKBLOOM_DESKTOP_RELEASE=1, set by release-desktop.yml) must be signed and
// notarized with the Developer ID team that also signs the CLI; it refuses to build otherwise.
export const releaseTeam = 'SLDQ2GJ6TL';
const notarizationEnv = ['APPLE_ID', 'APPLE_APP_SPECIFIC_PASSWORD', 'APPLE_TEAM_ID'] as const;

export function desktopBuildConfig(env: NodeJS.ProcessEnv): Configuration {
const team = env.DARKBLOOM_PREVIEW_TEAM_ID || '';
const runtime = env.DARKBLOOM_PREVIEW_RUNTIME;
if ((team && !/^[A-Z0-9]{10}$/.test(team)) || !!team !== !!runtime)
throw new Error(
'Local previews require DARKBLOOM_PREVIEW_RUNTIME and a valid DARKBLOOM_PREVIEW_TEAM_ID',
);
const release = env.DARKBLOOM_DESKTOP_RELEASE === '1';
if (release) {
if (team) throw new Error('A release build cannot also be a local preview');
const missing = notarizationEnv.filter((name) => !env[name]);
if (missing.length)
throw new Error(`A release build needs notarization credentials: ${missing.join(', ')}`);
if (env.APPLE_TEAM_ID !== releaseTeam)
throw new Error(`A release build must be notarized for team ${releaseTeam}`);
}
return {
appId: team ? 'io.darkbloom.desktop.preview' : 'io.darkbloom.desktop',
productName: team ? 'Darkbloom Preview' : 'Darkbloom',
...(team ? { forceCodeSigning: true, dmg: { sign: true } } : {}),
// Release builds fail instead of falling back to an unsigned app.
...(release ? { forceCodeSigning: true } : {}),
directories: { output: 'release' },
files: ['dist/**/*', 'package.json'],
extraResources: [
Expand All @@ -34,9 +50,14 @@ export function desktopBuildConfig(env: NodeJS.ProcessEnv): Configuration {
minimumSystemVersion: '14.0',
extendInfo: { LSUIElement: true },
icon: 'resources/icon.icns',
...(team
// Stable names for the GitHub release assets, e.g. Darkbloom-0.1.0-arm64.dmg.
artifactName: '${productName}-${version}-${arch}.${ext}',
// electron-builder notarizes and staples the app with APPLE_ID,
// APPLE_APP_SPECIFIC_PASSWORD and APPLE_TEAM_ID; the workflow then notarizes the DMG.
notarize: release,
...(team ? { signIgnore: ['preview-runtime/'] } : {}),
...(team || release
? {
signIgnore: ['preview-runtime/'],
// electron-builder otherwise passes the certificate's display name
// with validation disabled. Resolve the exact fingerprint instead;
// renewed certificates can legitimately have identical names.
Expand Down
51 changes: 51 additions & 0 deletions desktop-app/tests/releaseBuildConfig.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { expect, it } from 'vitest';
import { desktopBuildConfig, releaseTeam } from '../electron-builder';

const credentials = {
APPLE_ID: 'release@example.com',
APPLE_APP_SPECIFIC_PASSWORD: 'app-password',
APPLE_TEAM_ID: releaseTeam,
};

it('signs and notarizes a release build with the CLI’s Developer ID team', () => {
const config = desktopBuildConfig({ DARKBLOOM_DESKTOP_RELEASE: '1', ...credentials });
expect(config.appId).toBe('io.darkbloom.desktop');
expect(config.productName).toBe('Darkbloom');
expect(config.forceCodeSigning).toBe(true);
expect(config.mac?.notarize).toBe(true);
expect(config.mac?.artifactName).toBe('${productName}-${version}-${arch}.${ext}');
// No update feed unless one is configured.
expect(config.publish).toBeNull();
});

it('refuses a release build without notarization credentials or for another team', () => {
expect(() => desktopBuildConfig({ DARKBLOOM_DESKTOP_RELEASE: '1' })).toThrow(
'needs notarization credentials: APPLE_ID, APPLE_APP_SPECIFIC_PASSWORD, APPLE_TEAM_ID',
);
expect(() =>
desktopBuildConfig({
DARKBLOOM_DESKTOP_RELEASE: '1',
...credentials,
APPLE_TEAM_ID: 'ABCDEFGHIJ',
}),
).toThrow(`team ${releaseTeam}`);
expect(() =>
desktopBuildConfig({
DARKBLOOM_DESKTOP_RELEASE: '1',
...credentials,
DARKBLOOM_PREVIEW_TEAM_ID: 'ABCDEFGHIJ',
DARKBLOOM_PREVIEW_RUNTIME: '/tmp/runtime',
}),
).toThrow('cannot also be a local preview');
});

it('keeps development and preview builds un-notarized', () => {
expect(desktopBuildConfig({}).mac?.notarize).toBe(false);
expect(desktopBuildConfig({}).forceCodeSigning).toBeUndefined();
const preview = desktopBuildConfig({
DARKBLOOM_PREVIEW_TEAM_ID: 'ABCDEFGHIJ',
DARKBLOOM_PREVIEW_RUNTIME: '/tmp/runtime',
});
expect(preview.mac?.notarize).toBe(false);
expect(preview.appId).toBe('io.darkbloom.desktop.preview');
});
5 changes: 4 additions & 1 deletion docs/developer/desktop-app.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Build and validate the macOS desktop app

> Last updated: 2026-10-18
> Last updated: 2026-10-23

Build the Electron frontend and its Swift CLI/backend API in this repository.
This guide covers development and review artifacts; production distribution also
Expand Down Expand Up @@ -534,6 +534,9 @@ preview contains explicitly illustrative release notes and version cutoffs.

## Release qualification

Signed, notarized releases are built and published by
`.github/workflows/release-desktop.yml` (tag `desktop-vX.Y.Z`); see
[Release the macOS desktop app](../operations/desktop-release.md).
Before public distribution, verify all of the following against the final
signed frontend and signed provider artifact:

Expand Down
3 changes: 2 additions & 1 deletion docs/operations/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Provider Publication Operations

> Last updated: 2026-10-09
> Last updated: 2026-10-23

Only approved provider/model publication API actions are maintained here. No backend build, deployment or hosting cutover is authorized. Production mutations require specific human approval; use isolated development targets before publication.

- [Migrate a public model to a new build](model-migration.md)
- [Publish new weights for an existing model](model-revisions.md)
- [Release A Provider Version](provider-release.md)
- [Release the macOS desktop app](desktop-release.md)
Loading
Loading