Skip to content

Build Node binaries for macOS #2

Build Node binaries for macOS

Build Node binaries for macOS #2

Workflow file for this run

name: Build Node binaries for macOS
on:
workflow_dispatch:
workflow_call:
jobs:
macos-x64:
runs-on: macos-13
strategy:
fail-fast: false
matrix:
target-node: [18, 20, 22]
steps:
- uses: actions/checkout@v4
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Check arch is x64
run: |
if [[ $(uname -m) != "x86_64" ]]; then
echo "This job should run on x64 architecture"
exit 1
fi
- run: yarn install --ignore-engines
# add missing distutils package to python 3.12
- name: Install distutils
run: |
pip install setuptools
- run: yarn start --node-range node${{ matrix.target-node }} --output dist
env:
MAKE_JOB_COUNT: 2 # prevent to run out of memory
- name: Check if binary is compiled, skip if download only
id: check_file
run: |
ls -l dist
(test -f dist/*.sha256sum && echo "EXISTS=true" >> $GITHUB_OUTPUT) || echo "EXISTS=false" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
if: steps.check_file.outputs.EXISTS == 'true'
with:
name: node${{ matrix.target-node }}-macos-x64
path: dist/*
macos-arm64:
runs-on: macos-14 # macos-14 is arm64: https://github.com/actions/runner-images#available-images
strategy:
fail-fast: false
matrix:
target-node: [18, 20, 22]
steps:
- uses: actions/checkout@v4
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Check arch is arm64
run: |
if [[ $(uname -m) != "arm64" ]]; then
echo "This job should run on arm64 architecture"
exit 1
fi
- run: yarn install --ignore-engines
# add missing distutils package to python 3.12
- name: Install distutils
run: brew install python-setuptools
# Remove unneeded stuff to free up build space (from Node https://github.com/nodejs/build/issues/3878)
- name: Cleanup before build
run: |
sudo rm -rf /Users/runner/Library/Android/sdk
sudo rm -rf /Users/runner/Library/Developer/CoreSimulator/Caches
echo "::group::Free space after cleanup"
df -h
echo "::endgroup::"
- run: yarn start --node-range node${{ matrix.target-node }} --arch arm64 --output dist
env:
MAKE_JOB_COUNT: 2 # prevent to run out of memory
- name: Check if binary is compiled
id: check_file
run: |
ls -l dist
(test -f dist/*.sha256sum && echo "EXISTS=true" >> $GITHUB_OUTPUT) || echo "EXISTS=false" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
if: steps.check_file.outputs.EXISTS == 'true'
with:
name: node${{ matrix.target-node }}-macos-arm64
path: dist/*