Skip to content

Commit a30d4ef

Browse files
committed
ci: build and upload example app
1 parent 84529e0 commit a30d4ef

1 file changed

Lines changed: 143 additions & 0 deletions

File tree

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
name: Build example apps
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- docs/**
9+
- '**/*.md'
10+
pull_request:
11+
paths-ignore:
12+
- docs/**
13+
- '**/*.md'
14+
workflow_dispatch:
15+
16+
permissions:
17+
contents: read
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
22+
23+
jobs:
24+
android:
25+
name: Android
26+
runs-on: ubuntu-latest
27+
timeout-minutes: 60
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
31+
32+
- name: Setup
33+
uses: ./.github/actions/setup
34+
35+
- name: Calculate fingerprint
36+
id: fingerprint
37+
working-directory: example
38+
run: |
39+
fingerprint=$(yarn expo-updates fingerprint:generate --platform android | jq -er .hash)
40+
echo "fingerprint=$fingerprint" >> "$GITHUB_OUTPUT"
41+
42+
- name: Cache release build
43+
id: cache
44+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
45+
with:
46+
path: react-native-paper-example.apk
47+
key: android-${{ steps.fingerprint.outputs.fingerprint }}
48+
49+
# Repacking shells out to `apktool`, so this cannot be gated on the cache.
50+
- name: Setup JDK
51+
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
52+
with:
53+
distribution: temurin
54+
java-version: 17
55+
56+
# This build exhausts the metaspace limit that `expo prebuild` sets.
57+
- name: Build Android app
58+
if: steps.cache.outputs.cache-hit != 'true'
59+
working-directory: example
60+
run: |
61+
yarn expo prebuild --platform android --no-install
62+
cd android
63+
./gradlew :app:assembleRelease -Dorg.gradle.jvmargs=-XX:MaxMetaspaceSize=1g
64+
mv app/build/outputs/apk/release/app-release.apk ../../react-native-paper-example.apk
65+
66+
- name: Repack cached build
67+
if: steps.cache.outputs.cache-hit == 'true'
68+
working-directory: example
69+
run: |
70+
yarn dlx @expo/repack-app@0.10.3 \
71+
--platform android \
72+
--source-app ../react-native-paper-example.apk \
73+
--output ../react-native-paper-example.apk
74+
75+
- name: Upload APK
76+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
77+
with:
78+
path: react-native-paper-example.apk
79+
archive: false
80+
retention-days: 30
81+
82+
ios:
83+
name: iOS
84+
runs-on: macos-latest
85+
timeout-minutes: 60
86+
steps:
87+
- name: Checkout
88+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
89+
90+
- name: Setup
91+
uses: ./.github/actions/setup
92+
93+
- name: Calculate fingerprint
94+
id: fingerprint
95+
working-directory: example
96+
run: |
97+
fingerprint=$(yarn expo-updates fingerprint:generate --platform ios | jq -er .hash)
98+
echo "fingerprint=$fingerprint" >> "$GITHUB_OUTPUT"
99+
100+
- name: Cache release build
101+
id: cache
102+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
103+
with:
104+
path: react-native-paper-example.app
105+
key: ios-${{ steps.fingerprint.outputs.fingerprint }}
106+
107+
- name: Build iOS app
108+
if: steps.cache.outputs.cache-hit != 'true'
109+
working-directory: example
110+
run: |
111+
yarn expo prebuild --platform ios --no-install
112+
cd ios
113+
pod install
114+
xcodebuild build \
115+
-workspace ReactNativePaperExample.xcworkspace \
116+
-scheme ReactNativePaperExample \
117+
-configuration Release \
118+
-destination 'generic/platform=iOS Simulator' \
119+
-derivedDataPath build \
120+
ARCHS=arm64
121+
mv build/Build/Products/Release-iphonesimulator/ReactNativePaperExample.app ../../react-native-paper-example.app
122+
123+
# Repacking in place fails with ENOTEMPTY on an existing app directory.
124+
- name: Repack cached build
125+
if: steps.cache.outputs.cache-hit == 'true'
126+
working-directory: example
127+
run: |
128+
mv ../react-native-paper-example.app "$RUNNER_TEMP/cached.app"
129+
yarn dlx @expo/repack-app@0.10.3 \
130+
--platform ios \
131+
--source-app "$RUNNER_TEMP/cached.app" \
132+
--output ../react-native-paper-example.app
133+
134+
# `ditto` keeps the symlinks and executable bits a plain upload drops.
135+
- name: Archive app
136+
run: ditto -c -k --keepParent react-native-paper-example.app react-native-paper-example.app.zip
137+
138+
- name: Upload app
139+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
140+
with:
141+
path: react-native-paper-example.app.zip
142+
archive: false
143+
retention-days: 30

0 commit comments

Comments
 (0)