Skip to content

Commit

Permalink
chore: enhance macOS release workflow with universal binary support a…
Browse files Browse the repository at this point in the history
…nd architecture detection
  • Loading branch information
truemiller committed Jan 23, 2025
1 parent fe966b3 commit c313f89
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 46 deletions.
60 changes: 25 additions & 35 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-14, macos-14-large]

include:
- os: macos-14
arch: arm64
- os: macos-14-large
arch: x64
- os: macos-14
arch: universal
steps:
- uses: actions/checkout@v3

Expand All @@ -36,14 +41,9 @@ jobs:
virtualenvs-path: ~/my-custom-path
installer-parallel: true

# Set OS_ARCH env
# Set architecture environment variable
- name: Set architecture environment variable
run: |
if [ "${{ matrix.os }}" == "macos-14-large" ]; then
echo "OS_ARCH=x64" >> $GITHUB_ENV;
else
echo "OS_ARCH=arm64" >> $GITHUB_ENV;
fi
run: echo "OS_ARCH=${{ matrix.arch }}" >> $GITHUB_ENV

# Cache Poetry dependencies with unique key for each environment and architecture
- name: Cache Poetry dependencies
Expand Down Expand Up @@ -83,8 +83,8 @@ jobs:
- name: Upload Release Assets
uses: actions/upload-artifact@v4
with:
name: pearl_${{ env.OS_ARCH }}
path: dist/pearl_${{ env.OS_ARCH }}
name: pearl_${{ matrix.arch }}
path: dist/pearl_${{ matrix.arch }}

- name: Upload Tendermint
uses: actions/upload-artifact@v4
Expand All @@ -103,8 +103,16 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
env: [production, development]
os: [macos-14, macos-14-large]
include:
- os: macos-14
env: production
arch: universal
- os: macos-14-large
env: production
arch: x64
- os: macos-14
env: production
arch: arm64

needs: build-macos-pyinstaller

Expand All @@ -123,14 +131,12 @@ jobs:
yarn config set network-retries 10 # Retry up to 10 times
yarn config set network-concurrency 2 # Reduce concurrency to 2 connections
# Set OS_ARCH env
# Set architecture environment variable
- name: Set architecture environment variable
run: |
if [ "${{ matrix.os }}" == "macos-14-large" ]; then
echo "OS_ARCH=x64" >> $GITHUB_ENV;
else
echo "OS_ARCH=arm64" >> $GITHUB_ENV;
fi
echo "OS_ARCH=${{ matrix.arch }}" >> $GITHUB_ENV
echo "ARCH=${{ matrix.arch }}" >> $GITHUB_ENV
# Download the appropriate architecture artifact
- name: Download Pearl binary for architecture
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -252,19 +258,3 @@ jobs:
echo "DEV_RPC=https://virtual.gnosis.rpc.tenderly.co/80ff70d1-71fd-4c9e-9402-913f0c4c58b0" >> .env
echo "FORK_URL=https://virtual.gnosis.rpc.tenderly.co/80ff70d1-71fd-4c9e-9402-913f0c4c58b0" >> .env
node build.js
# Run universal build for both architectures (better legacy support)
- name: Build with electron-builder (Universal Production)
if: matrix.env == 'production' && matrix.os == 'macos-14'
env:
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLEIDPASS }}
APPLE_ID: ${{ secrets.APPLEID }}
APPLE_TEAM_ID: ${{ secrets.APPLETEAMID }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
CSC_LINK: ${{ secrets.CSC_LINK }}
GH_TOKEN: ${{ secrets.github_token }}
NODE_ENV: ${{ matrix.env }}
ARCH: "universal"
DEV_RPC: https://rpc-gate.autonolas.tech/gnosis-rpc/
FORK_URL: https://rpc-gate.autonolas.tech/gnosis-rpc/
run: node build.js
26 changes: 15 additions & 11 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,17 @@ function artifactName() {

const main = async () => {
console.log('Building...');

/** @type import {CliOptions} from "electron-builder" */

const macTarget = process.env.ARCH === 'universal' ? {
target: 'dmg',
arch: ['arm64', 'x64'],
artifactName: '${productName}-${version}-${platform}-universal.${ext}'
} : {
target: 'dmg',
arch: [process.env.ARCH],
artifactName: '${productName}-${version}-${platform}-${arch}.${ext}'
};

await build({
publish: 'onTag',
config: {
Expand All @@ -32,7 +41,7 @@ const main = async () => {
},
extraResources: [
{
from: 'electron/bins',
from: process.env.ARCH === 'universal' ? 'electron/bins' : 'electron/bins',
to: 'bins',
filter: ['**/*'],
},
Expand All @@ -41,15 +50,10 @@ const main = async () => {
to: '.env'
},
],
cscKeyPassword: process.env.CSC_KEY_PASSWORD,
cscKeyPassword: process.env.CSC_KEY_PASSWORD,
cscLink: process.env.CSC_LINK,
mac: {
target: [
{
target: 'dmg',
arch: [process.env.ARCH], // ARCH env is set during release CI
},
],
target: [macTarget],
publish: publishOptions,
category: 'public.app-category.utilities',
icon: 'electron/assets/icons/splash-robot-head-dock.png',
Expand All @@ -60,7 +64,7 @@ const main = async () => {
},
},
});
};
};

main().then(() => {
console.log('Build & Notarize complete');
Expand Down
14 changes: 14 additions & 0 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,25 @@ const binaryPaths = {
darwin: {
arm64: 'bins/pearl_arm64',
x64: 'bins/pearl_x64',
universal: 'bins/pearl_universal', // Add universal binary support
},
win32: {
x64: 'bins/pearl_win.exe',
},
};

// Add architecture detection
const getArchitecture = () => {
if (platform === 'darwin') {
// Check for universal binary first
if (fs.existsSync(path.join(__dirname, binaryPaths.darwin.universal))) {
return 'universal';
}
return process.arch === 'arm64' ? 'arm64' : 'x64';
}
return process.arch === 'x64' ? 'x64' : process.arch;
};

let appConfig = {
ports: {
dev: {
Expand All @@ -60,6 +73,7 @@ let appConfig = {
next: 3000,
},
},
architecture: getArchitecture(), // Add architecture to config
};

/** @type {Electron.BrowserWindow | null} */
Expand Down

0 comments on commit c313f89

Please sign in to comment.