From 33613c7041d5e12c039636fac20016d1eb132b0d Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Wed, 2 Aug 2023 08:56:00 -0700 Subject: [PATCH] fix(electron): check bundle (#3527) --- .github/workflows/build.yml | 3 +- apps/electron/forge.config.js | 106 +++++++++--------- .../scripts/macos-arm64-output-check.mts | 3 +- apps/electron/scripts/unzip-macos-arm64.sh | 16 --- 4 files changed, 58 insertions(+), 70 deletions(-) delete mode 100755 apps/electron/scripts/unzip-macos-arm64.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 50a81bdfc5..de3d480e10 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -431,12 +431,13 @@ jobs: - name: Make bundle if: ${{ matrix.spec.os == 'macos-latest' && matrix.spec.arch == 'arm64' }} + env: + SKIP_BUNDLE: true run: yarn workspace @affine/electron make --platform=darwin --arch=arm64 - name: Bundle output check if: ${{ matrix.spec.os == 'macos-latest' && matrix.spec.arch == 'arm64' }} run: | - ./scripts/unzip-macos-arm64.sh yarn ts-node-esm ./scripts/macos-arm64-output-check.mts working-directory: apps/electron diff --git a/apps/electron/forge.config.js b/apps/electron/forge.config.js index bd974f38ef..3025e798e6 100644 --- a/apps/electron/forge.config.js +++ b/apps/electron/forge.config.js @@ -28,6 +28,59 @@ const arch = const windowsIconUrl = `https://cdn.affine.pro/app-icons/icon_${buildType}.ico`; +const makers = [ + !process.env.SKIP_BUNDLE && { + name: '@affine/maker-dmg', + config: { + format: 'ULFO', + icon: icnsPath, + name: 'AFFiNE', + 'icon-size': 128, + background: path.resolve( + __dirname, + './resources/icons/dmg-background.png' + ), + file: path.resolve( + __dirname, + 'out', + buildType, + `${productName}-darwin-${arch}`, + `${productName}.app` + ), + }, + }, + { + name: '@electron-forge/maker-zip', + config: { + name: 'affine', + iconUrl: icoPath, + setupIcon: icoPath, + platforms: ['darwin', 'linux', 'win32'], + }, + }, + !process.env.SKIP_BUNDLE && { + name: '@electron-forge/maker-squirrel', + config: { + name: 'AFFiNE', + setupIcon: icoPath, + iconUrl: windowsIconUrl, + loadingGif: './resources/icons/affine_installing.gif', + }, + }, + !process.env.SKIP_BUNDLE && { + name: '@reforged/maker-appimage', + config: { + name: 'AFFiNE', + iconUrl: icoPath, + setupIcon: icoPath, + platforms: ['linux'], + options: { + bin: productName, + }, + }, + }, +].filter(Boolean); + /** * @type {import('@electron-forge/shared-types').ForgeConfig} */ @@ -57,58 +110,7 @@ module.exports = { // We need the following line for updater extraResource: ['./resources/app-update.yml'], }, - makers: [ - { - name: '@affine/maker-dmg', - config: { - format: 'ULFO', - icon: icnsPath, - name: 'AFFiNE', - 'icon-size': 128, - background: path.resolve( - __dirname, - './resources/icons/dmg-background.png' - ), - file: path.resolve( - __dirname, - 'out', - buildType, - `${productName}-darwin-${arch}`, - `${productName}.app` - ), - }, - }, - { - name: '@electron-forge/maker-zip', - config: { - name: 'affine', - iconUrl: icoPath, - setupIcon: icoPath, - platforms: ['darwin', 'linux', 'win32'], - }, - }, - { - name: '@electron-forge/maker-squirrel', - config: { - name: 'AFFiNE', - setupIcon: icoPath, - iconUrl: windowsIconUrl, - loadingGif: './resources/icons/affine_installing.gif', - }, - }, - { - name: '@reforged/maker-appimage', - config: { - name: 'AFFiNE', - iconUrl: icoPath, - setupIcon: icoPath, - platforms: ['linux'], - options: { - bin: productName, - }, - }, - }, - ], + makers, hooks: { readPackageJson: async (_, packageJson) => { // we want different package name for canary build diff --git a/apps/electron/scripts/macos-arm64-output-check.mts b/apps/electron/scripts/macos-arm64-output-check.mts index 81c2c8b9e9..550204c60b 100644 --- a/apps/electron/scripts/macos-arm64-output-check.mts +++ b/apps/electron/scripts/macos-arm64-output-check.mts @@ -3,10 +3,11 @@ import { readdir } from 'node:fs/promises'; const outputRoot = fileURLToPath( new URL( - '../zip-out/AFFiNE-canary.app/Contents/Resources/app', + '../out/canary/AFFiNE-canary-darwin-arm64/AFFiNE-canary.app/Contents/Resources/app', import.meta.url ) ); + const outputList = [ [ 'dist', diff --git a/apps/electron/scripts/unzip-macos-arm64.sh b/apps/electron/scripts/unzip-macos-arm64.sh deleted file mode 100755 index 1790fcbd97..0000000000 --- a/apps/electron/scripts/unzip-macos-arm64.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# Set the directory -dir="./out/canary/make/zip/darwin/arm64" - -# Get the first file -file=$(ls -1 $dir | head -n 1) - -# Check if file exists and is a zip file -if [ -f "$dir/$file" ] && [ ${file: -4} == ".zip" ] -then - # Unzip the file - unzip "$dir/$file" -d "zip-out" -else - echo "No zip file found" -fi