/
githubmirror
/
react-native
Обзор
Документация
Войти
/
githubmirror
/
react-native
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
.github/workflows/prebuild-ios-core.yml
270 строк
15 KB
Christian Falch
fix(iOS): stage Hermes headers in prebuild compose job so ReactNativeHeaders resolves <hermes/...> (#57661)
27 июл 2026, 16:30
27 июл 2026, 16:30
43b44ed
Код
Авторство
О чём код?
name: Prebuild iOS Core on: workflow_call: # this directive allow us to call this workflow from other workflows inputs: version-type: description: 'The version type to set for the prebuild (nightly or release)' type: string required: false default: '' use-hermes-prebuilt: description: 'Whether to resolve Hermes from the latest-v1 npm dist-tag (true) or from the version pinned in version.properties (false)' type: boolean required: false default: false jobs: build-rn-slice: runs-on: macos-15 strategy: fail-fast: false matrix: flavor: ['Debug', 'Release'] slice: ['ios', 'ios-simulator', 'mac-catalyst'] steps: - name: Checkout uses: actions/checkout@v6 - name: Restore cache if present id: restore-ios-slice uses: actions/cache/restore@v5 with: key: v3-ios-core-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift', 'packages/react-native/scripts/ios-prebuild/*.js', 'packages/react-native/scripts/ios-prebuild.js', 'packages/react-native/React/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*') }} path: packages/react-native/ - name: Setup node.js if: steps.restore-ios-slice.outputs.cache-hit != 'true' uses: ./.github/actions/setup-node - name: Setup xcode if: steps.restore-ios-slice.outputs.cache-hit != 'true' uses: ./.github/actions/setup-xcode - name: Yarn Install if: steps.restore-ios-slice.outputs.cache-hit != 'true' uses: ./.github/actions/yarn-install - name: Set Hermes version shell: bash run: | # Non-stable RN builds resolve Hermes from npm's latest-v1 dist-tag. # TODO: rename 'latest-v1' to 'latest' once V1 is the only Hermes on npm. # Stable builds use the version pinned in version.properties. if [ "${{ inputs.use-hermes-prebuilt }}" == "true" ]; then HERMES_VERSION="latest-v1" else HERMES_VERSION=$(sed -n 's/^HERMES_VERSION_NAME=//p' packages/react-native/sdks/hermes-engine/version.properties) fi echo "Using Hermes version: $HERMES_VERSION" echo "HERMES_VERSION=$HERMES_VERSION" >> $GITHUB_ENV - name: Set React Native version shell: bash run: | if [ "${{ inputs.version-type }}" != "" ]; then node ./scripts/releases/set-rn-artifacts-version.js --build-type "${{ inputs.version-type }}" fi - name: Download ReactNativeDependencies uses: actions/download-artifact@v7 with: name: ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz path: /tmp/third-party/ - name: Extract ReactNativeDependencies if: steps.restore-ios-slice.outputs.cache-hit != 'true' shell: bash run: | # Extract ReactNativeDependencies tar -xzf /tmp/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz -C /tmp/third-party/ # Create destination folder mkdir -p packages/react-native/third-party/ # Move the XCFramework in the destination directory mv /tmp/third-party/packages/react-native/third-party/ReactNativeDependencies.xcframework packages/react-native/third-party/ReactNativeDependencies.xcframework VERSION=$(jq -r '.version' packages/react-native/package.json) echo "$VERSION-${{matrix.flavor}}" > "packages/react-native/third-party/version.txt" cat "packages/react-native/third-party/version.txt" # Check destination directory ls -lR packages/react-native/third-party/ - name: Setup the workspace if: steps.restore-ios-slice.outputs.cache-hit != 'true' shell: bash run: | cd packages/react-native node scripts/ios-prebuild.js -s -f "${{ matrix.flavor }}" - name: Build React Native if: steps.restore-ios-slice.outputs.cache-hit != 'true' shell: bash run: | # This is going to be replaced by a CLI script cd packages/react-native node scripts/ios-prebuild -b -f "${{ matrix.flavor }}" -p "${{ matrix.slice }}" - name: Upload headers uses: actions/upload-artifact@v6 with: name: prebuild-ios-core-headers-${{ matrix.flavor }}-${{ matrix.slice }} path: packages/react-native/.build/headers - name: Upload artifacts uses: actions/upload-artifact@v6 with: name: prebuild-ios-core-slice-${{ matrix.flavor }}-${{ matrix.slice }} path: | packages/react-native/.build/output/spm/${{ matrix.flavor }}/Build/Products - name: Save Cache uses: actions/cache/save@v5 if: ${{ github.ref == 'refs/heads/main' }} # To avoid that the cache explode with: key: v3-ios-core-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift', 'packages/react-native/scripts/ios-prebuild/*.js', 'packages/react-native/scripts/ios-prebuild.js', 'packages/react-native/React/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*') }} path: | packages/react-native/.build/output/spm/${{ matrix.flavor }}/Build/Products packages/react-native/.build/headers compose-xcframework: runs-on: macos-15 needs: [build-rn-slice] strategy: fail-fast: false matrix: flavor: ['Debug', 'Release'] env: REACT_ORG_CODE_SIGNING_P12_CERT: ${{ secrets.REACT_ORG_CODE_SIGNING_P12_CERT }} REACT_ORG_CODE_SIGNING_P12_CERT_PWD: ${{ secrets.REACT_ORG_CODE_SIGNING_P12_CERT_PWD }} steps: - name: Checkout uses: actions/checkout@v6 - name: Restore cache if present id: restore-ios-xcframework uses: actions/cache/restore@v5 with: path: packages/react-native/.build/output/xcframeworks key: v4-ios-core-xcframework-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift', 'packages/react-native/scripts/ios-prebuild/*.js', 'packages/react-native/scripts/ios-prebuild.js', 'packages/react-native/React/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*') }} - name: Setup node.js if: steps.restore-ios-xcframework.outputs.cache-hit != 'true' uses: ./.github/actions/setup-node - name: Setup xcode if: steps.restore-ios-xcframework.outputs.cache-hit != 'true' uses: ./.github/actions/setup-xcode - name: Yarn Install if: steps.restore-ios-xcframework.outputs.cache-hit != 'true' uses: ./.github/actions/yarn-install - name: Download slice artifacts if: steps.restore-ios-xcframework.outputs.cache-hit != 'true' uses: actions/download-artifact@v7 with: pattern: prebuild-ios-core-slice-${{ matrix.flavor }}-* path: packages/react-native/.build/output/spm/${{ matrix.flavor }}/Build/Products merge-multiple: true - name: Download headers if: steps.restore-ios-xcframework.outputs.cache-hit != 'true' uses: actions/download-artifact@v7 with: pattern: prebuild-ios-core-headers-${{ matrix.flavor }}-* path: packages/react-native/.build/headers merge-multiple: true - name: Download ReactNativeDependencies if: steps.restore-ios-xcframework.outputs.cache-hit != 'true' uses: actions/download-artifact@v7 with: name: ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz path: /tmp/third-party/ - name: Extract ReactNativeDependencies if: steps.restore-ios-xcframework.outputs.cache-hit != 'true' shell: bash run: | # ReactNativeHeaders.xcframework is pure-RN (the deps namespaces ship # in the ReactNativeDependenciesHeaders sidecar built by the deps # prebuild), but the headers-verify compile gates still need the deps # headers on their include path (folly/glog/... reached from RN's # public headers), so the deps artifact is staged here too. tar -xzf /tmp/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz -C /tmp/third-party/ mkdir -p packages/react-native/third-party/ mv /tmp/third-party/packages/react-native/third-party/ReactNativeDependencies.xcframework packages/react-native/third-party/ReactNativeDependencies.xcframework - name: Set Hermes version if: steps.restore-ios-xcframework.outputs.cache-hit != 'true' shell: bash run: | # Non-stable RN builds resolve Hermes from npm's latest-v1 dist-tag. # TODO: rename 'latest-v1' to 'latest' once V1 is the only Hermes on npm. # Stable builds use the version pinned in version.properties. if [ "${{ inputs.use-hermes-prebuilt }}" == "true" ]; then HERMES_VERSION="latest-v1" else HERMES_VERSION=$(sed -n 's/^HERMES_VERSION_NAME=//p' packages/react-native/sdks/hermes-engine/version.properties) fi echo "Using Hermes version: $HERMES_VERSION" echo "HERMES_VERSION=$HERMES_VERSION" >> $GITHUB_ENV - name: Stage Hermes headers if: steps.restore-ios-xcframework.outputs.cache-hit != 'true' working-directory: packages/react-native env: FLAVOR: ${{ matrix.flavor }} run: | node -e "require('./scripts/ios-prebuild/hermes').prepareHermesArtifactsAsync(require('./package.json').version, process.env.FLAVOR).then(()=>process.exit(0)).catch(e=>{console.error(e);process.exit(1)})" - name: Setup Keychain if: ${{ steps.restore-ios-xcframework.outputs.cache-hit != 'true' && env.REACT_ORG_CODE_SIGNING_P12_CERT != '' }} uses: apple-actions/import-codesign-certs@v3 # https://github.com/marketplace/actions/import-code-signing-certificates with: p12-file-base64: ${{ secrets.REACT_ORG_CODE_SIGNING_P12_CERT }} p12-password: ${{ secrets.REACT_ORG_CODE_SIGNING_P12_CERT_PWD }} - name: Create XCFramework if: ${{ steps.restore-ios-xcframework.outputs.cache-hit != 'true' && env.REACT_ORG_CODE_SIGNING_P12_CERT == '' }} run: | cd packages/react-native node scripts/ios-prebuild -c -f "${{ matrix.flavor }}" ${{ inputs.version-type != '' && '--require-hermes' || '' }} - name: Create and Sign XCFramework if: ${{ steps.restore-ios-xcframework.outputs.cache-hit != 'true' && env.REACT_ORG_CODE_SIGNING_P12_CERT != '' }} run: | cd packages/react-native node scripts/ios-prebuild -c -f "${{ matrix.flavor }}" -i "React Org" ${{ inputs.version-type != '' && '--require-hermes' || '' }} - name: Verify composed headers if: steps.restore-ios-xcframework.outputs.cache-hit != 'true' run: | # Generator-time header gate: include-health ratchet, structural # byte-compare of module maps/umbrellas against the spec render, and # compile smokes (React module + every namespace module + the # privileged-consumer/Expo fixtures). Catches consumer-facing header # regressions here instead of in downstream builds. cd packages/react-native node scripts/ios-prebuild/headers-verify.js --flavor "${{ matrix.flavor }}" ${{ inputs.version-type != '' && '--require-stamped-version' || '' }} - name: Compress and Rename XCFramework if: steps.restore-ios-xcframework.outputs.cache-hit != 'true' run: | cd packages/react-native/.build/output/xcframeworks/${{matrix.flavor}} # Ship BOTH xcframeworks: React-Core-prebuilt's prepare_command flattens # ReactNativeHeaders.xcframework's Headers (incl. module.modulemap) into the # pod. Omitting it leaves consumers without React-Core-prebuilt/Headers/module.modulemap. tar -cz -f ../ReactCore${{matrix.flavor}}.xcframework.tar.gz React.xcframework ReactNativeHeaders.xcframework - name: Compress and Rename dSYM if: steps.restore-ios-xcframework.outputs.cache-hit != 'true' run: | cd packages/react-native/.build/output/xcframeworks/${{matrix.flavor}}/Symbols tar -cz -f ../../ReactCore${{ matrix.flavor }}.framework.dSYM.tar.gz . - name: Rename ReactNativeHeaders XCFramework tarball if: steps.restore-ios-xcframework.outputs.cache-hit != 'true' run: | # The compose step already tars ReactNativeHeaders.xcframework standalone; # published as its own Maven artifact (classifier reactnative-headers-*) # so SwiftPM consumers can wire it as a separate binaryTarget. It also # ships inside the ReactCore tarball for the CocoaPods pod. cp packages/react-native/.build/output/xcframeworks/${{matrix.flavor}}/ReactNativeHeaders.xcframework.tar.gz \ packages/react-native/.build/output/xcframeworks/ReactNativeHeaders${{matrix.flavor}}.xcframework.tar.gz - name: Upload XCFramework Artifact uses: actions/upload-artifact@v6 with: name: ReactCore${{ matrix.flavor }}.xcframework.tar.gz path: packages/react-native/.build/output/xcframeworks/ReactCore${{matrix.flavor}}.xcframework.tar.gz - name: Upload dSYM Artifact uses: actions/upload-artifact@v6 with: name: ReactCore${{ matrix.flavor }}.framework.dSYM.tar.gz path: packages/react-native/.build/output/xcframeworks/ReactCore${{matrix.flavor}}.framework.dSYM.tar.gz - name: Upload ReactNativeHeaders XCFramework Artifact uses: actions/upload-artifact@v6 with: name: ReactNativeHeaders${{ matrix.flavor }}.xcframework.tar.gz path: packages/react-native/.build/output/xcframeworks/ReactNativeHeaders${{matrix.flavor}}.xcframework.tar.gz - name: Save cache if present if: ${{ github.ref == 'refs/heads/main' }} # To avoid that the cache explode uses: actions/cache/save@v5 with: path: | packages/react-native/.build/output/xcframeworks/ReactCore${{matrix.flavor}}.xcframework.tar.gz packages/react-native/.build/output/xcframeworks/ReactCore${{matrix.flavor}}.framework.dSYM.tar.gz packages/react-native/.build/output/xcframeworks/ReactNativeHeaders${{matrix.flavor}}.xcframework.tar.gz key: v4-ios-core-xcframework-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift', 'packages/react-native/scripts/ios-prebuild/*.js', 'packages/react-native/scripts/ios-prebuild.js', 'packages/react-native/React/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*') }}