-
Notifications
You must be signed in to change notification settings - Fork 3
434 lines (414 loc) · 17.4 KB
/
deploy-release.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
name: Deploy a new release
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
push:
tags:
- 'v*.*.*-mock*'
env:
GITHUB_REF: ${{ github.ref }}
jobs:
cross-compile-ios:
name: cross-compile-ios
runs-on: macos-latest
strategy:
matrix:
target: [ x86_64-apple-ios, aarch64-apple-ios, aarch64-apple-ios-sim ]
mock-deps: [ true ]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Config cargo
run: echo -e "$CARGO_CONFIG_TOML_BREEZ" > .cargo/config.toml
env:
CARGO_CONFIG_TOML_BREEZ: ${{ secrets.CARGO_CONFIG_TOML_BREEZ }}
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.77.1
profile: minimal
override: true
target: ${{ matrix.target }}
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build target
uses: actions-rs/cargo@v1
with:
use-cross: false
command: build
args: ${{ matrix.mock-deps && '--no-default-features --features mock-deps' || '' }} --release --target ${{ matrix.target }}
- name: Upload library binaries
uses: actions/upload-artifact@v4
with:
path: target/${{ matrix.target }}/release/libuniffi_lipalightninglib.a
name: build-${{ matrix.target }}${{ matrix.mock-deps && '-mock' || '' }}
- name: Upload bindings files
uses: actions/upload-artifact@v4
if: ${{ matrix.target == 'x86_64-apple-ios' }}
with:
path: bindings/swift/lipalightninglib*
name: bindings-files-ios${{ matrix.mock-deps && '-mock' || '' }}
cross-compile-android:
name: cross-compile-android
runs-on: ubuntu-latest
strategy:
matrix:
target: [ aarch64-linux-android, armv7-linux-androideabi, i686-linux-android ]
mock-deps: [ true ]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Config cargo
run: echo -e "$CARGO_CONFIG_TOML_BREEZ" > .cargo/config.toml
env:
CARGO_CONFIG_TOML_BREEZ: ${{ secrets.CARGO_CONFIG_TOML_BREEZ }}
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.77.1
profile: minimal
override: true
target: ${{ matrix.target }}
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Cross
run: cargo install cross --locked
- name: Build target
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: ${{ matrix.mock-deps && '--no-default-features --features mock-deps' || '' }} --release --target ${{ matrix.target }}
- name: Upload library binaries
uses: actions/upload-artifact@v4
with:
path: target/${{ matrix.target }}/release/libuniffi_lipalightninglib.so
name: build-${{ matrix.target }}${{ matrix.mock-deps && '-mock' || '' }}
- name: Upload bindings file
uses: actions/upload-artifact@v4
if: ${{ matrix.target == 'aarch64-linux-android' }}
with:
path: bindings/kotlin/uniffi/lipalightninglib/lipalightninglib.kt
name: bindings-file-android${{ matrix.mock-deps && '-mock' || '' }}
lipo-ios:
name: lipo-ios
needs: [ cross-compile-ios, cross-compile-android ]
runs-on: macos-latest
strategy:
matrix:
mock-deps: [ true ]
steps:
- name: Download x86 bin
uses: actions/download-artifact@v4
with:
path: target/x86_64-apple-ios/release
name: build-x86_64-apple-ios${{ matrix.mock-deps && '-mock' || '' }}
- name: Download aarch64 bin
uses: actions/download-artifact@v4
with:
path: target/aarch64-apple-ios/release
name: build-aarch64-apple-ios${{ matrix.mock-deps && '-mock' || '' }}
- name: Download aarch64sim bin
uses: actions/download-artifact@v4
with:
path: target/aarch64-apple-ios-sim/release
name: build-aarch64-apple-ios-sim${{ matrix.mock-deps && '-mock' || '' }}
- name: Package simulator binaries
run: |
mkdir -p target/universal/release
lipo -create -output target/universal/release/libuniffi_lipalightninglib_simulator.a \
target/aarch64-apple-ios-sim/release/libuniffi_lipalightninglib.a \
target/x86_64-apple-ios/release/libuniffi_lipalightninglib.a
- name: Upload universal binary
uses: actions/upload-artifact@v4
with:
path: target/universal/release/libuniffi_lipalightninglib_simulator.a
name: build-ios-simulator-universal${{ matrix.mock-deps && '-mock' || '' }}
deploy-ios:
name: deploy-ios
needs: lipo-ios
runs-on: ubuntu-latest
strategy:
matrix:
mock-deps: [ true ]
max-parallel: 1
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set env
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
raw=$(git branch -r --contains ${{ github.ref }})
branch=${raw##*/}
echo "BRANCH=$branch" >> $GITHUB_ENV
- uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.LIPA_BOT_IOS_DEPLOY_KEY }}
- name: Import bot's GPG key for signing commits
id: import-gpg
uses: crazy-max/ghaction-import-gpg@v4
with:
gpg_private_key: ${{ secrets.LIPA_BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.LIPA_BOT_GPG_PASSPHRASE }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
- name: Download aarch64 bin
uses: actions/download-artifact@v4
with:
path: target/aarch64-apple-ios/release
name: build-aarch64-apple-ios${{ matrix.mock-deps && '-mock' || '' }}
- name: Download simulator universal bin
uses: actions/download-artifact@v4
with:
path: target/universal/release
name: build-ios-simulator-universal${{ matrix.mock-deps && '-mock' || '' }}
- name: Download bindings files
uses: actions/download-artifact@v4
with:
path: bindings/swift/
name: bindings-files-ios${{ matrix.mock-deps && '-mock' || '' }}
- name: Create xcframework
run: |
git clone git@github.com:getlipa/lipa-lightning-lib-swift.git
cp bindings/swift/lipalightninglibFFI.h lipa-lightning-lib-swift/lipalightninglibFFI.xcframework/ios-arm64/lipalightninglibFFI.framework/Headers/lipalightninglibFFI.h
cp bindings/swift/lipalightninglibFFI.h lipa-lightning-lib-swift/lipalightninglibFFI.xcframework/ios-arm64_x86_64-simulator/lipalightninglibFFI.framework/Headers/lipalightninglibFFI.h
cp target/aarch64-apple-ios/release/libuniffi_lipalightninglib.a lipa-lightning-lib-swift/lipalightninglibFFI.xcframework/ios-arm64/lipalightninglibFFI.framework/lipalightninglibFFI
cp target/universal/release/libuniffi_lipalightninglib_simulator.a lipa-lightning-lib-swift/lipalightninglibFFI.xcframework/ios-arm64_x86_64-simulator/lipalightninglibFFI.framework/lipalightninglibFFI
cd lipa-lightning-lib-swift
zip -9 -r lipalightninglibFFI.xcframework.zip lipalightninglibFFI.xcframework
- name: Push to target repo
env:
GITHUB_TOKEN: ${{ secrets.LIPA_BOT_ACCESS_TOKEN }}
run: |
cd lipa-lightning-lib-swift
git config --global user.email "lipa-lightning-engineering@getlipa.com"
git config --global user.name "lipa Bot"
cp ../bindings/swift/lipalightninglib.swift Sources/LipaLightningLib/LipaLightningLib.swift
cp Package.swift.template Package.swift
shasum -a 256 lipalightninglibFFI.xcframework.zip | sed 's/ .*//' > checksum
sed -i "s/to_replace_release_version/${{ env.RELEASE_VERSION }}/g" Package.swift
sed -i "s/to_replace_zip_checksum/$(cat checksum)/g" Package.swift
git add Package.swift
git add Sources/LipaLightningLib/LipaLightningLib.swift
git commit -m "This commit was created automatically by the lipa bot"
git restore .
git pull --rebase
git tag -a ${{ env.RELEASE_VERSION }} HEAD -m "This tag was created automatically by the lipa bot."
git push
git push --tag
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.LIPA_BOT_ACCESS_TOKEN }}
if: ${{ env.BRANCH == 'main' }}
run: |
cd lipa-lightning-lib-swift
gh release create ${{ env.RELEASE_VERSION }} \
lipalightninglibFFI.xcframework.zip \
--title "${{ env.RELEASE_VERSION }}" \
--notes "This release was created automatically by the lipa bot. For more information, please access the corresponding release in https://github.com/getlipa/lipa-lightning-lib"
- name: Create pre-release
env:
GITHUB_TOKEN: ${{ secrets.LIPA_BOT_ACCESS_TOKEN }}
if: ${{ env.BRANCH != 'main' }}
run: |
cd lipa-lightning-lib-swift
gh release create ${{ env.RELEASE_VERSION }} \
lipalightninglibFFI.xcframework.zip \
--title "${{ env.RELEASE_VERSION }}" \
--notes "This pre-release was created automatically by the lipa bot. For more information, please access the corresponding release in https://github.com/getlipa/lipa-lightning-lib" \
--prerelease
deploy-android:
name: deploy-android
needs: lipo-ios
runs-on: ubuntu-latest
strategy:
matrix:
mock-deps: [ true ]
max-parallel: 1
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set env
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
raw=$(git branch -r --contains ${{ github.ref }})
branch=${raw##*/}
echo "BRANCH=$branch" >> $GITHUB_ENV
- uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.LIPA_BOT_ANDROID_DEPLOY_KEY }}
- name: Import bot's GPG key for signing commits
id: import-gpg
uses: crazy-max/ghaction-import-gpg@v4
with:
gpg_private_key: ${{ secrets.LIPA_BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.LIPA_BOT_GPG_PASSPHRASE }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
- name: Download aarch64 bin
uses: actions/download-artifact@v4
with:
path: target/aarch64-linux-android/release
name: build-aarch64-linux-android${{ matrix.mock-deps && '-mock' || '' }}
- name: Download armv7 bin
uses: actions/download-artifact@v4
with:
path: target/armv7-linux-androideabi/release
name: build-armv7-linux-androideabi${{ matrix.mock-deps && '-mock' || '' }}
- name: Download i686 bin
uses: actions/download-artifact@v4
with:
path: target/i686-linux-android/release
name: build-i686-linux-android${{ matrix.mock-deps && '-mock' || '' }}
- name: Download bindings file
uses: actions/download-artifact@v4
with:
path: bindings/kotlin/uniffi/lipalightninglib
name: bindings-file-android${{ matrix.mock-deps && '-mock' || '' }}
- name: Push to target repo
run: |
git clone git@github.com:getlipa/lipa-lightning-lib-android.git
cd lipa-lightning-lib-android
git config --global user.email "lipa-lightning-engineering@getlipa.com"
git config --global user.name "lipa Bot"
cp ../bindings/kotlin/uniffi/lipalightninglib/lipalightninglib.kt LipaLightningLib/src/main/java/com/getlipa/lipalightninglib/lipalightninglib.kt
mkdir -p jniLibs/arm64-v8a
mkdir -p jniLibs/armeabi-v7a
mkdir -p jniLibs/x86
wget https://dl.google.com/android/repository/android-ndk-r25c-windows.zip
unzip android-ndk-r25c-windows.zip
mv android-ndk-r25c/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so jniLibs/arm64-v8a
mv android-ndk-r25c/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/lib/arm-linux-androideabi/libc++_shared.so jniLibs/armeabi-v7a
mv android-ndk-r25c/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/lib/i686-linux-android/libc++_shared.so jniLibs/x86
cp ../target/aarch64-linux-android/release/libuniffi_lipalightninglib.so jniLibs/arm64-v8a
cp ../target/armv7-linux-androideabi/release/libuniffi_lipalightninglib.so jniLibs/armeabi-v7a
cp ../target/i686-linux-android/release/libuniffi_lipalightninglib.so jniLibs/x86
zip -r jniLibs.zip jniLibs
shasum -a 256 jniLibs.zip | sed 's/ .*//' > checksum
cp jitpack.yml.template jitpack.yml
sed -i "s/to_replace_release_version/${{ env.RELEASE_VERSION }}/g" jitpack.yml
sed -i "s/to_replace_zip_checksum/$(cat checksum)/g" jitpack.yml
git add LipaLightningLib/src/main/java/com/getlipa/lipalightninglib/lipalightninglib.kt
git add jitpack.yml
git commit -m "This commit was created automatically by the lipa bot"
git pull --rebase
git tag -a ${{ env.RELEASE_VERSION }} HEAD -m "This tag was created automatically by the lipa bot."
git push
git push --tag
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.LIPA_BOT_ACCESS_TOKEN }}
if: ${{ env.BRANCH == 'main' }}
run: |
cd lipa-lightning-lib-android
gh release create ${{ env.RELEASE_VERSION }} \
jniLibs.zip \
--title "${{ env.RELEASE_VERSION }}" \
--notes "This release was created automatically by the lipa bot. For more information, please access the corresponding release in https://github.com/getlipa/lipa-lightning-lib"
- name: Create pre-release
env:
GITHUB_TOKEN: ${{ secrets.LIPA_BOT_ACCESS_TOKEN }}
if: ${{ env.BRANCH != 'main' }}
run: |
cd lipa-lightning-lib-android
gh release create ${{ env.RELEASE_VERSION }} \
jniLibs.zip \
--title "${{ env.RELEASE_VERSION }}" \
--notes "This pre-release was created automatically by the lipa bot. For more information, please access the corresponding release in https://github.com/getlipa/lipa-lightning-lib" \
--prerelease
- name: Trigger JitPack build
run: |
curl -s -m 30 https://jitpack.io/com/github/getlipa/lipa-lightning-lib-android/${{ env.RELEASE_VERSION }} || true
determine-branch:
name: determine-branch
needs:
- deploy-ios
- deploy-android
runs-on: ubuntu-latest
outputs:
is_main: ${{ steps.set-var.outputs.is_main }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get Branch Name
id: get-branch
run: |
BRANCH_NAMES=$(git branch -r --contains ${GITHUB_REF_NAME} | grep origin | sed 's/origin\///' | sed 's/ //g' | sed ':a;N;$!ba;s/\n//g')
echo "BRANCH_NAMES=$BRANCH_NAMES" >> "$GITHUB_ENV"
echo "Branch names: $BRANCH_NAMES"
- name: Set Output Variable
id: set-var
run: |
if [[ $BRANCH_NAMES == *'main'* ]]; then
echo "::set-output name=is_main::true"
echo "Setting is_main to true"
else
echo "::set-output name=is_main::false"
echo "Setting is_main to false"
fi
build-docs:
name: build-docs
needs:
- determine-branch
if: needs.determine-branch.outputs.is_main == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Config cargo
run: echo -e "$CARGO_CONFIG_TOML_BREEZ" > .cargo/config.toml
env:
CARGO_CONFIG_TOML_BREEZ: ${{ secrets.CARGO_CONFIG_TOML_BREEZ }}
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.77.1
profile: minimal
override: true
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docs
run: make doc
# Set the right file permissions, based on https://github.com/actions/upload-pages-artifact#file-permissions
- name: Fix file permissions
shell: sh
run: |
chmod -c -R +rX "./libs/target/doc/" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: './target/doc'
deploy-docs:
name: deploy-docs
needs: build-docs
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1