Skip to content
Latchkey

build-android workflow (facebook/hermes)

The build-android workflow from facebook/hermes, explained and optimized by Latchkey.

A

CI health: A - excellent

Run this on Latchkey for self-healing, caching, and up to 58% lower cost.

Grade your own workflow free or run it on Latchkey →
Source: facebook/hermes.github/workflows/build-android.ymlLicense MITView source

What it does

This is the build-android workflow from the facebook/hermes repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: build-android

on:
  workflow_call:
    inputs:
      release-type:
        required: true
        description: The type of release we are building. It could be release or dry-run
        type: string

jobs:
  build-android:
    runs-on: 8-core-ubuntu
    env:
      HERMES_WS_DIR: /home/runner/work/hermes/hermes
    container:
      image: reactnativecommunity/react-native-android:latest
      env:
        TERM: "dumb"
        GRADLE_OPTS: "-Dorg.gradle.daemon=false"
        ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }}
        ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_KEY }}
        ORG_GRADLE_PROJECT_SONATYPE_USERNAME: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_USERNAME }}
        ORG_GRADLE_PROJECT_SONATYPE_PASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_PASSWORD }}
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Setup git safe folders
        shell: bash
        run: git config --global --add safe.directory '*'
      - name: Setup node.js
        uses: ./.github/actions/setup-node
      - name: Install node dependencies
        uses: ./.github/actions/yarn-install
      - name: Set artifacts version
        shell: bash
        run: node ./utils/scripts/hermes/set-artifacts-version.js --build-type ${{ inputs.release-type }}
      - name: Build android
        shell: bash
        run: |
          cd android
          ./gradlew publishAndroidOnlyToMavenTempLocal :build -PenableWarningsAsErrors=true
      - name: Upload Maven Artifacts
        uses: actions/upload-artifact@v4.3.4
        with:
          name: maven-local
          path: /tmp/maven-local

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: build-android
 
on:
  workflow_call:
    inputs:
      release-type:
        required: true
        description: The type of release we are building. It could be release or dry-run
        type: string
 
jobs:
  build-android:
    timeout-minutes: 30
    runs-on: 8-core-ubuntu
    env:
      HERMES_WS_DIR: /home/runner/work/hermes/hermes
    container:
      image: reactnativecommunity/react-native-android:latest
      env:
        TERM: "dumb"
        GRADLE_OPTS: "-Dorg.gradle.daemon=false"
        ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }}
        ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_KEY }}
        ORG_GRADLE_PROJECT_SONATYPE_USERNAME: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_USERNAME }}
        ORG_GRADLE_PROJECT_SONATYPE_PASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_PASSWORD }}
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Setup git safe folders
        shell: bash
        run: git config --global --add safe.directory '*'
      - name: Setup node.js
        uses: ./.github/actions/setup-node
      - name: Install node dependencies
        uses: ./.github/actions/yarn-install
      - name: Set artifacts version
        shell: bash
        run: node ./utils/scripts/hermes/set-artifacts-version.js --build-type ${{ inputs.release-type }}
      - name: Build android
        shell: bash
        run: |
          cd android
          ./gradlew publishAndroidOnlyToMavenTempLocal :build -PenableWarningsAsErrors=true
      - name: Upload Maven Artifacts
        uses: actions/upload-artifact@v4.3.4
        with:
          name: maven-local
          path: /tmp/maven-local
 

What changed

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow