-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (113 loc) · 4.11 KB
/
release-kotlin.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Build and Release Yttrium Kotlin
on:
push
# workflow_dispatch:
# inputs:
# version:
# description: 'Version to release (e.g. 0.0.1)'
# required: true
env:
CARGO_TERM_COLOR: always
VERSION: ${{ github.event.inputs.version || '0.2.72' }}
TARGET_BRANCH: ${{ github.ref_name }}
permissions:
contents: write
jobs:
build-kotlin-artifacts:
runs-on: ubuntu-latest
strategy:
matrix:
target: [aarch64-linux-android, armv7-linux-androideabi]
steps:
- uses: actions/checkout@v3
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
components: rust-src
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Set up Android SDK
uses: android-actions/setup-android@v3
with:
api-level: 35
build-tools: 35.0.0
ndk-version: 27.2.12479018
- name: Install cargo-ndk
run: |
cargo install cargo-ndk
- name: Build Rust library
run: |
cargo ndk -t ${{ matrix.target }} build --release --features=uniffi/cli
- name: Generate Kotlin bindings (once)
if: ${{ matrix.target == 'aarch64-linux-android' }}
run: |
mkdir -p crates/kotlin-ffi/android/src/main/kotlin/com/reown/yttrium
cargo run --features=uniffi/cli --bin uniffi-bindgen generate --library target/${{ matrix.target }}/release/libuniffi_yttrium.so --language kotlin --out-dir crates/kotlin-ffi/android/src/main/kotlin/com/reown/yttrium
- name: Commit Generated Files (once)
if: ${{ matrix.target == 'aarch64-linux-android' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add crates/kotlin-ffi/android/src/main/kotlin/com/reown/yttrium/uniffi/uniffi_yttrium
git add crates/kotlin-ffi/android/src/main/kotlin/com/reown/yttrium/uniffi/yttrium
git commit -m "Add generated bindings for release: ${{ env.VERSION }}"
git push origin HEAD:$TARGET_BRANCH
- name: Prepare artifacts
run: |
# Map Rust targets to Android ABI names
declare -A abi_map
abi_map[aarch64-linux-android]="arm64-v8a"
abi_map[armv7-linux-androideabi]="armeabi-v7a"
abi_name=${abi_map[${{ matrix.target }}]}
if [ -z "$abi_name" ]; then
echo "Unknown ABI for target ${{ matrix.target }}"
exit 1
fi
mkdir -p yttrium/libs/$abi_name
cp target/${{ matrix.target }}/release/libuniffi_yttrium.so yttrium/libs/$abi_name/
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: artifacts
path: yttrium/
create-github-release:
needs: build-kotlin-artifacts
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: artifacts
path: yttrium/
- name: Create artifacts zip
run: |
zip -r kotlin-artifacts.zip yttrium/
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: 0.2.75 #${{ env.VERSION }}
release_name: 0.2.75 #Yttrium ${{ env.VERSION }}
draft: false
prerelease: false
- name: Upload Release Assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: kotlin-artifacts.zip
asset_name: kotlin-artifacts.zip
asset_content_type: application/zip