-
Notifications
You must be signed in to change notification settings - Fork 46
141 lines (127 loc) · 6.12 KB
/
publish-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
name: Publish Swift Package & CocoaPod
on:
workflow_call:
inputs:
repository:
description: 'sdk repository, defaults to current repository'
required: false
type: string
ref:
description: 'commit/tag/branch reference'
required: true
type: string
package-version:
description: 'version for the swift package / cocoapod (MAJOR.MINOR.BUILD) (no v prefix)'
required: true
type: string
publish:
description: 'value indicating whether to commit/tag a release.'
required: true
type: boolean
default: true
secrets:
REPO_SSH_KEY:
description: 'ssh key to commit to the breez-sdk-swift repository'
required: true
SWIFT_RELEASE_TOKEN:
description: 'token to create a release to the breez-sdk-swift repository'
required: true
COCOAPODS_TRUNK_TOKEN:
description: 'token to publish to cocoapods'
required: true
jobs:
build-tag-release:
runs-on: macos-latest
steps:
- name: Checkout breez-sdk-swift repo
uses: actions/checkout@v3
with:
repository: breez/breez-sdk-swift
ssh-key: ${{ secrets.REPO_SSH_KEY }}
path: breez-sdk-swift
- name: Checkout breez-sdk repo
uses: actions/checkout@v3
with:
repository: ${{ inputs.repository || github.repository }}
ref: ${{ inputs.ref || github.sha }}
path: breez-sdk
- uses: actions/download-artifact@v4
with:
name: bindings-swift
path: breez-sdk/libs/sdk-bindings/bindings-swift/Sources/BreezSDK/
- uses: actions/download-artifact@v4
with:
name: sdk-bindings-aarch64-apple-ios
path: breez-sdk/libs/target/aarch64-apple-ios/release/
- uses: actions/download-artifact@v4
with:
name: sdk-bindings-ios-universal-sim
path: breez-sdk/libs/target/ios-universal-sim/release/
- uses: actions/download-artifact@v4
with:
name: sdk-bindings-darwin-universal
path: breez-sdk/libs/target/darwin-universal/release/
- name: Create XCFramework
working-directory: breez-sdk/libs/sdk-bindings
run: |
cp bindings-swift/Sources/BreezSDK/breez_sdkFFI.h bindings-swift/breez_sdkFFI.xcframework/ios-arm64/breez_sdkFFI.framework/Headers
cp bindings-swift/Sources/BreezSDK/breez_sdkFFI.h bindings-swift/breez_sdkFFI.xcframework/ios-arm64_x86_64-simulator/breez_sdkFFI.framework/Headers
cp bindings-swift/Sources/BreezSDK/breez_sdkFFI.h bindings-swift/breez_sdkFFI.xcframework/macos-arm64_x86_64/breez_sdkFFI.framework/Headers
cp ../target/aarch64-apple-ios/release/libbreez_sdk_bindings.a bindings-swift/breez_sdkFFI.xcframework/ios-arm64/breez_sdkFFI.framework/breez_sdkFFI
cp ../target/ios-universal-sim/release/libbreez_sdk_bindings.a bindings-swift/breez_sdkFFI.xcframework/ios-arm64_x86_64-simulator/breez_sdkFFI.framework/breez_sdkFFI
cp ../target/darwin-universal/release/libbreez_sdk_bindings.a bindings-swift/breez_sdkFFI.xcframework/macos-arm64_x86_64/breez_sdkFFI.framework/breez_sdkFFI
rm bindings-swift/Sources/BreezSDK/breez_sdkFFI.h
rm bindings-swift/Sources/BreezSDK/breez_sdkFFI.modulemap
- name: Compress xcframework
working-directory: breez-sdk/libs/sdk-bindings/bindings-swift
run: |
zip -9 -r breez_sdkFFI.xcframework.zip breez_sdkFFI.xcframework
echo "XCF_CHECKSUM=`swift package compute-checksum breez_sdkFFI.xcframework.zip`" >> $GITHUB_ENV
- name: Archive xcframework
uses: actions/upload-artifact@v4
with:
name: breez_sdkFFI-${{ inputs.package-version || inputs.ref }}.xcframework
path: breez-sdk/libs/sdk-bindings/bindings-swift/breez_sdkFFI.xcframework
- name: Update swift package
working-directory: breez-sdk/libs/sdk-bindings/bindings-swift
run: |
# Update package definition
sed 's#.binaryTarget(name: "breez_sdkFFI", path: "./breez_sdkFFI.xcframework"),#.binaryTarget(name: "breez_sdkFFI", url: "https://github.com/breez/breez-sdk-swift/releases/download/${{ inputs.package-version }}/breez_sdkFFI.xcframework.zip", checksum: "${{ env.XCF_CHECKSUM }}"),#;/.testTarget(name: "BreezSDKTests", dependencies: \["BreezSDK"\]),/d' Package.swift > ../../../../breez-sdk-swift/Package.swift
# Update language bindings
cp -r Sources ../../../../breez-sdk-swift
- name: Update cocoapods definitions
working-directory: breez-sdk-swift
run: |
sed -i '' 's#^.\{2\}spec.version.*$# spec.version = "${{ inputs.package-version }}"#' breez_sdkFFI.podspec
sed -i '' 's#^.\{2\}spec.version.*$# spec.version = "${{ inputs.package-version }}"#' BreezSDK.podspec
- name: Tag swift package
working-directory: breez-sdk-swift
if: ${{ inputs.publish }}
run: |
git add Package.swift
git add Sources
git add breez_sdkFFI.podspec
git add BreezSDK.podspec
git commit -m "Update Breez SDK Swift bindings to version ${{ inputs.package-version }}"
git push
git tag ${{ inputs.package-version }} -m "${{ inputs.package-version }}"
git push --tags
- name: Release and attach XCFramework binary artifact
if: ${{ inputs.publish }}
uses: softprops/action-gh-release@v2
with:
repository: breez/breez-sdk-swift
files: |
breez-sdk/libs/sdk-bindings/bindings-swift/breez_sdkFFI.xcframework.zip
tag_name: ${{ inputs.package-version }}
generate_release_notes: false
token: ${{ secrets.SWIFT_RELEASE_TOKEN }}
prerelease: true
- name: Push update to Cocoapods trunk
working-directory: breez-sdk-swift
if: ${{ inputs.publish }}
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
run: |
pod trunk push breez_sdkFFI.podspec --allow-warnings
pod trunk push BreezSDK.podspec --allow-warnings --synchronous