Skip to content

fix: separate arm64 and x64 builds for Apple Silicon support#2

Open
Carme99 wants to merge 2 commits intokudosscience:mainfrom
Carme99:main
Open

fix: separate arm64 and x64 builds for Apple Silicon support#2
Carme99 wants to merge 2 commits intokudosscience:mainfrom
Carme99:main

Conversation

@Carme99
Copy link

@Carme99 Carme99 commented Feb 28, 2026

Hi Henry,

Cool looking app! Hope you don't mind me contributing to it!

Summary

  • Split macOS CI into two runners: macos-latest (Intel/x64) and macos-14 (Apple Silicon/arm64)
  • Add --x64/--arm64 flag to download-pdfium.js for cross-compilation
  • Pass arch flag to electron-builder to build only the target architecture
    Problem
    The current CI builds arm64 DMG on an Intel runner (macos-latest), downloads Intel PDFium binaries, and packages them into an arm64 app. This results in an "App is damaged" error when users try to install on Apple Silicon Macs.
    Solution
    Use separate runners for each architecture so each build downloads and uses the correct PDFium binaries:
  • macos-latest → builds x64 DMG with x64 PDFium
  • macos-14 → builds arm64 DMG with arm64 PDFium
    Files Changed
  • .github/workflows/release.yml — split macOS matrix, pass arch flags
  • scripts/download-pdfium.js — add --x64/--arm64 CLI args
  • package.json — update author

Summary by Sourcery

Separate macOS release builds by architecture and ensure each build uses matching PDFium binaries for correct Apple Silicon support.

New Features:

  • Add architecture selection flags (--x64/--arm64) to the PDFium download script to support cross-compilation.

Bug Fixes:

  • Ensure macOS arm64 builds use arm64 PDFium binaries instead of x64 binaries to prevent damaged app errors on Apple Silicon.

Build:

  • Update npm dist command invocation to pass through architecture-specific flags to electron-builder for macOS builds.

CI:

  • Split macOS release workflow into distinct x64 (macos-latest) and arm64 (macos-14) jobs, propagating architecture to download and build steps, and arch-specific artifact naming.

Chores:

  • Set the package author field in package.json.

Summary by CodeRabbit

  • New Features

    • Added native Apple Silicon (arm64) support for macOS builds, providing optimized installers for arm64 and x64 Macs.
  • Chores

    • CI/build pipeline now produces architecture-specific macOS installers and artifact names and supports selecting architecture for downloads and packaging.
    • Updated project author metadata.

- Split macOS CI into two runners: macos-latest (x64) and macos-14 (arm64)
- Add --x64/--arm64 flag to download-pdfium.js for cross-compilation
- Pass arch flag to electron-builder to build only target arch
- Update author: Carme99
@sourcery-ai
Copy link

sourcery-ai bot commented Feb 28, 2026

Reviewer's Guide

Separates macOS CI builds into distinct x64 and arm64 jobs for Apple Silicon support, adds architecture flags to the PDFium download script and electron-builder invocation, and updates the package author metadata.

File-Level Changes

Change Details Files
Add architecture selection to PDFium download script to support cross-compilation.
  • Extend CLI usage string to document optional --x64/--arm64 flags.
  • Parse command-line arguments to determine desired target architecture with a default of process.arch.
  • Build the PDFium platform key from process.platform and the selected architecture instead of process.arch directly.
  • Fallback to existing behavior when no architecture flag is provided.
scripts/download-pdfium.js
Split macOS CI release workflow into separate x64 and arm64 builds and propagate architecture through the pipeline.
  • Extend the workflow matrix with separate macos-latest (x64) and macos-14 (arm64) mac targets, each with its own DMG artifact pattern.
  • Pass the matrix architecture flag into the PDFium download script as a CLI argument for correct binary selection.
  • Adjust the installer build step to forward an architecture flag to the electron-builder npm script so it only builds the target architecture.
  • Include architecture in the uploaded artifact name to distinguish x64 and arm64 outputs.
.github/workflows/release.yml
Update package metadata author field.
  • Set the package.json author field to "Carme99".
package.json

Possibly linked issues

  • #Apple Silicon Build is corrupt: Yes. PR fixes Apple Silicon corruption by building arm64 DMG on arm runner with matching PDFium binaries.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link

coderabbitai bot commented Feb 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 706147e and 1de463c.

📒 Files selected for processing (1)
  • .github/workflows/release.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/release.yml

📝 Walkthrough

Walkthrough

Adds macOS x64 and arm64 build matrix entries, propagates architecture flags through CI build and artifact naming, updates PDFium download script to accept arch overrides, and sets package author to "Carme99".

Changes

Cohort / File(s) Summary
CI/CD Workflow Architecture Support
.github/workflows/release.yml
Added macOS matrix entries for x64 and arm64; pass arch flags to PDFium download and dist steps; include architecture in installer artifact names.
Build Script Enhancement
scripts/download-pdfium.js
Added CLI flags to override architecture (--x64, --arm64); introduce arch override variable; compute platform key as ${process.platform}-${arch} when selecting binaries.
Package Metadata
package.json
Updated author field from an empty string to "Carme99".

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hop through builds with a twitch and a grin,
mac x64 and arm64 now both join the spin.
Scripts take my flags, downloads neatly align,
Carme99 signs the package — that prize is mine! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: adding architecture-specific builds for Apple Silicon support on macOS, which directly addresses the cross-compilation issue described in the PR objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 3 issues, and left some high level feedback:

  • In the workflow matrix, arch is only defined for the macOS entries, but you unconditionally use ${{ matrix.arch }} in the Download PDFium binaries step and in the artifact name; this will be undefined for Linux/Windows runs and should either be given a default arch for those entries or the step/path should be made conditional on matrix.platform == 'mac'.
  • The Build installer step uses the condition ${{ matrix.arch == 'mac' && ... }}, but arch is set to x64/arm64 while platform is mac; this condition will never be true, so the arch flag is not passed—update the condition to check matrix.platform == 'mac' instead.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the workflow matrix, `arch` is only defined for the macOS entries, but you unconditionally use `${{ matrix.arch }}` in the `Download PDFium binaries` step and in the artifact name; this will be undefined for Linux/Windows runs and should either be given a default arch for those entries or the step/path should be made conditional on `matrix.platform == 'mac'`.
- The `Build installer` step uses the condition `${{ matrix.arch == 'mac' && ... }}`, but `arch` is set to `x64`/`arm64` while `platform` is `mac`; this condition will never be true, so the arch flag is not passed—update the condition to check `matrix.platform == 'mac'` instead.

## Individual Comments

### Comment 1
<location path=".github/workflows/release.yml" line_range="57" />
<code_context>

       - name: Build installer
-        run: npm run dist:${{ matrix.platform }}
+        run: npm run dist:${{ matrix.platform }} ${{ matrix.arch == 'mac' && format('-- --{0}', matrix.arch) || '' }}
         env:
           GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
</code_context>
<issue_to_address>
**issue (bug_risk):** GitHub Actions condition likely compares the wrong field (`matrix.arch` vs `matrix.platform`) for mac-specific args

`matrix.arch == 'mac'` looks incorrect. To pass `-- --x64/arm64` only for mac builds, this should probably be `matrix.platform == 'mac' && format('-- --{0}', matrix.arch)`. As written, no matrix entry will have `arch == 'mac'`, so the extra args are never applied.
</issue_to_address>

### Comment 2
<location path=".github/workflows/release.yml" line_range="64" />
<code_context>
         uses: actions/upload-artifact@v4
         with:
-          name: installer-${{ matrix.platform }}
+          name: installer-${{ matrix.platform }}-${{ matrix.arch }}
           path: |
             release/*.exe
</code_context>
<issue_to_address>
**issue:** Artifact name may include an empty or `null` arch segment for non-mac jobs

Non-mac matrix entries don’t define `arch`, so this will likely produce names like `installer-win-` or `installer-linux-` (or `null`). To avoid inconsistent or confusing artifact names, either add explicit `arch` values for all platforms (e.g., `x64`), or append `-${{ matrix.arch }}` only when it’s defined.
</issue_to_address>

### Comment 3
<location path=".github/workflows/release.yml" line_range="47-48" />
<code_context>

       - name: Download PDFium binaries
-        run: node scripts/download-pdfium.js
+        run: node scripts/download-pdfium.js --${{ matrix.arch }}

       - name: Build native addon
</code_context>
<issue_to_address>
**suggestion:** Passing `--${{ matrix.arch }}` when `arch` is undefined leads to a stray `--` argument

For non-mac runs `matrix.arch` is empty, so this becomes `node scripts/download-pdfium.js --`. While the script ignores the flag, this is misleading and may confuse future maintainers. Consider conditionally adding the flag, e.g. `node scripts/download-pdfium.js ${{ matrix.arch && format('--{0}', matrix.arch) || '' }}`, or using separate steps for mac vs non-mac.

```suggestion
      - name: Download PDFium binaries
        run: node scripts/download-pdfium.js ${{ matrix.arch && format('--{0}', matrix.arch) || '' }}
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 706147e763

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


- name: Build installer
run: npm run dist:${{ matrix.platform }}
run: npm run dist:${{ matrix.platform }} ${{ matrix.arch == 'mac' && format('-- --{0}', matrix.arch) || '' }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Check matrix.platform before appending mac arch flag

The Build installer command never adds --x64/--arm64 because the guard compares matrix.arch to 'mac', but matrix.arch is set to x64 or arm64 in the mac matrix entries (and unset elsewhere). As written, the expression is always false, so this change does not actually forward the architecture flag and the workflow can still produce mac artifacts without the intended per-arch restriction.

Useful? React with 👍 / 👎.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/release.yml (1)

17-22: ⚠️ Potential issue | 🟡 Minor

Add explicit arch to Windows and Linux matrix entries.

Windows and Linux entries don't define arch, causing:

  1. Line 48: --${{ matrix.arch }} expands to -- (an empty flag)
  2. Line 64: Artifact names become installer-win- and installer-linux- with trailing hyphens

While the download script happens to fall back to process.arch, this is implicit and fragile.

🔧 Proposed fix
         include:
           - os: windows-latest
             platform: win
+            arch: x64
             artifact: release/*.exe
           - os: ubuntu-latest
             platform: linux
+            arch: x64
             artifact: release/*.AppImage
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/release.yml around lines 17 - 22, The matrix entries for
"os: windows-latest" and "os: ubuntu-latest" are missing an explicit arch, which
makes "${{ matrix.arch }}" expand empty (producing a stray "--" flag and
trailing hyphens in artifact names); update those matrix items by adding an
appropriate "arch" key (e.g., arch: x64 or arch: arm64 as required) for the
Windows and Linux entries so matrix.arch is defined and artifact names
(installer-win-..., installer-linux-...) and the CLI flag (--${{ matrix.arch }})
render correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/release.yml:
- Line 57: The conditional in the release workflow uses the wrong variable:
replace the check matrix.arch == 'mac' with matrix.platform == 'mac' so the
architecture flag is passed for mac builds; update the run command that invokes
npm run dist:${{ matrix.platform }} to use ${{ matrix.platform == 'mac' &&
format('-- --{0}', matrix.arch) || '' }} (keeping matrix.arch for the format
argument) so mac jobs receive the correct -- --{arch} flag.

---

Outside diff comments:
In @.github/workflows/release.yml:
- Around line 17-22: The matrix entries for "os: windows-latest" and "os:
ubuntu-latest" are missing an explicit arch, which makes "${{ matrix.arch }}"
expand empty (producing a stray "--" flag and trailing hyphens in artifact
names); update those matrix items by adding an appropriate "arch" key (e.g.,
arch: x64 or arch: arm64 as required) for the Windows and Linux entries so
matrix.arch is defined and artifact names (installer-win-...,
installer-linux-...) and the CLI flag (--${{ matrix.arch }}) render correctly.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4164274 and 706147e.

📒 Files selected for processing (3)
  • .github/workflows/release.yml
  • package.json
  • scripts/download-pdfium.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant