-
Notifications
You must be signed in to change notification settings - Fork 23
150 lines (128 loc) · 4.17 KB
/
release-swift-bindings.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
143
144
145
146
147
148
149
150
name: Release Swift Bindings
on:
workflow_dispatch:
jobs:
build-macos:
runs-on: warp-macos-13-arm64-6x
strategy:
fail-fast: false
matrix:
target:
- aarch64-apple-ios
- x86_64-apple-ios
- aarch64-apple-ios-sim
- x86_64-apple-darwin
- aarch64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update rust toolchains, add target
run: |
rustup update
rustup target add ${{ matrix.target }}
- name: Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: |
.
bindings_ffi
# Install latest cross to mitigate unwind linking issue on android builds.
# See https://github.com/cross-rs/cross/issues/1222
- name: Install cross
run: |
cargo install cross --git https://github.com/cross-rs/cross
- name: Install OpenSSL
working-directory: bindings_ffi
run: brew install openssl@3
- name: Download and build SQLCipher
working-directory: bindings_ffi
env:
LDFLAGS: -L/usr/local/opt/openssl@3/lib
CPPFLAGS: -I/usr/local/opt/openssl@3/include
run: |
make download-sqlcipher
make build-sqlcipher
- name: Build target
env:
CROSS_NO_WARNINGS: "0"
run: |
cross build --release --target ${{ matrix.target }} --manifest-path bindings_ffi/Cargo.toml --target-dir bindings_ffi/target
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: bindings_ffi/target/${{ matrix.target }}/release/libxmtpv3.a
retention-days: 1
swift:
runs-on: warp-macos-13-arm64-6x
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update rust toolchains, add target
run: |
rustup update
rustup target add x86_64-apple-darwin
- name: Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: |
.
bindings_ffi
- name: Install swift
run: brew install swiftformat
- name: Generate bindings
working-directory: bindings_ffi
run: |
make swift
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: swift
path: bindings_ffi/build/swift/
retention-days: 1
package-swift:
needs: [build-macos, swift]
runs-on: warp-macos-13-arm64-6x
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: bindings_ffi/build
- name: Build archive
working-directory: bindings_ffi
run: |
mkdir -p Sources/LibXMTP
mv build/swift/xmtpv3.swift Sources/LibXMTP/
make framework
cp ../LICENSE ./LICENSE
zip -r LibXMTPSwiftFFI.zip Sources LibXMTPSwiftFFI.xcframework LICENSE
- name: Calculate checksum
id: checksum
working-directory: bindings_ffi
run: |
echo "::set-output name=checksum::$(shasum -a 256 LibXMTPSwiftFFI.zip | awk '{ print $1 }')"
- name: Get short SHA
id: slug
run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)"
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: swift-bindings-${{ steps.slug.outputs.sha7 }}
release_name: Swift-Bindings-${{ steps.slug.outputs.sha7 }}
body: "Checksum of LibXMTPSwiftFFI.zip: ${{ steps.checksum.outputs.checksum }}"
draft: false
prerelease: true
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bindings_ffi/LibXMTPSwiftFFI.zip
asset_name: LibXMTPSwiftFFI.zip
asset_content_type: application/zip