Skip to content

Commit

Permalink
Migrate crypto library from ConcordiumSwiftSdk
Browse files Browse the repository at this point in the history
Due to the way SwiftPM works, compiled binaries needs to be published in a separate repo from the package itself.
Otherwise, the huge static binaries would have to be checked into git, and nobody wants that.

With this setup the Rust sources will live as part of the actual published package
(defined by `Package.swift` and generated bridge code) along with the compiled binaries which are published as releases of this repo.
It's admittedly quite confusing that "releases" of the repo only contain the binaries (identified by "internal" tags) while the actual release is the repo itself
(identified by "external" tags).

This commit adds the Rust sources but doesn't migrate `Package.swift` yet.

The build process consists of the following two steps:

1. Tag the commit with the Rust sources that we want to build from and run the workflow to publish the XCFramework as a GitHub release.
2. Generate/update the Swift bridge sources and the packages spec. Commit and tag again.

The build has to span two tags because GitHub releases must refer to a tag. The first tag becomes part of the URL of the release and needs to be referenced in `Package.swift` along with the checksum of the zip file.
The tag created in step 2 is the one that defines the "actual" release, meaning that it's what's consuming packages use.

For a given release version `<version>` the "internal" tag uses format `build/<version>-<build-version>` while the "external" one is just `<version>`.
Note that the internal tag includes another component `<build-version>` which is bumped for every build attempt (starting from `0` for any `<version>`).
  • Loading branch information
bisgardo committed Feb 2, 2024
1 parent 04fffe1 commit 5c06fa2
Show file tree
Hide file tree
Showing 11 changed files with 2,518 additions and 5 deletions.
37 changes: 34 additions & 3 deletions .github/workflows/publish-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,41 @@ on:
type: string
required: true

env:
rust_version: "1.72"

# TODO: Lint/format/test Rust code in separate build script.

jobs:
build_publish:
runs-on: ubuntu-latest
runs-on: macos-13

steps:
- name: Check out sources
uses: actions/checkout@v4
- name: Setup Rust
run: |
rustup default "${{env.rust_version}}"
rustup target install \
aarch64-apple-darwin \
aarch64-apple-ios \
aarch64-apple-ios-sim \
x86_64-apple-darwin \
x86_64-apple-ios
- name: Check out sources
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build binary framework
run: ./build.sh # produces './generated/RustFramework.xcframework'
- name: Archive framework
working-directory: ./generated
run: |
zip -r ./RustFramework.xcframework.zip ./RustFramework.xcframework
swift package compute-checksum ./RustFramework.xcframework.zip > ./CHECKSUM
- name: Upload package as GitHub release
uses: softprops/action-gh-release@v1
with:
files: |
./generated/RustFramework.xcframework.zip
./generated/CHECKSUM
name: '${{github.event.inputs.version}}'
generate_release_notes: true
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/.idea
/target
/generated

.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/config/registries.json
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "concordium-base"]
path = concordium-base
url = https://github.com/Concordium/concordium-base.git
Loading

0 comments on commit 5c06fa2

Please sign in to comment.