Skip to content

Commit beca56b

Browse files
committed
Add publish-spm github actions workflow
1 parent 7ba5f37 commit beca56b

File tree

3 files changed

+153
-76
lines changed

3 files changed

+153
-76
lines changed

.github/workflows/publish-spm.yaml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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

Package.swift.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// swift-tools-version:5.5
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "bdk-swift",
8+
platforms: [
9+
.macOS(.v12),
10+
.iOS(.v15)
11+
],
12+
products: [
13+
// Products define the executables and libraries a package produces, and make them visible to other packages.
14+
.library(
15+
name: "BitcoinDevKit",
16+
targets: ["bdkFFI", "BitcoinDevKit"]),
17+
],
18+
dependencies: [
19+
// Dependencies declare other packages that this package depends on.
20+
// .package(url: /* package url */, from: "1.0.0"),
21+
],
22+
targets: [
23+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
24+
// Targets can depend on other targets in this package, and on products in packages this package depends on.
25+
.binaryTarget(
26+
name: "bdkFFI",
27+
url: "BDKFFIURL",
28+
checksum: "BDKFFICHECKSUM"),
29+
.target(
30+
name: "BitcoinDevKit",
31+
dependencies: ["bdkFFI"]),
32+
.testTarget(
33+
name: "BitcoinDevKitTests",
34+
dependencies: ["BitcoinDevKit"]),
35+
]
36+
)

build.sh

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)