Skip to content

Commit 0cf73a0

Browse files
reyamiryukibtc
andcommitted
ci: init
Co-authored-by: Yuki Kishimoto <[email protected]> Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent f87fc7b commit 0cf73a0

File tree

5 files changed

+287
-0
lines changed

5 files changed

+287
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Generate
2+
description: Set up dependencies and regenerate the bindings
3+
4+
inputs:
5+
platform:
6+
description: One of android, ios
7+
required: true
8+
release:
9+
description: Whether to build in release mode, one of true, false
10+
default: "false"
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Setup JS
16+
uses: ./.github/actions/setup-js
17+
18+
- name: Install cargo-ndk
19+
if: ${{ inputs.platform == 'android' }}
20+
shell: bash
21+
run: cargo install cargo-ndk
22+
23+
- name: Install clang-format
24+
if: ${{ inputs.platform == 'ios' }}
25+
shell: bash
26+
run: brew install clang-format
27+
28+
- name: Write .xcode.env.local
29+
if: ${{ inputs.platform == 'ios' }}
30+
shell: bash
31+
run: |
32+
# Work around for https://github.com/facebook/react-native/issues/35657
33+
echo "export NODE_BINARY=$(which node)" >> example/ios/.xcode.env.local
34+
cat example/ios/.xcode.env.local
35+
36+
- name: Generate
37+
shell: bash
38+
env:
39+
PLAT: ${{ inputs.platform == 'android' && 'android' || 'ios' }}
40+
MODE: ${{ inputs.release == 'true' && '--release' || '' }}
41+
run:
42+
yarn ubrn:$PLAT $MODE
43+
44+
- name: Check if repository is dirty
45+
shell: bash
46+
env:
47+
EXCLUDE: ${{ inputs.platform == 'android' && 'ios' || 'android' }}
48+
run: |
49+
if [[ -n "$(git status --porcelain | grep -v ". $EXCLUDE" | grep -v example/ios/Podfile.lock)" ]]; then
50+
>&2 echo "Found unexpected changes in repository after generating"
51+
git status --short
52+
git diff
53+
exit 1
54+
fi
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Setup JS
2+
description: Set up Node.js and install dependencies
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Setup Node.js
8+
uses: actions/setup-node@v4
9+
with:
10+
node-version-file: .nvmrc
11+
12+
- name: Cache dependencies
13+
id: yarn-cache
14+
uses: actions/cache@v4
15+
with:
16+
path: |
17+
**/node_modules
18+
.yarn/install-state.gz
19+
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }}
20+
restore-keys: |
21+
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
22+
${{ runner.os }}-yarn-
23+
24+
- name: Install dependencies
25+
if: steps.yarn-cache.outputs.cache-hit != 'true'
26+
run: yarn install --immutable
27+
shell: bash
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Build (Release)
2+
on:
3+
workflow_dispatch:
4+
5+
jobs:
6+
android:
7+
name: Android
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
with:
14+
submodules: 'true'
15+
16+
- name: Generate
17+
uses: ./.github/actions/generate
18+
with:
19+
platform: android
20+
release: true
21+
22+
- name: Upload artifact
23+
uses: actions/upload-artifact@v4
24+
with:
25+
name: android-libs
26+
path: android/**/*.a
27+
if-no-files-found: error
28+
29+
ios:
30+
name: iOS
31+
runs-on: macos-14
32+
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
with:
37+
submodules: 'true'
38+
39+
- name: Generate
40+
uses: ./.github/actions/generate
41+
with:
42+
platform: ios
43+
release: true
44+
45+
- name: Upload artifact
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: xcframework
49+
path: build/*.xcframework
50+
if-no-files-found: error

.github/workflows/ci.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
android:
12+
name: Android
13+
runs-on: ubuntu-latest
14+
env:
15+
TURBO_CACHE_DIR: .turbo/android
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
submodules: 'true'
22+
23+
- name: Generate
24+
uses: ./.github/actions/generate
25+
with:
26+
platform: android
27+
release: true # Some android target fails to compile in debug due to unstable panic_immediate_abort option
28+
29+
- name: Cache turborepo for Android
30+
uses: actions/cache@v4
31+
with:
32+
path: ${{ env.TURBO_CACHE_DIR }}
33+
key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }}
34+
restore-keys: |
35+
${{ runner.os }}-turborepo-android-
36+
37+
- name: Check turborepo cache for Android
38+
run: |
39+
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
40+
41+
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
42+
echo "turbo_cache_hit=1" >> $GITHUB_ENV
43+
fi
44+
45+
- name: Install JDK
46+
if: env.turbo_cache_hit != 1
47+
uses: actions/setup-java@v3
48+
with:
49+
distribution: 'zulu'
50+
java-version: '17'
51+
52+
- name: Finalize Android SDK
53+
if: env.turbo_cache_hit != 1
54+
run: |
55+
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
56+
57+
- name: Cache Gradle
58+
if: env.turbo_cache_hit != 1
59+
uses: actions/cache@v4
60+
with:
61+
path: |
62+
~/.gradle/wrapper
63+
~/.gradle/caches
64+
key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
65+
restore-keys: |
66+
${{ runner.os }}-gradle-
67+
68+
- name: Build example for Android
69+
env:
70+
JAVA_OPTS: "-XX:MaxHeapSize=6g"
71+
run: |
72+
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
73+
74+
ios:
75+
name: iOS
76+
runs-on: macos-14
77+
env:
78+
TURBO_CACHE_DIR: .turbo/ios
79+
80+
steps:
81+
- name: Checkout
82+
uses: actions/checkout@v4
83+
with:
84+
submodules: 'true'
85+
86+
- name: Generate
87+
uses: ./.github/actions/generate
88+
with:
89+
platform: ios
90+
release: false
91+
92+
- name: Cache turborepo for iOS
93+
uses: actions/cache@v4
94+
with:
95+
path: ${{ env.TURBO_CACHE_DIR }}
96+
key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }}
97+
restore-keys: |
98+
${{ runner.os }}-turborepo-ios-
99+
100+
- name: Check turborepo cache for iOS
101+
run: |
102+
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
103+
104+
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
105+
echo "turbo_cache_hit=1" >> $GITHUB_ENV
106+
fi
107+
108+
- name: Cache cocoapods
109+
if: env.turbo_cache_hit != 1
110+
id: cocoapods-cache
111+
uses: actions/cache@v4
112+
with:
113+
path: |
114+
**/ios/Pods
115+
key: ${{ runner.os }}-cocoapods-${{ hashFiles('example/ios/Podfile.lock') }}
116+
restore-keys: |
117+
${{ runner.os }}-cocoapods-
118+
119+
- name: Install cocoapods
120+
if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
121+
run: |
122+
cd example/ios
123+
124+
# Work around '[!] CocoaPods could not find compatible versions for pod "hermes-engine"'
125+
pod update hermes-engine --no-repo-update
126+
127+
pod install
128+
env:
129+
NO_FLIPPER: 1
130+
131+
- name: Build example for iOS
132+
run: |
133+
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"

.github/workflows/library.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Library
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
submodules: 'true'
18+
19+
- name: Setup JS
20+
uses: ./.github/actions/setup-js
21+
22+
- name: Build package
23+
run: yarn prepare

0 commit comments

Comments
 (0)