name: prepare-hermes-workspace description: This action prepares the hermes workspace with the right hermes and react-native versions. inputs: hermes-ws-dir: required: true description: The hermes dir we need to use to setup the workspace hermes-version-file: required: true description: the path to the file that will contain the hermes version outputs: hermes-version: description: the version of Hermes tied to this run value: ${{ steps.hermes-version.outputs.VERSION }} react-native-version: description: the version of React Native tied to this run value: ${{ steps.react-native-version.outputs.VERSION }} runs: using: composite steps: - name: Setup hermes version shell: bash id: hermes-version run: | mkdir -p "/tmp/hermes" "/tmp/hermes/download" "/tmp/hermes/hermes" if [ -f "${{ inputs.hermes-version-file }}" ]; then echo "Hermes Version file found! Using this version for the build:" echo "VERSION=$(cat ${{ inputs.hermes-version-file }})" >> "$GITHUB_OUTPUT" else echo "Hermes Version file not found!!!" echo "Using the last commit from main for the build:" HERMES_TAG_SHA=$(git ls-remote https://github.com/facebook/hermes main | cut -f 1 | tr -d '[:space:]') echo "VERSION=$HERMES_TAG_SHA" >> "$GITHUB_OUTPUT" fi echo "Hermes commit is $HERMES_TAG_SHA" - name: Get react-native version shell: bash id: react-native-version run: | VERSION=$(cat packages/react-native/package.json | jq -r '.version') # Save the react native version we are building in an output variable so we can use that file as part of the cache key. echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" echo "React Native Version is $VERSION" - name: Cache hermes workspace id: restore-hermes uses: actions/cache/restore@v4 with: path: | /tmp/hermes/download/ /tmp/hermes/hermes/ key: v1-hermes-${{ steps.hermes-version.outputs.version }} enableCrossOsArchive: true # It happened while testing that a cache was created from the right folders # but those folders where empty. Thus, the next check ensures that we can work with those caches. - name: Check if cache was meaningful id: meaningful-cache shell: bash run: | if [[ -d /tmp/hermes/hermes ]] && [[ -n "$(ls -A /tmp/hermes/hermes)" ]]; then echo "Found a good hermes cache" echo "HERMES_CACHED=true" >> "$GITHUB_OUTPUT" fi - name: Setup node.js uses: ./.github/actions/setup-node - name: Yarn- Install Dependencies if: ${{ steps.meaningful-cache.outputs.HERMES_CACHED != 'true' }} uses: ./.github/actions/yarn-install - name: Download Hermes tarball if: ${{ steps.meaningful-cache.outputs.HERMES_CACHED != 'true' }} shell: bash run: | node packages/react-native/scripts/hermes/prepare-hermes-for-build ${{ github.event.pull_request.html_url }} cp packages/react-native/sdks/download/* ${{ inputs.hermes-ws-dir }}/download/. cp -r packages/react-native/sdks/hermes/* ${{ inputs.hermes-ws-dir }}/hermes/. echo ${{ steps.hermes-version.outputs.version }} - name: Upload Hermes artifact uses: actions/upload-artifact@v4.3.4 with: name: hermes-workspace path: | /tmp/hermes/download/ /tmp/hermes/hermes/ - name: Cache hermes workspace uses: actions/cache/save@v4 if: ${{ github.ref == 'refs/heads/main' }} # To avoid that the cache explode. with: path: | /tmp/hermes/download/ /tmp/hermes/hermes/ key: v1-hermes-${{ steps.hermes-version.outputs.version }} enableCrossOsArchive: true