Skip to content

Commit 71deb16

Browse files
committed
ci: build apk and app on each commit
1 parent 27fb72a commit 71deb16

5 files changed

Lines changed: 278 additions & 0 deletions

File tree

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Build Android
2+
3+
on:
4+
push:
5+
branches: [master]
6+
paths:
7+
- '.github/workflows/build-android.yml'
8+
- 'mobile-app/android/**'
9+
- 'mobile-app/package.json'
10+
- 'mobile-app/yarn.lock'
11+
- 'mobile-app/package-lock.json'
12+
- 'mobile-app/src/**'
13+
- 'mobile-app/*.js'
14+
- 'mobile-app/*.ts'
15+
- 'mobile-app/*.tsx'
16+
- 'mobile-app/*.json'
17+
pull_request:
18+
branches: [master]
19+
paths:
20+
- '.github/workflows/build-android.yml'
21+
- 'mobile-app/android/**'
22+
- 'mobile-app/package.json'
23+
- 'mobile-app/yarn.lock'
24+
- 'mobile-app/package-lock.json'
25+
- 'mobile-app/src/**'
26+
- 'mobile-app/*.js'
27+
- 'mobile-app/*.ts'
28+
- 'mobile-app/*.tsx'
29+
- 'mobile-app/*.json'
30+
workflow_dispatch:
31+
32+
jobs:
33+
build-android:
34+
name: Build Android APK
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v4
40+
with:
41+
submodules: recursive
42+
43+
- name: Setup Node.js
44+
uses: actions/setup-node@v4
45+
with:
46+
node-version: '20'
47+
cache: 'npm'
48+
cache-dependency-path: mobile-app/package-lock.json
49+
50+
- name: Install dependencies
51+
working-directory: mobile-app
52+
run: npm ci
53+
54+
- name: Setup Nim
55+
run: |
56+
# Install Nim from official Ubuntu repository
57+
sudo apt-get update
58+
sudo apt-get install -y nim
59+
nim --version
60+
nimble --version
61+
62+
- name: Install Nim dependencies
63+
working-directory: mobile-app/nim
64+
run: |
65+
if [ -f "nimbridge.nimble" ]; then
66+
nimble install -d
67+
fi
68+
69+
- name: Setup JDK 17
70+
uses: actions/setup-java@v4
71+
with:
72+
java-version: '17'
73+
distribution: 'zulu'
74+
cache: 'gradle'
75+
76+
- name: Cache Gradle packages
77+
uses: actions/cache@v4
78+
with:
79+
path: |
80+
~/.gradle/caches
81+
~/.gradle/wrapper
82+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
83+
restore-keys: |
84+
${{ runner.os }}-gradle-
85+
86+
- name: Grant execute permission for gradlew
87+
run: chmod +x mobile-app/android/gradlew
88+
89+
- name: Build Debug APK
90+
working-directory: mobile-app/android
91+
run: ./gradlew assembleDebug --no-daemon --build-cache
92+
93+
- name: Build Release APK
94+
working-directory: mobile-app/android
95+
run: ./gradlew assembleRelease --no-daemon --build-cache
96+
97+
- name: Upload Debug APK
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: app-debug
101+
path: mobile-app/android/app/build/outputs/apk/debug/app-debug.apk
102+
retention-days: 7
103+
104+
- name: Upload Release APK
105+
uses: actions/upload-artifact@v4
106+
with:
107+
name: app-release
108+
path: mobile-app/android/app/build/outputs/apk/release/app-release.apk
109+
retention-days: 7
110+
111+
- name: Stop Gradle daemon
112+
if: always()
113+
working-directory: mobile-app/android
114+
run: ./gradlew --stop

.github/workflows/build-ios.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Build iOS
2+
3+
on:
4+
push:
5+
branches: [master]
6+
paths:
7+
- '.github/workflows/build-ios.yml'
8+
- 'mobile-app/ios/**'
9+
- 'mobile-app/package.json'
10+
- 'mobile-app/yarn.lock'
11+
- 'mobile-app/package-lock.json'
12+
- 'mobile-app/src/**'
13+
- 'mobile-app/*.js'
14+
- 'mobile-app/*.ts'
15+
- 'mobile-app/*.tsx'
16+
- 'mobile-app/*.json'
17+
pull_request:
18+
branches: [master]
19+
paths:
20+
- '.github/workflows/build-ios.yml'
21+
- 'mobile-app/ios/**'
22+
- 'mobile-app/package.json'
23+
- 'mobile-app/yarn.lock'
24+
- 'mobile-app/package-lock.json'
25+
- 'mobile-app/src/**'
26+
- 'mobile-app/*.js'
27+
- 'mobile-app/*.ts'
28+
- 'mobile-app/*.tsx'
29+
- 'mobile-app/*.json'
30+
workflow_dispatch:
31+
32+
jobs:
33+
build-ios:
34+
name: Build iOS IPA
35+
runs-on: macos-latest
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v4
40+
with:
41+
submodules: recursive
42+
43+
- name: Setup Node.js
44+
uses: actions/setup-node@v4
45+
with:
46+
node-version: '20'
47+
cache: 'npm'
48+
cache-dependency-path: mobile-app/package-lock.json
49+
50+
- name: Install dependencies
51+
working-directory: mobile-app
52+
run: npm ci
53+
54+
- name: Setup Nim
55+
run: |
56+
# Install Nim from Homebrew on macOS
57+
brew install nim
58+
nim --version
59+
nimble --version
60+
61+
- name: Install Nim dependencies
62+
working-directory: mobile-app/nim
63+
run: |
64+
if [ -f "nimbridge.nimble" ]; then
65+
nimble install -d
66+
fi
67+
68+
- name: Setup Ruby
69+
uses: ruby/setup-ruby@v1
70+
with:
71+
ruby-version: '3.0'
72+
bundler-cache: true
73+
working-directory: mobile-app/ios
74+
75+
- name: Cache CocoaPods
76+
uses: actions/cache@v4
77+
with:
78+
path: mobile-app/ios/Pods
79+
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
80+
restore-keys: |
81+
${{ runner.os }}-pods-
82+
83+
- name: Install CocoaPods dependencies
84+
working-directory: mobile-app/ios
85+
run: |
86+
pod install --repo-update || pod install
87+
88+
- name: Select Xcode
89+
run: sudo xcode-select -s /Applications/Xcode.app
90+
91+
- name: Install xcbeautify
92+
run: brew install xcbeautify
93+
94+
- name: Build iOS Simulator App
95+
working-directory: mobile-app/ios
96+
run: |
97+
set -o pipefail
98+
xcodebuild -workspace nimrnmobileapp.xcworkspace \
99+
-scheme nimrnmobileapp \
100+
-sdk iphonesimulator \
101+
-configuration Debug \
102+
-destination 'platform=iOS Simulator,name=iPhone 15' \
103+
-derivedDataPath build \
104+
CODE_SIGNING_ALLOWED=NO \
105+
| xcbeautify
106+
107+
- name: Build iOS Device App (unsigned)
108+
working-directory: mobile-app/ios
109+
run: |
110+
set -o pipefail
111+
xcodebuild -workspace nimrnmobileapp.xcworkspace \
112+
-scheme nimrnmobileapp \
113+
-sdk iphoneos \
114+
-configuration Release \
115+
-derivedDataPath build \
116+
CODE_SIGNING_ALLOWED=NO \
117+
CODE_SIGN_IDENTITY="" \
118+
CODE_SIGNING_REQUIRED=NO \
119+
| xcbeautify
120+
121+
- name: Create IPA (unsigned)
122+
working-directory: mobile-app/ios
123+
run: |
124+
mkdir -p build/Payload
125+
cp -r build/Build/Products/Release-iphoneos/nimrnmobileapp.app build/Payload/
126+
cd build
127+
zip -r nimrnmobileapp-unsigned.ipa Payload
128+
cd ..
129+
130+
- name: Upload Simulator Build
131+
uses: actions/upload-artifact@v4
132+
with:
133+
name: ios-simulator-app
134+
path: mobile-app/ios/build/Build/Products/Debug-iphonesimulator/nimrnmobileapp.app
135+
retention-days: 7
136+
137+
- name: Upload IPA (unsigned)
138+
uses: actions/upload-artifact@v4
139+
with:
140+
name: ios-unsigned-ipa
141+
path: mobile-app/ios/build/nimrnmobileapp-unsigned.ipa
142+
retention-days: 7

mobile-app/nim/nimbridge.nimble

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Package
2+
version = "0.1.0"
3+
author = "React Native Nim Bridge"
4+
description = "Nim bridge for React Native"
5+
license = "MIT"
6+
srcDir = "."
7+
8+
# Dependencies
9+
requires "nim >= 2.0.0"
10+
requires "json_serialization >= 0.2.8"

mobile-app/tools/build-android-nim.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ echo "Building Nim code for Android..."
77

88
cd ../nim
99

10+
# Install Nim dependencies if nimble file exists
11+
if [ -f "nimbridge.nimble" ]; then
12+
echo "Installing Nim dependencies..."
13+
nimble install -d
14+
fi
15+
1016
# Clean previous builds
1117
rm -rf cache_android_*
1218
mkdir -p cache_android

mobile-app/tools/build-mobile.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ echo "Building Nim-React Native Bridge..."
1414
echo "Compiling Nim code..."
1515
cd "$NIM_DIR"
1616

17+
# Install Nim dependencies if nimble file exists
18+
if [ -f "nimbridge.nimble" ]; then
19+
echo "Installing Nim dependencies..."
20+
nimble install -d
21+
fi
22+
1723
# Detect platform and build accordingly
1824
if [[ "$OSTYPE" == "darwin"* ]]; then
1925
# macOS: Build iOS static library AND Android C files

0 commit comments

Comments
 (0)