Skip to content

Commit

Permalink
update swift release
Browse files Browse the repository at this point in the history
  • Loading branch information
llbartekll committed Sep 25, 2024
1 parent 7d1acdb commit db92a59
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 }}
Expand All @@ -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
Expand All @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions crates/ffi/YttriumCore/Sources/YttriumCore/ffi.swift
Original file line number Diff line number Diff line change
@@ -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<NativeSignerFFI>.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<PrivateKeySignerFFI>.fromOpaque(this).takeUnretainedValue().private_key().intoFfiRepr()
}

Expand Down Expand Up @@ -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<NativeSignerFFI>.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<PrivateKeySignerFFI>.fromOpaque(ptr).takeRetainedValue()
}

Expand Down
3 changes: 3 additions & 0 deletions crates/ffi/build-rust-ios-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit db92a59

Please sign in to comment.