Skip to content

Commit dc596a4

Browse files
committed
Update publish-spm workflow
1 parent d2a2073 commit dc596a4

File tree

2 files changed

+42
-60
lines changed

2 files changed

+42
-60
lines changed

.github/workflows/publish-spm.yaml

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,20 @@ jobs:
1212
name: Build, tag and create release
1313
runs-on: macos-12
1414
steps:
15-
- name: Checkout release branch
16-
uses: actions/checkout@v2
15+
- name: Checkout build repo
16+
uses: actions/checkout@v3
1717
with:
18-
submodules: true
18+
repository: ${{ github.repository_owner }}/bdk-ffi
19+
path: build
20+
ref: v${{ inputs.version }}
1921

20-
- name: Cache
21-
uses: actions/cache@v3
22+
- name: Checkout dist repo
23+
uses: actions/checkout@v3
2224
with:
23-
path: |
24-
~/.cargo/registry
25-
~/.cargo/git
26-
./bdk-ffi/target
27-
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
25+
path: dist
2826

2927
- name: Install Rust targets
28+
working-directory: build
3029
run: |
3130
rustup install nightly-x86_64-apple-darwin
3231
rustup component add rust-src --toolchain nightly-x86_64-apple-darwin
@@ -35,78 +34,79 @@ jobs:
3534
rustup target add aarch64-apple-darwin x86_64-apple-darwin
3635
3736
- name: Run bdk-ffi-bindgen
38-
working-directory: bdk-ffi
37+
working-directory: build/bdk-ffi
3938
run: |
40-
cargo run --package bdk-ffi-bindgen -- --language swift --out-dir ../Sources/BitcoinDevKit
39+
cargo run --package bdk-ffi-bindgen -- --language swift --out-dir ../bdk-swift/Sources/BitcoinDevKit
4140
4241
- name: Build bdk-ffi for x86_64-apple-darwin
43-
working-directory: bdk-ffi
42+
working-directory: build
4443
run: |
4544
cargo build --profile release-smaller --target x86_64-apple-darwin
4645
4746
- name: Build bdk-ffi for aarch64-apple-darwin
48-
working-directory: bdk-ffi
47+
working-directory: build
4948
run: |
5049
cargo build --profile release-smaller --target aarch64-apple-darwin
5150
5251
- name: Build bdk-ffi for x86_64-apple-ios
53-
working-directory: bdk-ffi
52+
working-directory: build
5453
run: |
5554
cargo build --profile release-smaller --target x86_64-apple-ios
5655
5756
- name: Build bdk-ffi for aarch64-apple-ios
58-
working-directory: bdk-ffi
57+
working-directory: build
5958
run: |
6059
cargo build --profile release-smaller --target aarch64-apple-ios
6160
6261
- name: Build bdk-ffi for aarch64-apple-ios-sim
63-
working-directory: bdk-ffi
62+
working-directory: build
6463
run: |
6564
cargo +nightly build --release -Z build-std --target aarch64-apple-ios-sim
6665
6766
- name: Create lipo-ios-sim and lipo-macos
68-
working-directory: bdk-ffi
67+
working-directory: build
6968
run: |
7069
mkdir -p target/lipo-ios-sim/release-smaller
7170
lipo target/aarch64-apple-ios-sim/release/libbdkffi.a target/x86_64-apple-ios/release-smaller/libbdkffi.a -create -output target/lipo-ios-sim/release-smaller/libbdkffi.a
7271
mkdir -p target/lipo-macos/release-smaller
7372
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
7473
7574
- name: Create bdkFFI.xcframework
75+
working-directory: build/bdk-swift
7676
run: |
7777
mv Sources/BitcoinDevKit/bdk.swift Sources/BitcoinDevKit/BitcoinDevKit.swift
7878
cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/ios-arm64/bdkFFI.framework/Headers
7979
cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/Headers
8080
cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/Headers
81-
cp bdk-ffi/target/aarch64-apple-ios/release-smaller/libbdkffi.a bdkFFI.xcframework/ios-arm64/bdkFFI.framework/bdkFFI
82-
cp bdk-ffi/target/lipo-ios-sim/release-smaller/libbdkffi.a bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/bdkFFI
83-
cp bdk-ffi/target/lipo-macos/release-smaller/libbdkffi.a bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/bdkFFI
81+
cp ../target/aarch64-apple-ios/release-smaller/libbdkffi.a bdkFFI.xcframework/ios-arm64/bdkFFI.framework/bdkFFI
82+
cp ../target/lipo-ios-sim/release-smaller/libbdkffi.a bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/bdkFFI
83+
cp ../target/lipo-macos/release-smaller/libbdkffi.a bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/bdkFFI
8484
rm Sources/BitcoinDevKit/bdkFFI.h
8585
rm Sources/BitcoinDevkit/bdkFFI.modulemap
8686
rm bdkFFI.xcframework.zip || true
8787
zip -9 -r bdkFFI.xcframework.zip bdkFFI.xcframework
8888
echo "BDKFFICHECKSUM=`swift package compute-checksum bdkFFI.xcframework.zip`" >> $GITHUB_ENV
8989
echo "BDKFFIURL=https\:\/\/github\.com\/${{ github.repository_owner }}\/bdk\-swift\/releases\/download\/${{ inputs.version }}\/bdkFFI\.xcframework\.zip" >> $GITHUB_ENV
9090
91-
- name: Update, commit, and push new Package.swift
91+
- name: Update and tag release dist repo
92+
working-directory: build/bdk-swift
9293
run: |
9394
echo checksum = ${{ env.BDKFFICHECKSUM }}
9495
echo url = ${{ env.BDKFFIURL }}
95-
sed "s/BDKFFICHECKSUM/${BDKFFICHECKSUM}/;s/BDKFFIURL/${BDKFFIURL}/" Package.swift.txt > Package.swift
96+
sed "s/BDKFFICHECKSUM/${BDKFFICHECKSUM}/;s/BDKFFIURL/${BDKFFIURL}/" Package.swift.txt > > ../../dist/Package.swift
97+
cp Sources/Calculator/Calculator.swift ../../dist/Sources/Calculator/Calculator.swift
98+
cd ../../dist
9699
git add Sources/BitcoinDevKit/BitcoinDevKit.swift
97100
git add Package.swift
98101
git commit -m "Update BitcoinDevKit.swift and Package.swift for release ${{ inputs.version }}"
99102
git push
100-
101-
- name: Tag new release
102-
run: |
103103
git tag ${{ inputs.version }} -m "Release ${{ inputs.version }}"
104104
git push --tags
105105
106-
- name: Publish release
106+
- name: Create release
107107
uses: ncipollo/release-action@v1
108108
with:
109-
artifacts: "bdkFFI.xcframework.zip"
109+
artifacts: "build/bdk-swift/bdkFFI.xcframework.zip"
110110
tag: ${{ inputs.version }}
111111
token: ${{ secrets.GITHUB_TOKEN }}
112112
name: Release ${{ inputs.version }}

README.md

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,23 @@
11
# bdk-swift
22

3-
This project builds a Swift package that provides [Swift] language bindings for the
4-
[`bdk`] library. The Swift language bindings are created by the [`bdk-ffi`] project which
5-
is included as a git submodule of this repository.
3+
This project is only used to publish a [Swift] package manager package called `bdk-swift` with language bindings and corresponding bdkFFI.xcframework for the
4+
`BitcoinDevKit` framework created by the [bdk-ffi] project. The Swift language bindings files are created by the [bdk-ffi] `./bdk-ffi` sub-project which are copied into, committed and tagged in this `bdk-swift` repo by the `publish-spm` github actions workflow.
65

7-
## How to Use
8-
9-
To use the Swift language bindings for [`bdk`] in your [Xcode] iOS or MacOS project add
10-
the github repository (https://github.com/bitcoindevkit/bdk-swift) and select one of the
11-
release versions. You may then import and use the `BitcoinDevKit` library in your Swift
12-
code. For example:
13-
14-
```swift
15-
import BitcoinDevKit
16-
17-
...
18-
let desc = "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)"
19-
let databaseConfig = DatabaseConfig.memory
20-
let wallet = try Wallet.init(descriptor: desc, changeDescriptor: nil, network: Network.regtest, databaseConfig: databaseConfig)
21-
let addressInfo = try wallet.getAddress(addressIndex: AddressIndex.new)
22-
```
6+
Any changes to the `bdk-swift` Swift package must be made via the [bdk-ffi] repo.
237

24-
### Example Projects
25-
26-
* [BdkSwiftSample](https://github.com/futurepaul/BdkSwiftSample)
27-
28-
## How to Build and Publish
8+
## How to Use
299

30-
If you are a maintainer of this project or want to build and publish this project to your
31-
own Github repository use the following steps:
10+
To use the Swift language bindings for `BitcoinDevKit` in your [Xcode] iOS or MacOS project:
3211

33-
1. If it doesn't already exist, create a new `release/0.MINOR` branch from the `master` branch
34-
2. Run the `publish-spm` workflow on Github for branch `release/0.MINOR` and version `0.MINOR.0`
35-
3. Copy the changelog from corresponding `bdk-ffi` release description to this release
12+
1. Add the "bdk-swift" package from the repo https://github.com/bitcoindevkit/bdk-swift and select one of the latest minor versions.
13+
2. Add the `BitcoinDevKit` framework in your Target config.
14+
3. Import and use the `BitcoinDevKit` library in your Swift code. For example:
15+
```swift
16+
import BitcoinDevKit
17+
18+
...
19+
```
3620

3721
[Swift]: https://developer.apple.com/swift/
3822
[Xcode]: https://developer.apple.com/documentation/Xcode
39-
[`bdk`]: https://github.com/bitcoindevkit/bdk
40-
[`bdk-ffi`]: https://github.com/bitcoindevkit/bdk-ffi
41-
["Getting Started (Developer)"]: https://github.com/bitcoindevkit/bdk-ffi#getting-started-developer
23+
[bdk-ffi]: https://github.com/notmandatory/bdk-ffi

0 commit comments

Comments
 (0)