Publish Swift Bindings #91
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Swift Bindings | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'breez-sdk repo release (MAJOR.MINOR.PATCH)' | |
required: true | |
type: string | |
env: | |
DEVELOPER_DIR: /Applications/Xcode_14.3.1.app/Contents/Developer | |
jobs: | |
build-tag-release: | |
name: Build, tag, and release the Breez SDK Swift bindings | |
runs-on: macos-13 | |
steps: | |
- name: Install required dependencies | |
run: | | |
brew install protobuf | |
cargo install --version 0.22.0 uniffi_bindgen | |
- name: Checkout breez-sdk repo | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ github.repository_owner }}/breez-sdk | |
path: build | |
ref: ${{ inputs.version }} | |
- name: Checkout breez-sdk-swift repo | |
uses: actions/checkout@v3 | |
with: | |
path: dist | |
- name: Build Swift bindings | |
working-directory: build/libs/sdk-bindings | |
env: | |
SSH_PRIVATE_KEY: ${{secrets.REPO_SSH_KEY}} | |
run: | | |
mkdir -p ~/.ssh | |
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa | |
sudo chmod 600 ~/.ssh/id_rsa | |
ssh-add ~/.ssh/id_rsa | |
make init | |
make bindings-swift | |
- name: Compress XCFramework | |
working-directory: build/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: Update Swift Package definition | |
working-directory: build/libs/sdk-bindings/bindings-swift | |
run: | | |
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.version }}/breez_sdkFFI.xcframework.zip", checksum: "${{ env.XCF_CHECKSUM }}"),#;/.testTarget(name: "BreezSDKTests", dependencies: \["BreezSDK"\]),/d' Package.swift > ../../../../dist/Package.swift | |
rm -rf ../../../../../dist/Sources | |
cp -r Sources ../../../../dist | |
- name: Update Cocoapods definitions | |
working-directory: dist | |
run: | | |
sed -i '' 's#^.\{2\}spec.version.*$# spec.version = "${{ inputs.version }}"#' breez_sdkFFI.podspec | |
sed -i '' 's#^.\{2\}spec.version.*$# spec.version = "${{ inputs.version }}"#' BreezSDK.podspec | |
- name: Tag the Swift bindings | |
working-directory: dist | |
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.version }}" | |
git push | |
git tag ${{ inputs.version }} -m "${{ inputs.version }}" | |
git push --tags | |
- name: Release and attach XCFramework binary artifact | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "build/libs/sdk-bindings/bindings-swift/breez_sdkFFI.xcframework.zip" | |
tag: ${{ inputs.version }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: ${{ inputs.version }} | |
prerelease: true | |
- name: Push update to Cocoapods trunk | |
working-directory: dist | |
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 |