-
Notifications
You must be signed in to change notification settings - Fork 4
chore(ci): refactor template android/ios workflows #329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| name: Build Android | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
|
|
@@ -25,63 +28,52 @@ on: | |
| - '**/bun.lock' | ||
| - '**/react-native.config.js' | ||
| - '**/nitro.json' | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build_new: | ||
| name: Build Android Example App (new architecture) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: oven-sh/setup-bun@v2 | ||
|
|
||
| - name: Install npm dependencies (bun) | ||
| run: bun install | ||
|
|
||
| - name: Setup JDK 17 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: 'zulu' | ||
| java-version: 17 | ||
| java-package: jdk | ||
| cache: gradle | ||
|
|
||
| - name: Run Gradle Build for example/android/ | ||
| working-directory: example/android | ||
| run: ./gradlew assembleDebug --no-daemon --build-cache | ||
|
|
||
| - name: Stop Gradle Daemon | ||
| working-directory: example/android | ||
| run: ./gradlew --stop | ||
|
|
||
| build_old: | ||
| name: Build Android Example App (old architecture) | ||
| build: | ||
| name: Build Android Example App (${{ matrix.arch }}) | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| arch: [new, old] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: oven-sh/setup-bun@v2 | ||
|
|
||
| - name: Install npm dependencies (bun) | ||
| - name: Install dependencies (bun) | ||
| run: bun install | ||
|
|
||
| - name: Disable new architecture in gradle.properties | ||
| if: matrix.arch == 'old' | ||
| run: sed -i "s/newArchEnabled=true/newArchEnabled=false/g" example/android/gradle.properties | ||
|
|
||
| - name: Setup JDK 17 | ||
| uses: actions/setup-java@v4 | ||
| uses: actions/setup-java@v5 | ||
| with: | ||
| distribution: 'zulu' | ||
| java-version: 17 | ||
| java-package: jdk | ||
| cache: gradle | ||
| java-version: '17' | ||
| cache: 'gradle' | ||
|
|
||
|
Comment on lines
56
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid double Gradle caching. You’re using both setup-java’s Option A (keep setup-java cache, remove explicit cache): - - name: Cache Gradle
- uses: actions/cache@v4
- with:
- path: |
- ~/.gradle/caches
- ~/.gradle/wrapper
- key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/**/*.gradle*') }}
- restore-keys: |
- ${{ runner.os }}-gradle-Option B (remove - with:
- distribution: 'zulu'
- java-version: '17'
- cache: 'gradle'
+ with:
+ distribution: 'zulu'
+ java-version: '17'And widen cache key: - key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/**/*.gradle*') }}
+ key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/**/*.gradle*', 'example/android/**/gradle.properties') }}Also applies to: 63-72 🤖 Prompt for AI Agents |
||
| - name: Cache Gradle | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.gradle/caches | ||
| ~/.gradle/wrapper | ||
| key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/**/*.gradle*') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-gradle- | ||
|
|
||
| - name: Run Gradle Build for example/android/ | ||
| - name: Run Gradle build | ||
| working-directory: example/android | ||
| run: ./gradlew assembleDebug --no-daemon --build-cache | ||
|
|
||
| - name: Stop Gradle Daemon | ||
| - name: Stop Gradle daemon | ||
| working-directory: example/android | ||
| run: ./gradlew --stop | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| name: Build iOS | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
|
|
@@ -33,6 +36,7 @@ on: | |
| - '**/*.podspec' | ||
| - '**/react-native.config.js' | ||
| - '**/nitro.json' | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| USE_CCACHE: 1 | ||
|
|
@@ -42,9 +46,13 @@ concurrency: | |
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build_new: | ||
| name: Build iOS Example App (new architecture) | ||
| build: | ||
| name: Build iOS Example App (${{ matrix.arch }}) | ||
| runs-on: macOS-15 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| arch: [new, old] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: oven-sh/setup-bun@v2 | ||
|
|
@@ -53,93 +61,47 @@ jobs: | |
| with: | ||
| xcode-version: 16.4 | ||
|
|
||
| - name: Install npm dependencies (bun) | ||
| run: bun install | ||
|
|
||
| - name: Setup Ruby (bundle) | ||
| uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: 2.7.2 | ||
| bundler-cache: true | ||
| working-directory: example/ios | ||
|
|
||
| - name: Install xcpretty | ||
| run: gem install xcpretty | ||
|
|
||
| - name: Restore Pods cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: example/ios/Pods | ||
| key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock', '**/Gemfile.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pods- | ||
| - name: Install Pods | ||
| working-directory: example/ios | ||
| run: pod install | ||
| - name: Build App | ||
| working-directory: example/ios | ||
| run: "set -o pipefail && xcodebuild \ | ||
| CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ \ | ||
| -derivedDataPath build -UseModernBuildSystem=YES \ | ||
| -workspace $$exampleApp$$.xcworkspace \ | ||
| -scheme $$exampleApp$$ \ | ||
| -sdk iphonesimulator \ | ||
| -configuration Debug \ | ||
| -destination 'platform=iOS Simulator,name=iPhone 16' \ | ||
| build \ | ||
| CODE_SIGNING_ALLOWED=NO | xcpretty" | ||
|
|
||
| build_old: | ||
| name: Build iOS Example App (old architecture) | ||
| runs-on: macOS-15 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: oven-sh/setup-bun@v2 | ||
|
|
||
| - name: Setup Xcode | ||
| uses: maxim-lobanov/setup-xcode@v1 | ||
| with: | ||
| xcode-version: 16.4 | ||
|
|
||
| - name: Install npm dependencies (bun) | ||
| - name: Install dependencies (bun) | ||
| run: bun install | ||
|
|
||
| - name: Disable new architecture in Podfile | ||
| if: matrix.arch == 'old' | ||
| run: sed -i "" "s/ENV\['RCT_NEW_ARCH_ENABLED'\] = '1'/ENV['RCT_NEW_ARCH_ENABLED'] = '0'/g" example/ios/Podfile | ||
|
|
||
| - name: Restore buildcache | ||
| uses: mikehardy/buildcache-action@v2 | ||
| continue-on-error: true | ||
|
|
||
| - name: Setup Ruby (bundle) | ||
| uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: 2.7.2 | ||
| ruby-version: '3.2' | ||
| bundler-cache: true | ||
| working-directory: example/ios | ||
|
|
||
|
Comment on lines
71
to
77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix: ruby/setup-ruby working-directory is misplaced.
- - name: Setup Ruby (bundle)
- uses: ruby/setup-ruby@v1
- with:
- ruby-version: '3.2'
- bundler-cache: true
- working-directory: example/ios
+ - name: Setup Ruby (bundle)
+ uses: ruby/setup-ruby@v1
+ with:
+ ruby-version: '3.2'
+ bundler-cache: true
+ working-directory: example/ios
🤖 Prompt for AI Agents |
||
| - name: Install xcpretty | ||
| run: gem install xcpretty | ||
|
|
||
| - name: Restore Pods cache | ||
| - name: Cache CocoaPods | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: example/ios/Pods | ||
| key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock', '**/Gemfile.lock') }} | ||
| path: | | ||
| ~/.cocoapods/repos | ||
| example/ios/Pods | ||
| key: ${{ runner.os }}-pods-${{ hashFiles('example/ios/Podfile.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pods- | ||
|
|
||
| - name: Install Pods | ||
| working-directory: example/ios | ||
| run: pod install | ||
|
|
||
| - name: Build App | ||
| working-directory: example/ios | ||
| run: "set -o pipefail && xcodebuild \ | ||
| CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ \ | ||
| -derivedDataPath build -UseModernBuildSystem=YES \ | ||
| -workspace $$exampleApp$$.xcworkspace \ | ||
| -scheme $$exampleApp$$ \ | ||
| -sdk iphonesimulator \ | ||
| -configuration Debug \ | ||
| -destination 'platform=iOS Simulator,name=iPhone 16' \ | ||
| build \ | ||
| CODE_SIGNING_ALLOWED=NO | xcpretty" | ||
| run: | | ||
| set -o pipefail && xcodebuild \ | ||
| CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ \ | ||
| -derivedDataPath build -UseModernBuildSystem=YES \ | ||
| -workspace $$exampleApp$$.xcworkspace \ | ||
| -scheme $$exampleApp$$ \ | ||
| -sdk iphonesimulator \ | ||
| -configuration Debug \ | ||
| -destination 'platform=iOS Simulator,name=iPhone 16' \ | ||
| build \ | ||
| CODE_SIGNING_ALLOWED=NO | xcpretty | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: manual dispatch path lacks a run-id for artifact download.
When
workflow_dispatchtriggers this workflow,${{ github.event.workflow_run.id }}is undefined and the download step will fail.Add an optional input and use it when manually dispatched:
on: workflow_run: workflows: ['Generate Packages'] types: - completed - workflow_dispatch: + workflow_dispatch: + inputs: + upstream_run_id: + description: 'Run ID of the upstream "Generate Packages" workflow' + required: false + type: stringThen select the run-id:
And guard the step when neither is present:
Also applies to: 38-46