Skip to content

Commit cb32dd1

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

File tree

5 files changed

+277
-0
lines changed

5 files changed

+277
-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: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
14+
- name: Generate
15+
uses: ./.github/actions/generate
16+
with:
17+
platform: android
18+
release: true
19+
20+
- name: Upload artifact
21+
uses: actions/upload-artifact@v4
22+
with:
23+
name: android-libs
24+
path: android/**/*.a
25+
if-no-files-found: error
26+
27+
ios:
28+
name: iOS
29+
runs-on: macos-14
30+
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Generate
36+
uses: ./.github/actions/generate
37+
with:
38+
platform: ios
39+
release: true
40+
41+
- name: Upload artifact
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: xcframework
45+
path: build/*.xcframework
46+
if-no-files-found: error

.github/workflows/ci.yml

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

.github/workflows/library.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
17+
- name: Setup JS
18+
uses: ./.github/actions/setup-js
19+
20+
- name: Build package
21+
run: yarn prepare

0 commit comments

Comments
 (0)