Publish Swift Bindings #6
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: 'LWK repo release (MAJOR.MINOR.PATCH)' | |
required: true | |
type: string | |
jobs: | |
build-tag-release: | |
name: Build, tag, and release the LWK SDK Swift bindings | |
runs-on: macos-14 | |
steps: | |
- name: ENV | |
run: env | |
- name: Set release version | |
run: | | |
echo "VERSION=$(echo ${{ inputs.version }} | sed 's/bindings_//')" >> $GITHUB_ENV | |
- name: Version | |
run: | | |
echo "New tag: ${VERSION}" | |
- name: Setup rust toolchain | |
uses: dtolnay/[email protected] | |
with: | |
targets: x86_64-apple-ios,aarch64-apple-ios,aarch64-apple-ios-sim | |
- name: Setup just | |
uses: extractions/setup-just@v2 | |
with: | |
just-version: 1.5.0 # optional semver specification, otherwise latest | |
- name: Checkout lwk-swift repo | |
uses: actions/checkout@v4 | |
with: | |
repository: Blockstream/lwk-swift | |
ref: main | |
- name: Checkout lwk repo | |
uses: actions/checkout@v4 | |
with: | |
repository: Blockstream/lwk | |
ref: ${{ inputs.version }} | |
path: build | |
- name: Build Swift bindings | |
working-directory: build | |
run: just swift | |
- name: Compress XCFramework | |
working-directory: build | |
run: | | |
zip -9 -r target/lwkFFI.xcframework.zip target/lwkFFI.xcframework | |
echo "XCF_CHECKSUM=`swift package compute-checksum lwkFFI.xcframework.zip`" >> $GITHUB_ENV | |
- name: LS | |
run: ls | |
- name: Update Swift Package definition | |
run: | | |
sed -i '' 's#.binaryTarget(name: "lwkFFI".*$#.binaryTarget(name: "lwkFFI", url: "https://github.com/Blockstream/lwk-swift/releases/download/${VERSION}/lwkFFI.xcframework.zip", checksum: "${{ env.XCF_CHECKSUM }}"),#' Package.swift | |
- name: Update Cocoapods definitions | |
run: | | |
sed -i '' 's/^.\{4\}spec.version.*$/ spec.version = "${VERSION}"/g' lwkFFI.podspec | |
sed -i '' 's/^.\{4\}spec.source.*$/ spec.source = { :http => "https://github.com/Blockstream/lwk-swift/releases/download/${VERSION}/lwkFFI.xcframework.zip" }/g' lwkFFI.podspec | |
sed -i '' 's/^.\{4\}spec.version.*$/ spec.version = "${VERSION}"/g' LiquidWalletKit.podspec | |
- name: Tag the Swift bindings | |
run: | | |
git add Package.swift | |
git add Sources | |
git add lwkFFI.podspec | |
git add LiquidWalletKit.podspec | |
git commit -m "Bump Liquid Wallet Kit to version ${VERSION}" | |
git push | |
git tag ${VERSION} -m "${VERSION}" | |
git push --tags | |
- name: Release and attach XCFramework binary artifact | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "build/target/lwkFFI.xcframework.zip" | |
tag: ${VERSION} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: ${VERSION} | |
prerelease: true | |
- name: Push update to Cocoapods trunk | |
env: | |
COCOAPODS_TRUNK_TOKEN: ${{secrets.COCOAPODS_TRUNK_TOKEN}} | |
run: | | |
pod trunk push lwkFFI.podspec --allow-warnings | |
pod trunk push LiquidWalletKit.podspec --allow-warnings --synchronous |