|
| 1 | +name: Build, tag and create release |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + branch: |
| 6 | + description: 'Release branch, eg. release/0.MINOR' |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + version: |
| 10 | + description: 'New release version, eg. 0.MINOR.PATCH' |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + |
| 14 | +jobs: |
| 15 | + build-publish: |
| 16 | + name: Build, tag and create release |
| 17 | + runs-on: macos-12 |
| 18 | + steps: |
| 19 | + - name: Checkout release branch |
| 20 | + uses: actions/checkout@v2 |
| 21 | + with: |
| 22 | + ref: ${{ inputs.branch }} |
| 23 | + submodules: true |
| 24 | + |
| 25 | + - name: Cache |
| 26 | + uses: actions/cache@v3 |
| 27 | + with: |
| 28 | + path: | |
| 29 | + ~/.cargo/registry |
| 30 | + ~/.cargo/git |
| 31 | + ./bdk-ffi/target |
| 32 | + key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} |
| 33 | + |
| 34 | + - name: Install Rust targets |
| 35 | + run: | |
| 36 | + rustup install nightly-x86_64-apple-darwin |
| 37 | + rustup component add rust-src --toolchain nightly-x86_64-apple-darwin |
| 38 | + rustup target add aarch64-apple-ios x86_64-apple-ios |
| 39 | + rustup target add aarch64-apple-ios-sim --toolchain nightly |
| 40 | + rustup target add aarch64-apple-darwin x86_64-apple-darwin |
| 41 | +
|
| 42 | + - name: Run bdk-ffi-bindgen |
| 43 | + working-directory: bdk-ffi |
| 44 | + run: | |
| 45 | + cargo run --package bdk-ffi-bindgen -- --language swift --out-dir ../Sources/BitcoinDevKit |
| 46 | +
|
| 47 | + - name: Build bdk-ffi for x86_64-apple-darwin |
| 48 | + working-directory: bdk-ffi |
| 49 | + run: | |
| 50 | + cargo build --release --target x86_64-apple-darwin |
| 51 | +
|
| 52 | + - name: Build bdk-ffi for aarch64-apple-darwin |
| 53 | + working-directory: bdk-ffi |
| 54 | + run: | |
| 55 | + cargo build --release --target aarch64-apple-darwin |
| 56 | +
|
| 57 | + - name: Build bdk-ffi for x86_64-apple-ios |
| 58 | + working-directory: bdk-ffi |
| 59 | + run: | |
| 60 | + cargo build --release --target x86_64-apple-ios |
| 61 | +
|
| 62 | + - name: Build bdk-ffi for aarch64-apple-ios |
| 63 | + working-directory: bdk-ffi |
| 64 | + run: | |
| 65 | + cargo build --release --target aarch64-apple-ios |
| 66 | +
|
| 67 | + - name: Build bdk-ffi for aarch64-apple-ios-sim |
| 68 | + working-directory: bdk-ffi |
| 69 | + run: | |
| 70 | + cargo +nightly build --release -Z build-std --target aarch64-apple-ios-sim |
| 71 | +
|
| 72 | + - name: Create lipo-ios-sim and lipo-macos |
| 73 | + working-directory: bdk-ffi |
| 74 | + run: | |
| 75 | + mkdir -p target/lipo-ios-sim/release |
| 76 | + lipo target/aarch64-apple-ios-sim/release/libbdkffi.a target/x86_64-apple-ios/release/libbdkffi.a -create -output target/lipo-ios-sim/release/libbdkffi.a |
| 77 | + mkdir -p target/lipo-macos/release |
| 78 | + lipo target/aarch64-apple-darwin/release/libbdkffi.a target/x86_64-apple-darwin/release/libbdkffi.a -create -output target/lipo-macos/release/libbdkffi.a |
| 79 | +
|
| 80 | + - name: Create bdkFFI.xcframework |
| 81 | + run: | |
| 82 | + mv Sources/BitcoinDevKit/bdk.swift Sources/BitcoinDevKit/BitcoinDevKit.swift |
| 83 | + cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/ios-arm64/bdkFFI.framework/Headers |
| 84 | + cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/Headers |
| 85 | + cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/Headers |
| 86 | + cp bdk-ffi/target/aarch64-apple-ios/release/libbdkffi.a bdkFFI.xcframework/ios-arm64/bdkFFI.framework/bdkFFI |
| 87 | + cp bdk-ffi/target/lipo-ios-sim/release/libbdkffi.a bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/bdkFFI |
| 88 | + cp bdk-ffi/target/lipo-macos/release/libbdkffi.a bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/bdkFFI |
| 89 | + rm Sources/BitcoinDevKit/bdkFFI.h |
| 90 | + rm Sources/BitcoinDevkit/bdkFFI.modulemap |
| 91 | + rm bdkFFI.xcframework.zip || true |
| 92 | + zip -9 -r bdkFFI.xcframework.zip bdkFFI.xcframework |
| 93 | + echo "BDKFFICHECKSUM=`swift package compute-checksum bdkFFI.xcframework.zip`" >> $GITHUB_ENV |
| 94 | + echo "BDKFFIURL=https\:\/\/github\.com\/${{ github.repository_owner }}\/bdk\-swift\/releases\/download\/${{ inputs.version }}\/bdkFFI\.xcframework\.zip" >> $GITHUB_ENV |
| 95 | +
|
| 96 | + - name: Update, commit, and push new Package.swift |
| 97 | + run: | |
| 98 | + echo checksum = ${{ env.BDKFFICHECKSUM }} |
| 99 | + echo url = ${{ env.BDKFFIURL }} |
| 100 | + sed "s/BDKFFICHECKSUM/${BDKFFICHECKSUM}/;s/BDKFFIURL/${BDKFFIURL}/" Package.swift.txt > Package.swift |
| 101 | + git add Package.swift |
| 102 | + git commit -m "Update Package.swift for release ${{ inputs.version }}" |
| 103 | + git push |
| 104 | +
|
| 105 | + - name: Tag new release |
| 106 | + run: | |
| 107 | + git tag ${{ inputs.version }} -m "Release ${{ inputs.version }}" |
| 108 | + git push --tags |
| 109 | +
|
| 110 | + - name: Publish release |
| 111 | + uses: ncipollo/release-action@v1 |
| 112 | + with: |
| 113 | + artifacts: "bdkFFI.xcframework.zip" |
| 114 | + tag: ${{ inputs.version }} |
| 115 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 116 | + name: Release ${{ inputs.version }} |
| 117 | + prerelease: true |
0 commit comments