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
50 changes: 44 additions & 6 deletions .github/workflows/cookiemonster-desktop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: cookiemonster-desktop
run-name: CookieMonster V2 beta ${{ inputs.beta }} (macOS arm64)
run-name: CookieMonster V2 ${{ inputs.version || inputs.beta }} (macOS arm64)

on:
workflow_dispatch:
Expand All @@ -14,6 +14,11 @@ on:
required: true
default: false
type: boolean
version:
description: "Production WPP version, for example 2.0.29-cm.2; leave empty for beta"
required: false
default: ""
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -24,7 +29,7 @@ permissions:

jobs:
package:
name: signed macOS arm64 beta
name: signed macOS arm64
runs-on: macos-latest
timeout-minutes: 30
permissions:
Expand All @@ -33,7 +38,7 @@ jobs:
run:
shell: bash
env:
OPENCODE_CHANNEL: beta
OPENCODE_CHANNEL: ${{ inputs.version != '' && 'prod' || 'beta' }}
OPENCODE_CLI_TARGET: aarch64-apple-darwin
OPENCODE_CLI_DIST: ${{ github.workspace }}/packages/cli/dist
CM_BRAND: "1"
Expand All @@ -43,9 +48,11 @@ jobs:
- name: Checkout release source
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1

- name: Resolve beta version
- name: Resolve build version
env:
BETA_NUMBER: ${{ inputs.beta }}
RELEASE_VERSION: ${{ inputs.version }}
PUBLISH: ${{ inputs.publish }}
run: |
test "$RUNNER_ARCH" = ARM64
if [[ ! "$BETA_NUMBER" =~ ^[1-9][0-9]*$ ]]; then
Expand All @@ -54,6 +61,13 @@ jobs:
fi
base=$(node -p "require('./packages/desktop/package.json').version")
version="${base}-beta.${BETA_NUMBER}"
if [[ -n "$RELEASE_VERSION" ]]; then
if [[ ! "$RELEASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+-cm\.[1-9][0-9]*$ || "$RELEASE_VERSION" != "$base"-cm.* || "$PUBLISH" == true ]]; then
echo "Production builds require a matching CM version and publish=false; publish all platforms together." >&2
exit 1
fi
version="$RELEASE_VERSION"
fi
echo "CM_VERSION=$version" >> "$GITHUB_ENV"
echo "OPENCODE_VERSION=$version" >> "$GITHUB_ENV"
echo "RELEASE_TAG=cookiemonster-v$version" >> "$GITHUB_ENV"
Expand All @@ -78,6 +92,7 @@ jobs:
run: bun run build

- name: Test installer configuration and user installation
if: inputs.version == ''
timeout-minutes: 2
working-directory: packages/desktop
env:
Expand All @@ -88,6 +103,7 @@ jobs:
run: bun test --preload ./test/preload.ts --timeout 20000 electron-builder.config.test.ts src/main/macos-user-install.test.ts

- name: Verify pinned WPP backend and host contracts
if: inputs.version == ''
timeout-minutes: 3
run: |
bun run --cwd packages/desktop/wpp/node_modules/@cookiemonster/wpp test
Expand Down Expand Up @@ -116,7 +132,7 @@ jobs:
APPLE_API_KEY: ${{ runner.temp }}/apple-api-key.p8
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
run: bunx electron-builder --mac dmg --arm64 --publish never --config electron-builder.config.ts -c.forceCodeSigning=true -c.dmg.sign=true
run: bunx electron-builder --mac dmg zip --arm64 --publish never --config electron-builder.config.ts -c.forceCodeSigning=true -c.dmg.sign=true

- name: Notarize and staple the installer
timeout-minutes: 8
Expand All @@ -132,6 +148,24 @@ jobs:
if: always()
run: rm -f "$RUNNER_TEMP/apple-api-key.p8"

- name: Refresh update checksums after stapling
run: |
bun -e '
import { createHash } from "node:crypto"
import { join } from "node:path"
const root = "packages/desktop/dist"
const path = join(root, "latest-mac.yml")
const data = Bun.YAML.parse(await Bun.file(path).text())
for (const item of data.files) {
const bytes = await Bun.file(join(root, item.url)).bytes()
item.size = bytes.length
item.sha512 = createHash("sha512").update(bytes).digest("base64")
}
const primary = data.files.find(item => item.url === data.path)
if (primary) data.sha512 = primary.sha512
await Bun.write(path, Bun.YAML.stringify(data))
'

- name: Verify the mounted installer and both versions
timeout-minutes: 3
run: |
Expand All @@ -153,6 +187,7 @@ jobs:
test "$(cat "$app/Contents/Resources/opencode-cli.version")" = "$CM_VERSION"
cd packages/desktop/dist
shasum -a 256 cookiemonster-mac-arm64.dmg > SHA256SUMS.txt
shasum -a 256 cookiemonster-mac-arm64.zip >> SHA256SUMS.txt

- name: Verify packaged macOS activation with a hidden worker
timeout-minutes: 3
Expand All @@ -170,9 +205,12 @@ jobs:
timeout-minutes: 3
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: cookiemonster-macos-arm64-beta
name: ${{ inputs.version != '' && 'cookiemonster-macos-arm64-release' || 'cookiemonster-macos-arm64-beta' }}
path: |
packages/desktop/dist/cookiemonster-mac-arm64.dmg
packages/desktop/dist/cookiemonster-mac-arm64.zip
packages/desktop/dist/cookiemonster-mac-arm64.zip.blockmap
packages/desktop/dist/latest-mac.yml
packages/desktop/dist/SHA256SUMS.txt
if-no-files-found: error
retention-days: 7
Expand Down
107 changes: 107 additions & 0 deletions .github/workflows/cookiemonster-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: cookiemonster-windows
run-name: CookieMonster V2 ${{ inputs.version }} (Windows x64)

on:
workflow_dispatch:
inputs:
version:
description: "Production WPP version"
required: true
default: "2.0.29-cm.2"
type: string

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

permissions:
contents: read

jobs:
package:
runs-on: windows-2022
timeout-minutes: 40
defaults:
run:
shell: bash
env:
OPENCODE_CHANNEL: prod
OPENCODE_CLI_TARGET: x86_64-pc-windows-msvc
OPENCODE_CLI_DIST: ${{ github.workspace }}/packages/cli/dist
CM_BRAND: "1"
CM_WPP: "1"
CM_UNSIGNED: "1"
steps:
- name: Checkout release source
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1

- name: Resolve release version
env:
RELEASE_VERSION: ${{ inputs.version }}
run: |
base=$(node -p "require('./packages/desktop/package.json').version")
if [[ ! "$RELEASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+-cm\.[1-9][0-9]*$ || "$RELEASE_VERSION" != "$base"-cm.* ]]; then
echo "Production version must match the desktop base version." >&2
exit 1
fi
echo "CM_VERSION=$RELEASE_VERSION" >> "$GITHUB_ENV"
echo "OPENCODE_VERSION=$RELEASE_VERSION" >> "$GITHUB_ENV"

- name: Setup Bun and dependencies
timeout-minutes: 8
uses: ./.github/actions/setup-bun
with:
wpp-ssh-key: ${{ secrets.CM_WPP_SSH_KEY }}

- name: Build matching V2 CLI
timeout-minutes: 8
run: |
bun packages/cli/script/build.ts --target=opencode-windows-x64-baseline --skip-install
test "$(packages/cli/dist/cli-windows-x64-baseline/bin/opencode.exe --version)" = "opencode v$CM_VERSION"

- name: Build WPP desktop
timeout-minutes: 6
working-directory: packages/desktop
env:
NODE_OPTIONS: --max-old-space-size=4096
run: bun run build

- name: Package Windows x64 installer
timeout-minutes: 8
working-directory: packages/desktop
run: bun run package:win --x64 --publish never

- name: Verify packaged version and required resources
working-directory: packages/desktop
run: |
node --input-type=module <<'JS'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
import { existsSync, readFileSync } from 'node:fs'
const require = createRequire(process.cwd() + '/package.json')
const builder = createRequire(require.resolve('app-builder-lib/package.json'))
const asar = builder('@electron/asar')
const root = 'dist/win-unpacked/resources'
const manifest = JSON.parse(asar.extractFile(root + '/app.asar', 'package.json'))
assert.equal(manifest.version, process.env.CM_VERSION)
assert.equal(readFileSync(root + '/opencode-cli.version', 'utf8').trim(), process.env.CM_VERSION)
for (const file of ['opencode-cli.exe', 'cm-plugins/provider/index.mjs', 'cm-plugins/browser/index.mjs', 'cm-plugins/figma/index.mjs', 'vault-auth/windows-x64.exe', 'vault-auth/windows-entry-x64.exe'])
assert(existsSync(root + '/' + file), file)
assert(readFileSync('dist/latest.yml', 'utf8').includes('version: ' + process.env.CM_VERSION))
console.log(JSON.stringify({ result: 'pass', version: manifest.version, wpp: true }))
JS
test "$(dist/win-unpacked/resources/opencode-cli.exe --version)" = "opencode v$CM_VERSION"
cd dist
sha256sum cookiemonster-win-x64.exe > SHA256SUMS.txt

- name: Upload release assets
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: cookiemonster-windows-x64-release
path: |
packages/desktop/dist/cookiemonster-win-x64.exe
packages/desktop/dist/cookiemonster-win-x64.exe.blockmap
packages/desktop/dist/latest.yml
packages/desktop/dist/SHA256SUMS.txt
if-no-files-found: error
retention-days: 7
8 changes: 6 additions & 2 deletions packages/gui-extensions/src/updater/migration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ test.each([
["CookieMonster", "darwin", "prod", false, false, true],
["CookieMonster", "darwin", "dev", true, false, true],
["CookieMonster", "darwin", "beta", true, false, true],
["CookieMonster", "linux", "prod", true, false, true],
["CookieMonster", "win32", "prod", true, false, true],
["CookieMonster", "linux", "prod", true, true, true],
["CookieMonster", "win32", "prod", true, true, true],
["CookieMonster", "linux", "prod", false, false, true],
["CookieMonster", "win32", "prod", false, false, true],
["CookieMonster", "linux", "beta", true, false, true],
["CookieMonster", "win32", "dev", true, false, true],
["OpenCode", "darwin", "prod", true, true, false],
["OpenCode Beta", "darwin", "beta", true, true, false],
["OpenCode Dev", "linux", "dev", true, false, false],
Expand Down
5 changes: 4 additions & 1 deletion packages/gui-extensions/src/updater/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export function requiresStableMacInstaller(platform: string, channel: string) {
return platform === "darwin" && channel === "beta"
}

// SAFETY: Update responses are untrusted; this boundary decodes Artifact before reading its fields.
// oxlint-disable-next-line anti-slop/no-unknown-parameters -- see SAFETY above
export function stableMacDownload(input: unknown, arch: string) {
if (arch !== "arm64" && arch !== "x64") return undefined
const artifact = Option.getOrUndefined(decode(input))
Expand All @@ -25,7 +27,8 @@ export function updatePolicy(name: string, platform: string, channel: string, pa
const branded = name === "CookieMonster"

return {
enabled: packaged && (branded ? platform === "darwin" && channel === "prod" : channel !== "dev"),
enabled:
packaged && (branded ? ["darwin", "win32", "linux"].includes(platform) && channel === "prod" : channel !== "dev"),
prerelease: branded,
}
}
Loading