Skip to content

Commit

Permalink
Add universal builds on macOS (#767)
Browse files Browse the repository at this point in the history
* Create `universal` builds on macOS

* try building separately

* use one build step per arch

* add arch to file name

* Revert "use one build step per arch"

This reverts commit 4d4b398.

* wip

* bump `@filecoin-station/core`

* use after-pack hook to rebuild core

* clean up

* `universal` seems to work!

* undo file name change

* clean up

* update `electron-builder`

* set `x64ArchFiles` (bacalhau arm64 is actually x64)

* fix bacalhau path

* Revert "fix bacalhau path"

This reverts commit f054187.

* Revert "set `x64ArchFiles` (bacalhau arm64 is actually x64)"

This reverts commit 4d974e8.

* disable `USE_HARD_LINKS`
  • Loading branch information
juliangruber authored Jun 15, 2023
1 parent 17cee5e commit 0a612d9
Show file tree
Hide file tree
Showing 5 changed files with 3,216 additions and 903 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ jobs:
APPLEID: ${{ secrets.apple_id }}
APPLEIDPASS: ${{ secrets.apple_id_pass }}
APPLETEAMID: ${{ secrets.apple_team_id }}
USE_HARD_LINKS: false

- name: Show dist/
run: du -sh dist/ && ls -l dist/
Expand Down
46 changes: 46 additions & 0 deletions build/after-pack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'use strict'

const { spawn } = require('node:child_process')
const { platform } = require('node:os')
const assert = require('node:assert')
const { join } = require('node:path')
const { once } = require('node:events')

/** @typedef {import('app-builder-lib').AfterPackContext} AfterPackContext */

/**
* @param {AfterPackContext} context
*/
exports.default = async function (context) {
if (platform() !== 'darwin') return
const arch = context.arch === 1
? 'x64'
: context.arch === 3
? 'arm64'
: context.arch === 4
? 'universal'
: null
if (arch === 'universal') return
assert(arch, `Unknown architecture id: ${context.arch}`)
console.log(`Rebuild Station Core for arch=${arch}`)
const ps = spawn(
'node',
['scripts/post-install.js'],
{
cwd: join(
context.appOutDir,
'Filecoin Station.app',
'Contents',
'Resources',
'core'
),
env: {
...process.env,
TARGET_ARCH: arch
}
}
)
ps.stdout.pipe(process.stdout)
ps.stderr.pipe(process.stderr)
await once(ps, 'exit')
}
5 changes: 3 additions & 2 deletions electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extraResources:
- 'core/**'

beforePack: './build/before-pack.js'
afterPack: './build/after-pack.js'
afterSign: './build/notarize-macos.js'
artifactName: '${productName}.${ext}'

Expand All @@ -28,9 +29,9 @@ mac:
entitlementsInherit: 'build/entitlements.mac.plist'
target:
- target: dmg
arch: ['x64']
arch: ['universal']
- target: zip
arch: ['x64']
arch: ['universal']


dmg:
Expand Down
Loading

0 comments on commit 0a612d9

Please sign in to comment.