|
| 1 | +name: Build Hermes for macOS SPM |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + outputs: |
| 6 | + hermes-version: |
| 7 | + description: "The version of Hermes that was built" |
| 8 | + value: ${{ jobs.prepare_hermes_workspace.outputs.hermes-version }} |
| 9 | + react-native-version: |
| 10 | + description: "The version of React Native" |
| 11 | + value: ${{ jobs.prepare_hermes_workspace.outputs.react-native-version }} |
| 12 | + |
| 13 | +jobs: |
| 14 | + prepare_hermes_workspace: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + env: |
| 17 | + HERMES_WS_DIR: /tmp/hermes |
| 18 | + HERMES_VERSION_FILE: packages/react-native/sdks/.hermesversion |
| 19 | + # Use the Hermes commit at the merge base with facebook/react-native |
| 20 | + HERMES_COMMIT: e0fc67142ec0763c6b6153ca2bf96df815539782 |
| 21 | + outputs: |
| 22 | + react-native-version: ${{ steps.prepare-hermes-workspace.outputs.react-native-version }} |
| 23 | + hermes-version: ${{ steps.prepare-hermes-workspace.outputs.hermes-version }} |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v4 |
| 27 | + - name: Prepare Hermes Workspace |
| 28 | + id: prepare-hermes-workspace |
| 29 | + uses: ./.github/actions/prepare-hermes-workspace |
| 30 | + with: |
| 31 | + hermes-ws-dir: ${{ env.HERMES_WS_DIR }} |
| 32 | + hermes-version-file: ${{ env.HERMES_VERSION_FILE }} |
| 33 | + |
| 34 | + build_hermesc_apple: |
| 35 | + runs-on: macos-14 |
| 36 | + needs: prepare_hermes_workspace |
| 37 | + env: |
| 38 | + HERMES_WS_DIR: /tmp/hermes |
| 39 | + steps: |
| 40 | + - name: Checkout |
| 41 | + uses: actions/checkout@v4 |
| 42 | + - name: Build HermesC Apple |
| 43 | + uses: ./.github/actions/build-hermesc-apple |
| 44 | + with: |
| 45 | + hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} |
| 46 | + react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} |
| 47 | + |
| 48 | + build_macos_slice: |
| 49 | + runs-on: macos-14 |
| 50 | + needs: [build_hermesc_apple, prepare_hermes_workspace] |
| 51 | + env: |
| 52 | + HERMES_WS_DIR: /tmp/hermes |
| 53 | + HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin |
| 54 | + HERMES_OSXBIN_ARTIFACTS_DIR: /tmp/hermes/osx-bin |
| 55 | + MAC_DEPLOYMENT_TARGET: "10.15" |
| 56 | + strategy: |
| 57 | + fail-fast: false |
| 58 | + matrix: |
| 59 | + flavor: [Debug, Release] |
| 60 | + steps: |
| 61 | + - name: Checkout |
| 62 | + uses: actions/checkout@v4 |
| 63 | + - name: Build macOS Slice |
| 64 | + uses: ./.github/actions/build-apple-slices-hermes |
| 65 | + with: |
| 66 | + flavor: ${{ matrix.flavor }} |
| 67 | + slice: macosx |
| 68 | + hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} |
| 69 | + react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} |
| 70 | + |
| 71 | + package_hermes_macos: |
| 72 | + runs-on: macos-14 |
| 73 | + needs: [build_macos_slice, prepare_hermes_workspace] |
| 74 | + env: |
| 75 | + HERMES_WS_DIR: /tmp/hermes |
| 76 | + HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin |
| 77 | + strategy: |
| 78 | + fail-fast: false |
| 79 | + matrix: |
| 80 | + flavor: [Debug, Release] |
| 81 | + steps: |
| 82 | + - name: Checkout |
| 83 | + uses: actions/checkout@v4 |
| 84 | + - name: Setup toolchain |
| 85 | + uses: ./.github/actions/microsoft-setup-toolchain |
| 86 | + with: |
| 87 | + platform: macos |
| 88 | + node-version: '22' |
| 89 | + - name: Download macOS slice |
| 90 | + uses: actions/download-artifact@v4 |
| 91 | + with: |
| 92 | + name: slice-macosx-${{ matrix.flavor }} |
| 93 | + path: ./packages/react-native/sdks/hermes/ |
| 94 | + - name: Unzip slice |
| 95 | + shell: bash |
| 96 | + run: | |
| 97 | + cd ./packages/react-native/sdks/hermes |
| 98 | + tar -xzv -f build_macosx_${{ matrix.flavor }}.tar.gz |
| 99 | + mv build_macosx_${{ matrix.flavor }} build_macosx |
| 100 | + - name: Prepare destroot folder |
| 101 | + shell: bash |
| 102 | + run: | |
| 103 | + cd ./packages/react-native/sdks/hermes || exit 1 |
| 104 | + chmod +x ./utils/build-apple-framework.sh |
| 105 | + . ./utils/build-apple-framework.sh |
| 106 | + prepare_dest_root_for_ci |
| 107 | + - name: Create framework for macOS |
| 108 | + shell: bash |
| 109 | + run: | |
| 110 | + cd ./packages/react-native/sdks/hermes || exit 1 |
| 111 | + echo "[HERMES] Creating the macOS framework" |
| 112 | + chmod +x ./utils/build-ios-framework.sh |
| 113 | + # Only build for macOS, not the full iOS framework |
| 114 | + ./utils/build-ios-framework.sh build_framework |
| 115 | + chmod +x ./destroot/bin/hermesc |
| 116 | + - name: Package Hermes macOS tarball |
| 117 | + shell: bash |
| 118 | + run: | |
| 119 | + BUILD_TYPE="${{ matrix.flavor }}" |
| 120 | + echo "Packaging Hermes for macOS $BUILD_TYPE build type" |
| 121 | +
|
| 122 | + TARBALL_OUTPUT_DIR=$(mktemp -d /tmp/hermes-tarball-output-XXXXXXXX) |
| 123 | +
|
| 124 | + TARBALL_FILENAME=$(node ./packages/react-native/scripts/hermes/get-tarball-name.js --buildType "$BUILD_TYPE") |
| 125 | +
|
| 126 | + TARBALL_OUTPUT_PATH=$(node ./packages/react-native/scripts/hermes/create-tarball.js \ |
| 127 | + --inputDir ./packages/react-native/sdks/hermes \ |
| 128 | + --buildType "$BUILD_TYPE" \ |
| 129 | + --outputDir $TARBALL_OUTPUT_DIR) |
| 130 | +
|
| 131 | + echo "Hermes tarball saved to $TARBALL_OUTPUT_PATH" |
| 132 | +
|
| 133 | + mkdir -p $HERMES_TARBALL_ARTIFACTS_DIR |
| 134 | + cp $TARBALL_OUTPUT_PATH $HERMES_TARBALL_ARTIFACTS_DIR/. |
| 135 | +
|
| 136 | + ls -lh $HERMES_TARBALL_ARTIFACTS_DIR |
| 137 | + - name: Upload Hermes tarball |
| 138 | + uses: actions/upload-artifact@v4.3.4 |
| 139 | + with: |
| 140 | + name: hermes-darwin-bin-${{ matrix.flavor }} |
| 141 | + path: /tmp/hermes/hermes-runtime-darwin/hermes-ios-${{ matrix.flavor }}.tar.gz |
0 commit comments