-
Notifications
You must be signed in to change notification settings - Fork 50
142 lines (122 loc) · 5.03 KB
/
build-swift.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
137
138
139
140
141
142
---
name: Build Swift
on:
push:
branches:
- "rc"
- "hotfix-rc-swift"
- "DEVOPS-1525-swift-workflow-for-package-publishing"
jobs:
version:
name: Get Version
runs-on: ubuntu-22.04
outputs:
package_version: ${{ steps.retrieve-version.outputs.package_version }}
steps:
- name: Checkout repo
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Get Package Version
id: retrieve-version
run: |
VERSION=$(grep -o '^version = ".*"' crates/bitwarden/Cargo.toml | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")
echo "package_version=$VERSION" >> $GITHUB_OUTPUT
build:
runs-on: macos-13
strategy:
fail-fast: false
matrix:
settings:
- target: aarch64-apple-ios-sim
- target: aarch64-apple-ios
- target: x86_64-apple-ios
steps:
- name: Checkout repo
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Install rust
uses: dtolnay/rust-toolchain@5cb429dd810e16ff67df78472fa81cf760f4d1c0 # stable
with:
toolchain: 1.70.0
- name: Cache cargo registry
uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0
with:
key: ${{ matrix.settings.target }}-cargo
- name: Rustup target
run: rustup target install ${{ matrix.settings.target }}
- name: Build native library
env:
IPHONEOS_DEPLOYMENT_TARGET: 13.0
RUSTFLAGS: "-C link-arg=-Wl,-application_extension"
run: cargo build --package bitwarden-uniffi --target ${{ matrix.settings.target }} --release
working-directory: languages/swift
- name: Upload libbitwarden_uniffi.a artifact
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: libbitwarden_uniffi.a-${{ matrix.settings.target }}
path: ./target/${{ matrix.settings.target }}/release/libbitwarden_uniffi.a
if-no-files-found: error
- name: Upload libbitwarden_uniffi.dylib artifact
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: libbitwarden_uniffi.dylib-${{ matrix.settings.target }}
path: ./target/${{ matrix.settings.target }}/release/libbitwarden_uniffi.dylib
if-no-files-found: error
package:
runs-on: macos-13
needs:
- build
- version
env:
_PKG_VERSION: ${{ needs.version.outputs.package_version }}
steps:
- name: Checkout repo
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Install rust
uses: dtolnay/rust-toolchain@5cb429dd810e16ff67df78472fa81cf760f4d1c0 # stable
with:
toolchain: 1.70.0
- name: Cache cargo registry
uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0
with:
key: cargo-combine-cache
- name: Download artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
path: ./languages/swift/target
- name: Create universal libraries
working-directory: ./languages/swift
run: |
mkdir -p ${{ github.workspace }}/universal-ios-sim/release
lipo -create -output ${{ github.workspace }}/universal-ios-sim/release/libbitwarden_uniffi.a \
./target/libbitwarden_uniffi.a-aarch64-apple-ios-sim/libbitwarden_uniffi.a \
./target/libbitwarden_uniffi.a-x86_64-apple-ios/libbitwarden_uniffi.a
- name: Generate Swift bindings
working-directory: ./languages/swift
run: |
cargo run -p uniffi-bindgen generate \
./target/libbitwarden_uniffi.dylib-aarch64-apple-ios-sim/libbitwarden_uniffi.dylib \
--library \
--language swift \
--no-format \
--out-dir ./bindings
- name: Fit bindings for xcframework
working-directory: ./languages/swift
run: |
mkdir ./Headers
mv ./bindings/BitwardenFFI.h ./Headers/
mv ./bindings/BitwardenCoreFFI.h ./Headers/
cat ./bindings/BitwardenFFI.modulemap ./bindings/BitwardenCoreFFI.modulemap > ./Headers/module.modulemap
- name: Build xcframework
working-directory: ./languages/swift
run: |
xcodebuild -create-xcframework \
-library ./target/libbitwarden_uniffi.a-aarch64-apple-ios/libbitwarden_uniffi.a \
-headers ./Headers \
-library ${{ github.workspace }}/universal-ios-sim/release/libbitwarden_uniffi.a \
-headers ./Headers \
-output ./BitwardenFFI.xcframework
- name: Upload xcframework artifact
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: BitwardenFFI-${{ env._PKG_VERSION }}.xcframework
path: ./languages/swift/BitwardenFFI.xcframework
if-no-files-found: error