Skip to content

Commit 992067f

Browse files
kixelatedQizotclaude
authored
Uniffi async objects (#1071)
Co-authored-by: Jakub Perżyło <jakub.perzylo@swmansion.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent cf3b3e4 commit 992067f

22 files changed

Lines changed: 1763 additions & 29 deletions

File tree

.github/workflows/moq-ffi.yml

Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
name: moq-ffi
2+
3+
on:
4+
push:
5+
tags:
6+
- "moq-ffi-v*"
7+
8+
permissions:
9+
contents: write
10+
11+
concurrency:
12+
group: moq-ffi-release
13+
cancel-in-progress: true
14+
15+
jobs:
16+
parse-version:
17+
name: Parse version
18+
runs-on: ubuntu-latest
19+
outputs:
20+
version: ${{ steps.parse.outputs.version }}
21+
22+
steps:
23+
- name: Parse version from tag
24+
id: parse
25+
shell: bash
26+
run: |
27+
ref=${GITHUB_REF#refs/tags/}
28+
if [[ "$ref" =~ ^moq-ffi-v([0-9.]+)$ ]]; then
29+
echo "version=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
30+
else
31+
echo "Tag format not recognized: $ref" >&2
32+
exit 1
33+
fi
34+
35+
build:
36+
name: Build (${{ matrix.target }})
37+
needs: [parse-version]
38+
runs-on: ${{ matrix.os }}
39+
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
include:
44+
# Desktop/Server
45+
- target: x86_64-unknown-linux-gnu
46+
os: ubuntu-latest
47+
- target: aarch64-unknown-linux-gnu
48+
os: ubuntu-latest
49+
- target: x86_64-apple-darwin
50+
os: macos-15-intel
51+
- target: aarch64-apple-darwin
52+
os: macos-latest
53+
- target: universal-apple-darwin
54+
os: macos-latest
55+
- target: x86_64-pc-windows-msvc
56+
os: windows-latest
57+
# iOS
58+
- target: aarch64-apple-ios
59+
os: macos-latest
60+
- target: aarch64-apple-ios-sim
61+
os: macos-latest
62+
# Android
63+
- target: aarch64-linux-android
64+
os: ubuntu-latest
65+
- target: armv7-linux-androideabi
66+
os: ubuntu-latest
67+
- target: x86_64-linux-android
68+
os: ubuntu-latest
69+
70+
steps:
71+
- uses: actions/checkout@v6
72+
73+
- name: Install Rust
74+
uses: dtolnay/rust-toolchain@stable
75+
with:
76+
targets: ${{ matrix.target == 'universal-apple-darwin' && 'x86_64-apple-darwin,aarch64-apple-darwin' || matrix.target }}
77+
78+
- name: Rust cache
79+
uses: Swatinem/rust-cache@v2
80+
81+
- name: Install cross-compilation tools (Linux ARM64)
82+
if: matrix.target == 'aarch64-unknown-linux-gnu'
83+
run: |
84+
sudo apt-get update
85+
sudo apt-get install -y gcc-aarch64-linux-gnu
86+
87+
- name: Install cargo-ndk (Android)
88+
if: contains(matrix.target, 'android')
89+
run: cargo install cargo-ndk
90+
91+
- name: Build and package
92+
shell: bash
93+
env:
94+
BUILD_TARGET: ${{ matrix.target }}
95+
BUILD_VERSION: ${{ needs.parse-version.outputs.version }}
96+
run: |
97+
./rs/moq-ffi/build.sh \
98+
--target "$BUILD_TARGET" \
99+
--version "$BUILD_VERSION" \
100+
--output dist
101+
102+
- name: Upload artifact
103+
uses: actions/upload-artifact@v7
104+
with:
105+
name: moq-ffi-${{ matrix.target }}
106+
path: dist/*
107+
108+
bindings:
109+
name: Generate bindings
110+
needs: [parse-version]
111+
runs-on: ubuntu-latest
112+
113+
steps:
114+
- uses: actions/checkout@v6
115+
116+
- name: Install Rust
117+
uses: dtolnay/rust-toolchain@stable
118+
119+
- name: Rust cache
120+
uses: Swatinem/rust-cache@v2
121+
122+
- name: Generate bindings
123+
env:
124+
BUILD_VERSION: ${{ needs.parse-version.outputs.version }}
125+
run: |
126+
./rs/moq-ffi/build.sh \
127+
--bindings-only \
128+
--version "$BUILD_VERSION" \
129+
--output dist
130+
131+
- name: Upload bindings
132+
uses: actions/upload-artifact@v7
133+
with:
134+
name: moq-ffi-bindings
135+
path: dist/*
136+
137+
python:
138+
name: Python wheels (${{ matrix.target }})
139+
needs: [parse-version]
140+
runs-on: ${{ matrix.os }}
141+
142+
strategy:
143+
fail-fast: false
144+
matrix:
145+
include:
146+
- target: x86_64-unknown-linux-gnu
147+
os: ubuntu-latest
148+
- target: aarch64-unknown-linux-gnu
149+
os: ubuntu-latest
150+
- target: x86_64-apple-darwin
151+
os: macos-15-intel
152+
- target: aarch64-apple-darwin
153+
os: macos-latest
154+
- target: x86_64-pc-windows-msvc
155+
os: windows-latest
156+
157+
steps:
158+
- uses: actions/checkout@v6
159+
160+
- uses: actions/setup-python@v6
161+
with:
162+
python-version: "3.12"
163+
164+
- name: Set Cargo.toml version
165+
shell: bash
166+
run: |
167+
VERSION="${{ needs.parse-version.outputs.version }}"
168+
sed -i.bak "s/^version = \".*\"/version = \"${VERSION}\"/" rs/moq-ffi/Cargo.toml
169+
rm -f rs/moq-ffi/Cargo.toml.bak
170+
171+
- name: Build wheels
172+
uses: PyO3/maturin-action@v1
173+
with:
174+
args: --release --out dist -m rs/moq-ffi/Cargo.toml
175+
target: ${{ matrix.target }}
176+
177+
- name: Upload wheels
178+
uses: actions/upload-artifact@v7
179+
with:
180+
name: python-${{ matrix.target }}
181+
path: dist/*.whl
182+
183+
release:
184+
name: Release
185+
needs: [parse-version, build, bindings, python]
186+
runs-on: ubuntu-latest
187+
188+
steps:
189+
- uses: actions/checkout@v6
190+
with:
191+
fetch-depth: 0
192+
193+
- name: Find previous tag
194+
id: prev_tag
195+
shell: bash
196+
run: |
197+
current_tag="moq-ffi-v${{ needs.parse-version.outputs.version }}"
198+
prev_tag=$(git tag --list 'moq-ffi-v*' --sort=-v:refname | grep -v "^${current_tag}$" | head -n1 || true)
199+
echo "tag=${prev_tag}" >> "$GITHUB_OUTPUT"
200+
echo "Previous tag: ${prev_tag:-none}"
201+
202+
- name: Download artifacts
203+
uses: actions/download-artifact@v8
204+
with:
205+
path: artifacts
206+
merge-multiple: true
207+
208+
- name: Create release
209+
shell: bash
210+
env:
211+
GH_TOKEN: ${{ github.token }}
212+
REF_NAME: ${{ github.ref_name }}
213+
VERSION: ${{ needs.parse-version.outputs.version }}
214+
PREV_TAG: ${{ steps.prev_tag.outputs.tag }}
215+
run: |
216+
if [ -n "$PREV_TAG" ]; then
217+
gh release create "$REF_NAME" \
218+
--title "moq-ffi v${VERSION}" \
219+
--generate-notes \
220+
--notes-start-tag "$PREV_TAG" \
221+
artifacts/*
222+
else
223+
gh release create "$REF_NAME" \
224+
--title "moq-ffi v${VERSION}" \
225+
--generate-notes \
226+
artifacts/*
227+
fi
228+
229+
publish-python:
230+
name: Publish to PyPI
231+
needs: [release]
232+
runs-on: ubuntu-latest
233+
environment:
234+
name: pypi
235+
url: https://pypi.org/p/moq-ffi
236+
permissions:
237+
id-token: write
238+
239+
steps:
240+
- name: Download wheels
241+
uses: actions/download-artifact@v8
242+
with:
243+
pattern: python-*
244+
path: dist
245+
merge-multiple: true
246+
247+
- name: Publish to PyPI
248+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)