From db92a59050b3d0af6805dd1de5552830fd6f6abf Mon Sep 17 00:00:00 2001 From: llbartekll Date: Wed, 25 Sep 2024 12:14:47 +0200 Subject: [PATCH] update swift release --- .../{release.yml => releas-swift.yml} | 32 ++++++------------- .../YttriumCore/Sources/YttriumCore/ffi.swift | 12 +++---- crates/ffi/build-rust-ios-release.sh | 3 ++ 3 files changed, 19 insertions(+), 28 deletions(-) rename .github/workflows/{release.yml => releas-swift.yml} (82%) diff --git a/.github/workflows/release.yml b/.github/workflows/releas-swift.yml similarity index 82% rename from .github/workflows/release.yml rename to .github/workflows/releas-swift.yml index 2aa0c070..ab7f9d51 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/releas-swift.yml @@ -1,9 +1,11 @@ name: Build and Release Yttrium on: - push: - branches: - - 'xcframework' + workflow_dispatch: + inputs: + version: + description: 'Version to release (e.g. 0.0.1)' + required: true env: CARGO_TERM_COLOR: always @@ -54,7 +56,7 @@ jobs: # 6. Build and Package Rust XCFramework - name: Build and Package Rust XCFramework run: | - make build-ios-bindings + make build-ios-bindings-release make zip-rust-xcframework make compute-rust-checksum make generate-package-swift @@ -73,21 +75,7 @@ jobs: - name: List Changes in Package.swift run: git diff Package.swift - # 10. Compute Checksum and Update Package.swift - - name: Compute Checksum and Update Package.swift - id: compute_checksum - run: | - # Compute checksum - CHECKSUM=$(swift package compute-checksum ./Output/RustXcframework.xcframework.zip) - echo "Computed checksum: $CHECKSUM" - - # Update Package.swift with the new checksum - # Assuming the binary target is named "RustXcframework" - sed -i '' "s/checksum: \".*\"/checksum: \"$CHECKSUM\"/" Package.swift - - echo "Updated Package.swift with new checksum." - - # 11. Commit and Push Package.swift + # 10. Commit and Push Package.swift - name: Commit and Push Package.swift env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use default token @@ -102,7 +90,7 @@ jobs: git push origin HEAD:$TARGET_BRANCH fi - # 12. Create Git Tag + # 11. Create Git Tag - name: Create Git Tag env: VERSION: ${{ env.VERSION }} @@ -121,7 +109,7 @@ jobs: # Push the tag to the repository git push origin "${VERSION}" - # 13. Create a GitHub Release + # 12. Create a GitHub Release - name: Create Release id: create_release uses: actions/create-release@v1 @@ -133,7 +121,7 @@ jobs: draft: false prerelease: true - # 14. Upload Rust XCFramework to the Release + # 13. Upload Rust XCFramework to the Release - name: Upload Rust XCFramework to Release uses: actions/upload-release-asset@v1 env: diff --git a/crates/ffi/YttriumCore/Sources/YttriumCore/ffi.swift b/crates/ffi/YttriumCore/Sources/YttriumCore/ffi.swift index 76de8440..47cdb507 100644 --- a/crates/ffi/YttriumCore/Sources/YttriumCore/ffi.swift +++ b/crates/ffi/YttriumCore/Sources/YttriumCore/ffi.swift @@ -1,21 +1,21 @@ import RustXcframework @_cdecl("__swift_bridge__$NativeSignerFFI$new") -func __swift_bridge__NativeSignerFFI_new (_ signer_id: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { +public func __swift_bridge__NativeSignerFFI_new (_ signer_id: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { Unmanaged.passRetained(NativeSignerFFI(signer_id: RustString(ptr: signer_id))).toOpaque() } @_cdecl("__swift_bridge__$NativeSignerFFI$sign") -func __swift_bridge__NativeSignerFFI_sign (_ this: UnsafeMutableRawPointer, _ message: UnsafeMutableRawPointer) -> __swift_bridge__$FFIStringResult { +public func __swift_bridge__NativeSignerFFI_sign (_ this: UnsafeMutableRawPointer, _ message: UnsafeMutableRawPointer) -> __swift_bridge__$FFIStringResult { Unmanaged.fromOpaque(this).takeUnretainedValue().sign(message: RustString(ptr: message)).intoFfiRepr() } @_cdecl("__swift_bridge__$PrivateKeySignerFFI$new") -func __swift_bridge__PrivateKeySignerFFI_new (_ signer_id: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { +public func __swift_bridge__PrivateKeySignerFFI_new (_ signer_id: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { Unmanaged.passRetained(PrivateKeySignerFFI(signer_id: RustString(ptr: signer_id))).toOpaque() } @_cdecl("__swift_bridge__$PrivateKeySignerFFI$private_key") -func __swift_bridge__PrivateKeySignerFFI_private_key (_ this: UnsafeMutableRawPointer) -> __swift_bridge__$FFIStringResult { +public func __swift_bridge__PrivateKeySignerFFI_private_key (_ this: UnsafeMutableRawPointer) -> __swift_bridge__$FFIStringResult { Unmanaged.fromOpaque(this).takeUnretainedValue().private_key().intoFfiRepr() } @@ -552,13 +552,13 @@ extension FFI7702AccountClient: Vectorizable { @_cdecl("__swift_bridge__$NativeSignerFFI$_free") -func __swift_bridge__NativeSignerFFI__free (ptr: UnsafeMutableRawPointer) { +public func __swift_bridge__NativeSignerFFI__free (ptr: UnsafeMutableRawPointer) { let _ = Unmanaged.fromOpaque(ptr).takeRetainedValue() } @_cdecl("__swift_bridge__$PrivateKeySignerFFI$_free") -func __swift_bridge__PrivateKeySignerFFI__free (ptr: UnsafeMutableRawPointer) { +public func __swift_bridge__PrivateKeySignerFFI__free (ptr: UnsafeMutableRawPointer) { let _ = Unmanaged.fromOpaque(ptr).takeRetainedValue() } diff --git a/crates/ffi/build-rust-ios-release.sh b/crates/ffi/build-rust-ios-release.sh index bb91437f..51402672 100644 --- a/crates/ffi/build-rust-ios-release.sh +++ b/crates/ffi/build-rust-ios-release.sh @@ -37,6 +37,9 @@ function create_package { --ios ./../../target/aarch64-apple-ios/release/lib$PACKAGE_NAME.a \ --simulator ./../../target/universal-ios/release/lib$PACKAGE_NAME.a \ --name $SWIFT_PACKAGE_NAME + + # Make generated methods public in the ffi.swift file + sed -i '' 's/^func __swift_bridge__/public func __swift_bridge__/g' YttriumCore/Sources/YttriumCore/ffi.swift } # Check if Package.swift file exists