Build, Tag and Create Release #25
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: Build, Tag and Create Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "New release version, eg. 0.MINOR.PATCH" | |
required: true | |
type: string | |
ffitag: | |
description: "The bdk-ffi tag to use for the release" | |
required: true | |
type: string | |
jobs: | |
build-publish: | |
name: Build, tag and create release | |
runs-on: macos-12 | |
steps: | |
- name: "Checkout build repo" | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ github.repository_owner }}/bdk-ffi | |
path: build | |
ref: ${{ inputs.ffitag }} | |
- name: "Checkout dist repo" | |
uses: actions/checkout@v3 | |
with: | |
path: dist | |
- name: "Install Rust targets" | |
working-directory: build/bdk-ffi | |
run: | | |
rustup install 1.73.0 | |
rustup component add rust-src | |
rustup target add aarch64-apple-ios # iOS ARM64 | |
rustup target add x86_64-apple-ios # iOS x86_64 | |
rustup target add aarch64-apple-ios-sim # simulator mac M1 | |
rustup target add aarch64-apple-darwin # mac M1 | |
rustup target add x86_64-apple-darwin # mac x86_64 | |
- name: "Run bdk-ffi-bindgen" | |
working-directory: build/bdk-ffi | |
run: | | |
cargo run --bin uniffi-bindgen generate src/bdk.udl --language swift --out-dir ../bdk-swift/Sources/BitcoinDevKit --no-format | |
- name: "Build bdk-ffi for all targets" | |
working-directory: build/bdk-ffi | |
run: | | |
cargo build --profile release-smaller --target x86_64-apple-darwin | |
cargo build --profile release-smaller --target aarch64-apple-darwin | |
cargo build --profile release-smaller --target x86_64-apple-ios | |
cargo build --profile release-smaller --target aarch64-apple-ios | |
cargo build --profile release-smaller --target aarch64-apple-ios-sim | |
- name: "Create lipo-ios-sim and lipo-macos" | |
working-directory: build/bdk-ffi | |
run: | | |
mkdir -p target/lipo-ios-sim/release-smaller | |
lipo target/aarch64-apple-ios-sim/release-smaller/libbdkffi.a target/x86_64-apple-ios/release-smaller/libbdkffi.a -create -output target/lipo-ios-sim/release-smaller/libbdkffi.a | |
mkdir -p target/lipo-macos/release-smaller | |
lipo target/aarch64-apple-darwin/release-smaller/libbdkffi.a target/x86_64-apple-darwin/release-smaller/libbdkffi.a -create -output target/lipo-macos/release-smaller/libbdkffi.a | |
- name: "Create bdkFFI.xcframework" | |
working-directory: build/bdk-swift | |
run: | | |
mv Sources/BitcoinDevKit/bdk.swift Sources/BitcoinDevKit/BitcoinDevKit.swift | |
cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/ios-arm64/bdkFFI.framework/Headers | |
cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/Headers | |
cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/Headers | |
cp ../bdk-ffi/target/aarch64-apple-ios/release-smaller/libbdkffi.a bdkFFI.xcframework/ios-arm64/bdkFFI.framework/bdkFFI | |
cp ../bdk-ffi/target/lipo-ios-sim/release-smaller/libbdkffi.a bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/bdkFFI | |
cp ../bdk-ffi/target/lipo-macos/release-smaller/libbdkffi.a bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/bdkFFI | |
rm Sources/BitcoinDevKit/bdkFFI.h | |
rm Sources/BitcoinDevkit/bdkFFI.modulemap | |
rm bdkFFI.xcframework.zip || true | |
zip -9 -r bdkFFI.xcframework.zip bdkFFI.xcframework | |
echo "BDKFFICHECKSUM=`swift package compute-checksum bdkFFI.xcframework.zip`" >> $GITHUB_ENV | |
echo "BDKFFIURL=https\:\/\/github\.com\/${{ github.repository_owner }}\/bdk\-swift\/releases\/download\/${{ inputs.version }}\/bdkFFI\.xcframework\.zip" >> $GITHUB_ENV | |
- name: "Update and tag release dist repo" | |
working-directory: build/bdk-swift | |
run: | | |
echo checksum = ${{ env.BDKFFICHECKSUM }} | |
echo url = ${{ env.BDKFFIURL }} | |
sed "s/BDKFFICHECKSUM/${BDKFFICHECKSUM}/;s/BDKFFIURL/${BDKFFIURL}/" Package.swift.txt > ../../dist/Package.swift | |
cp Sources/BitcoinDevKit/BitcoinDevKit.swift ../../dist/Sources/BitcoinDevKit/BitcoinDevKit.swift | |
cd ../../dist | |
git add Sources/BitcoinDevKit/BitcoinDevKit.swift | |
git add Package.swift | |
git commit -m "Update BitcoinDevKit.swift and Package.swift for release ${{ inputs.version }}" | |
git push | |
git tag ${{ inputs.version }} -m "Release ${{ inputs.version }}" | |
git push --tags | |
- name: "Create release" | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "build/bdk-swift/bdkFFI.xcframework.zip" | |
tag: ${{ inputs.version }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: Release ${{ inputs.version }} | |
prerelease: true |