Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 148 additions & 0 deletions .github/workflows/build-hermes-macos-spm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: Build Hermes for macOS SPM

on:
workflow_call:
outputs:
hermes-version:
description: "The version of Hermes that was built"
value: ${{ jobs.prepare_hermes_workspace.outputs.hermes-version }}
react-native-version:
description: "The version of React Native"
value: ${{ jobs.prepare_hermes_workspace.outputs.react-native-version }}

jobs:
prepare_hermes_workspace:
runs-on: ubuntu-latest
env:
HERMES_WS_DIR: /tmp/hermes
HERMES_VERSION_FILE: packages/react-native/sdks/.hermesversion
# Use the Hermes commit at the merge base with facebook/react-native
HERMES_COMMIT: e0fc67142ec0763c6b6153ca2bf96df815539782
outputs:
react-native-version: ${{ steps.prepare-hermes-workspace.outputs.react-native-version }}
hermes-version: ${{ steps.prepare-hermes-workspace.outputs.hermes-version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup toolchain
uses: ./.github/actions/microsoft-setup-toolchain
with:
node-version: '22'
cache-npm-dependencies: ''
- name: Install dependencies
run: yarn install
- name: Prepare Hermes Workspace
id: prepare-hermes-workspace
uses: ./.github/actions/prepare-hermes-workspace
with:
hermes-ws-dir: ${{ env.HERMES_WS_DIR }}
hermes-version-file: ${{ env.HERMES_VERSION_FILE }}

build_hermesc_apple:
runs-on: macos-14
needs: prepare_hermes_workspace
env:
HERMES_WS_DIR: /tmp/hermes
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build HermesC Apple
uses: ./.github/actions/build-hermesc-apple
with:
hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }}
react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }}

build_macos_slice:
runs-on: macos-14
needs: [build_hermesc_apple, prepare_hermes_workspace]
env:
HERMES_WS_DIR: /tmp/hermes
HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin
HERMES_OSXBIN_ARTIFACTS_DIR: /tmp/hermes/osx-bin
MAC_DEPLOYMENT_TARGET: "10.15"
strategy:
fail-fast: false
matrix:
flavor: [Debug, Release]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build macOS Slice
uses: ./.github/actions/build-apple-slices-hermes
with:
flavor: ${{ matrix.flavor }}
slice: macosx
hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }}
react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }}

package_hermes_macos:
runs-on: macos-14
needs: [build_macos_slice, prepare_hermes_workspace]
env:
HERMES_WS_DIR: /tmp/hermes
HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin
strategy:
fail-fast: false
matrix:
flavor: [Debug, Release]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup toolchain
uses: ./.github/actions/microsoft-setup-toolchain
with:
platform: macos
node-version: '22'
- name: Download macOS slice
uses: actions/download-artifact@v4
with:
name: slice-macosx-${{ matrix.flavor }}
path: ./packages/react-native/sdks/hermes/
- name: Unzip slice
shell: bash
run: |
cd ./packages/react-native/sdks/hermes
tar -xzv -f build_macosx_${{ matrix.flavor }}.tar.gz
mv build_macosx_${{ matrix.flavor }} build_macosx
- name: Prepare destroot folder
shell: bash
run: |
cd ./packages/react-native/sdks/hermes || exit 1
chmod +x ./utils/build-apple-framework.sh
. ./utils/build-apple-framework.sh
prepare_dest_root_for_ci
- name: Create framework for macOS
shell: bash
run: |
cd ./packages/react-native/sdks/hermes || exit 1
echo "[HERMES] Creating the macOS framework"
chmod +x ./utils/build-ios-framework.sh
# Only build for macOS, not the full iOS framework
./utils/build-ios-framework.sh build_framework
chmod +x ./destroot/bin/hermesc
- name: Package Hermes macOS tarball
shell: bash
run: |
BUILD_TYPE="${{ matrix.flavor }}"
echo "Packaging Hermes for macOS $BUILD_TYPE build type"

TARBALL_OUTPUT_DIR=$(mktemp -d /tmp/hermes-tarball-output-XXXXXXXX)

TARBALL_FILENAME=$(node ./packages/react-native/scripts/hermes/get-tarball-name.js --buildType "$BUILD_TYPE")

TARBALL_OUTPUT_PATH=$(node ./packages/react-native/scripts/hermes/create-tarball.js \
--inputDir ./packages/react-native/sdks/hermes \
--buildType "$BUILD_TYPE" \
--outputDir $TARBALL_OUTPUT_DIR)

echo "Hermes tarball saved to $TARBALL_OUTPUT_PATH"

mkdir -p $HERMES_TARBALL_ARTIFACTS_DIR
cp $TARBALL_OUTPUT_PATH $HERMES_TARBALL_ARTIFACTS_DIR/.

ls -lh $HERMES_TARBALL_ARTIFACTS_DIR
- name: Upload Hermes tarball
uses: actions/upload-artifact@v4.3.4
with:
name: hermes-darwin-bin-${{ matrix.flavor }}
path: /tmp/hermes/hermes-runtime-darwin/hermes-ios-${{ matrix.flavor }}.tar.gz
155 changes: 155 additions & 0 deletions .github/workflows/build-react-native-dependencies-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
name: Build ReactNativeDependencies for PR

on:
workflow_call:

jobs:
prepare_workspace:
name: Prepare workspace
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup toolchain
uses: ./.github/actions/microsoft-setup-toolchain
with:
platform: macos
node-version: '22'
- name: Install dependencies
run: yarn install
- name: Restore cache if present
id: restore-rn-deps
uses: actions/cache/restore@v4
with:
path: packages/react-native/third-party/
key: v2-pr-rn-dependencies-${{ hashfiles('scripts/releases/ios-prebuild/configuration.js') }}
enableCrossOsArchive: true
- name: Prepare Dependencies
if: steps.restore-rn-deps.outputs.cache-hit != 'true'
run: |
node scripts/releases/prepare-ios-prebuilds.js -s
- name: Generate Package.swift
if: steps.restore-rn-deps.outputs.cache-hit != 'true'
run: |
node scripts/releases/prepare-ios-prebuilds.js -w
- name: Upload Artifacts
uses: actions/upload-artifact@v4.3.4
with:
name: rn-deps-workspace
path: packages/react-native/third-party/
- name: Save Cache
uses: actions/cache/save@v4
if: ${{ github.ref == 'refs/heads/main' }}
with:
key: v2-pr-rn-dependencies-${{ hashfiles('scripts/releases/ios-prebuild/configuration.js') }}
enableCrossOsArchive: true
path: packages/react-native/third-party/

build-macos-slice:
name: Build macOS Slice
runs-on: macos-14
needs: [prepare_workspace]
strategy:
fail-fast: false
matrix:
flavor: ['Debug', 'Release']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup toolchain
uses: ./.github/actions/microsoft-setup-toolchain
with:
platform: macos
node-version: '22'
- name: Install dependencies
run: yarn install
- name: Restore slice folder
id: restore-slice-folder
uses: actions/cache/restore@v4
with:
path: packages/react-native/third-party/.build/Build/Products
key: v2-pr-rn-dependencies-slice-macos-${{ matrix.flavor }}-${{ hashfiles('scripts/releases/ios-prebuild/configuration.js') }}
- name: Restore workspace
if: steps.restore-slice-folder.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: rn-deps-workspace
path: packages/react-native/third-party/
- name: Print third-party folder structure
run: ls -lR packages/react-native/third-party
- name: Build slice for macOS ${{ matrix.flavor }}
if: steps.restore-slice-folder.outputs.cache-hit != 'true'
run: node scripts/releases/prepare-ios-prebuilds.js -b -p macos -r ${{ matrix.flavor }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4.3.4
with:
name: prebuild-slice-${{ matrix.flavor }}-macos
path: |
packages/react-native/third-party/.build/Build/Products
- name: Save Cache
uses: actions/cache/save@v4
if: ${{ github.ref == 'refs/heads/main' }}
with:
key: v2-pr-rn-dependencies-slice-macos-${{ matrix.flavor }}-${{ hashfiles('scripts/releases/ios-prebuild/configuration.js') }}
enableCrossOsArchive: true
path: |
packages/react-native/third-party/.build/Build/Products

create-xcframework:
name: Create XCFramework
runs-on: macos-14
needs: [build-macos-slice]
strategy:
fail-fast: false
matrix:
flavor: [Debug, Release]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup toolchain
uses: ./.github/actions/microsoft-setup-toolchain
with:
platform: macos
node-version: '22'
- name: Install dependencies
run: yarn install
- name: Restore XCFramework
id: restore-xcframework
uses: actions/cache/restore@v4
with:
path: |
packages/react-native/third-party/
key: v2-pr-rn-dependencies-xcframework-${{ matrix.flavor }}-${{ hashfiles('scripts/releases/ios-prebuild/configuration.js') }}
- name: Restore workspace
if: steps.restore-xcframework.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: rn-deps-workspace
path: packages/react-native/third-party/
- name: Download slices
if: steps.restore-xcframework.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
pattern: prebuild-slice-${{ matrix.flavor }}-*
path: packages/react-native/third-party/.build/Build/Products
merge-multiple: true
- name: Create XCFramework (unsigned)
if: steps.restore-xcframework.outputs.cache-hit != 'true'
run: node scripts/releases/prepare-ios-prebuilds.js -c -r ${{ matrix.flavor }}
- name: Compress and Rename XCFramework
if: steps.restore-xcframework.outputs.cache-hit != 'true'
run: |
tar -cz -f packages/react-native/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz \
packages/react-native/third-party/ReactNativeDependencies.xcframework
- name: Upload XCFramework Artifact
uses: actions/upload-artifact@v4
with:
name: ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz
path: packages/react-native/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz
- name: Save XCFramework in Cache
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/cache/save@v4
with:
path: |
packages/react-native/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz
key: v2-pr-rn-dependencies-xcframework-${{ matrix.flavor }}-${{ hashfiles('scripts/releases/ios-prebuild/configuration.js') }}
17 changes: 17 additions & 0 deletions .github/workflows/microsoft-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,22 @@ jobs:
permissions: {}
uses: ./.github/workflows/microsoft-build-rntester.yml

build-hermes-macos:
name: "Build Hermes for macOS"
permissions: {}
uses: ./.github/workflows/build-hermes-macos-spm.yml

build-react-native-dependencies:
name: "Build ReactNativeDependencies"
permissions: {}
uses: ./.github/workflows/build-react-native-dependencies-pr.yml

build-spm-macos:
name: "Build SPM macOS"
permissions: {}
needs: [build-hermes-macos, build-react-native-dependencies]
uses: ./.github/workflows/prebuild-macos-core.yml

# https://github.com/microsoft/react-native-macos/issues/2344
# Disable these tests because verdaccio hangs
# test-react-native-macos-init:
Expand All @@ -158,6 +174,7 @@ jobs:
- yarn-constraints
- javascript-tests
- build-rntester
- build-spm-macos
# - test-react-native-macos-init
# - react-native-test-app-integration
steps:
Expand Down
Loading
Loading