Skip to content

Commit

Permalink
chore: add workflow for generating release builds on the CI (#23)
Browse files Browse the repository at this point in the history
Johennes authored Jan 30, 2025
1 parent 54ca156 commit 2a374bd
Showing 9 changed files with 138 additions and 47 deletions.
70 changes: 70 additions & 0 deletions .github/actions/generate/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Generate
description: Set up dependencies and regenerate the bindings

inputs:
platform:
description: One of android, ios
required: true
release:
description: Whether to build in release mode, one of true, false
default: "false"

runs:
using: composite
steps:
- name: Setup JS
uses: ./.github/actions/setup-js

- name: Setup Rust (Android)
if: ${{ inputs.platform == 'android' }}
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android

- name: Setup Rust (iOS)
if: ${{ inputs.platform == 'ios' }}
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-ios,aarch64-apple-ios-sim,x86_64-apple-ios

- name: Install cargo-ndk
if: ${{ inputs.platform == 'android' }}
shell: bash
run: cargo install cargo-ndk

- name: Install clang-format
if: ${{ inputs.platform == 'ios' }}
shell: bash
run: brew install clang-format

- name: Write .xcode.env.local
if: ${{ inputs.platform == 'ios' }}
shell: bash
run: |
# Work around for https://github.com/facebook/react-native/issues/35657
echo "export NODE_BINARY=$(which node)" >> example/ios/.xcode.env.local
cat example/ios/.xcode.env.local
- name: Generate
shell: bash
env:
INFIX: ${{ inputs.release == 'true' && ':release' || '' }}
SUFFIX: ${{ inputs.platform == 'android' && ':android' || ':ios' }}
run:
yarn generate$INFIX$SUFFIX

- name: Free space
shell: bash
run: rm -rf rust_modules

- name: Check if repository is dirty
shell: bash
env:
EXCLUDE: ${{ inputs.platform == 'android' && 'ios' || 'android' }}
run: |
if [[ -n "$(git status --porcelain | grep -v ". $EXCLUDE")" ]]; then
>&2 echo "Found unexpected changes in repository after generating"
git status --short
git diff
exit 1
fi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Setup
description: Setup Node.js and install dependencies
name: Setup JS
description: Set up Node.js and install dependencies

runs:
using: composite
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Android
name: Build (Android)
on:
push:
branches:
@@ -13,26 +13,16 @@ jobs:
runs-on: ubuntu-latest
env:
TURBO_CACHE_DIR: .turbo/android

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup JS
uses: ./.github/actions/setup

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android

- name: Install cargo-ndk
run: cargo install cargo-ndk

- name: Generate
run: |
yarn generate:android
# Free up space for subsequent steps
rm -rf rust_modules
uses: ./.github/actions/generate
with:
platform: android
release: false

- name: Cache turborepo for Android
uses: actions/cache@v4
29 changes: 6 additions & 23 deletions .github/workflows/ios.yml → .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: iOS
name: Build (iOS)
on:
push:
branches:
@@ -13,33 +13,16 @@ jobs:
runs-on: macos-14
env:
TURBO_CACHE_DIR: .turbo/ios

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup JS
uses: ./.github/actions/setup

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-ios,aarch64-apple-ios-sim,x86_64-apple-ios

- name: Write .xcode.env.local
run: |
# Work around for https://github.com/facebook/react-native/issues/35657
echo "export NODE_BINARY=$(which node)" >> example/ios/.xcode.env.local
cat example/ios/.xcode.env.local
- name: Generate
run: |
# Disabling NEON fixes linker error, see
# https://github.com/unomed-dev/react-native-matrix-sdk/issues/12
# TODO: Replace this with setting the reldbg profile once ubrn supports it
export CARGO_FEATURE_NO_NEON=1
yarn generate:ios
# Free up space for subsequent steps
rm -rf rust_modules
uses: ./.github/actions/generate
with:
platform: ios
release: false

- name: Cache turborepo for iOS
uses: actions/cache@v4
45 changes: 45 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build (Release)
on:
workflow_dispatch:

jobs:
android:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Generate
uses: ./.github/actions/generate
with:
platform: android
release: true

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: android-libs
path: android/**/*.a
if-no-files-found: error

ios:
runs-on: macos-14

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Generate
uses: ./.github/actions/generate
with:
platform: ios
release: true

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: xcframework
path: build/*.xcframework
if-no-files-found: error

4 changes: 2 additions & 2 deletions .github/workflows/library.yml
Original file line number Diff line number Diff line change
@@ -15,8 +15,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
- name: Setup JS
uses: ./.github/actions/setup-js

- name: Build package
run: yarn prepare
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -15,8 +15,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
- name: Setup JS
uses: ./.github/actions/setup-js

- name: Lint files
run: yarn lint
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -4,8 +4,9 @@

[![lint](https://github.com/unomed-dev/react-native-matrix-sdk/actions/workflows/lint.yml/badge.svg)](https://github.com/unomed-dev/react-native-matrix-sdk/actions/workflows/lint.yml)
[![library](https://github.com/unomed-dev/react-native-matrix-sdk/actions/workflows/library.yml/badge.svg)](https://github.com/unomed-dev/react-native-matrix-sdk/actions/workflows/library.yml)
[![android](https://github.com/unomed-dev/react-native-matrix-sdk/actions/workflows/android.yml/badge.svg)](https://github.com/unomed-dev/react-native-matrix-sdk/actions/workflows/android.yml)
[![ios](https://github.com/unomed-dev/react-native-matrix-sdk/actions/workflows/ios.yml/badge.svg)](https://github.com/unomed-dev/react-native-matrix-sdk/actions/workflows/ios.yml)
[![android](https://github.com/unomed-dev/react-native-matrix-sdk/actions/workflows/build-android.yml/badge.svg)](https://github.com/unomed-dev/react-native-matrix-sdk/actions/workflows/build-android.yml)
[![ios](https://github.com/unomed-dev/react-native-matrix-sdk/actions/workflows/build-ios.yml/badge.svg)](https://github.com/unomed-dev/react-native-matrix-sdk/actions/workflows/build-ios.yml)
[![android](https://github.com/unomed-dev/react-native-matrix-sdk/actions/workflows/build-release.yml/badge.svg)](https://github.com/unomed-dev/react-native-matrix-sdk/actions/workflows/build-release.yml)

Powered by [uniffi-bindgen-react-native] and [create-react-native-library].

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -50,6 +50,8 @@
"generate:android": "yarn ubrn:clean && yarn ubrn:checkout && yarn ubrn:android:build --and-generate",
"generate:ios": "yarn ubrn:clean && yarn ubrn:checkout && yarn ubrn:ios:build && yarn ubrn:ios:generate",
"generate:release": "yarn ubrn:clean && yarn ubrn:checkout && yarn ubrn:android:build:release && yarn ubrn:ios:build:release && yarn ubrn:ios:generate",
"generate:release:android": "yarn ubrn:clean && yarn ubrn:checkout && yarn ubrn:android:build:release --and-generate",
"generate:release:ios": "yarn ubrn:clean && yarn ubrn:checkout && yarn ubrn:ios:build:release && yarn ubrn:ios:generate",
"format": "prettier -w '**/*.{ts,tsx}'",
"example": "yarn workspace @unomed/react-native-matrix-sdk-example",
"typecheck": "tsc",

0 comments on commit 2a374bd

Please sign in to comment.