-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace `Package.swift` to build the package from `./Sources` (generated Swift bridge code) and the binaries built from the previous commit and pushed as a "release" in the repo. This completes the migration of the repo from its former use as a simple package spec for the legacy `mobile_wallet` library to the new one which is embedded in the repo. Future releases are to follow the same two-step process layed out by this commit and its predecessor; i.e. two conscutive, tagged commits within a single PR. The complete process is described in the README.
- Loading branch information
Showing
3 changed files
with
670 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,30 @@ | ||
// swift-tools-version: 5.6 | ||
// swift-tools-version:5.6 | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "ConcordiumWalletCrypto", | ||
platforms: [ | ||
.iOS(.v13), | ||
.macOS(.v10_15), | ||
], | ||
products: [ | ||
.library( | ||
name: "ConcordiumWalletCrypto", | ||
targets: ["libmobile_wallet"]), | ||
targets: ["ConcordiumWalletCrypto"] | ||
), | ||
], | ||
dependencies: [], | ||
targets: [ | ||
.binaryTarget(name: "libmobile_wallet", url: "https://s3.eu-west-1.amazonaws.com/static-libraries.concordium.com/iOS/libmobile_wallet_0.24.0-0.xcframework.zip", checksum: "8051b9681901187537adc76858715d569d51abd4c201c376f292749da0b6eb60") | ||
.binaryTarget( | ||
name: "RustFramework", | ||
url: "https://github.com/Concordium/concordium-wallet-crypto-swift/releases/download/build%2F1.0.0-1/RustFramework.xcframework.zip", | ||
checksum: "edc2628d1721697b555891316dac3be1490072c1649d040fff8f3c160b2d0e09" | ||
), | ||
.target( | ||
name: "ConcordiumWalletCrypto", | ||
dependencies: [ | ||
.target(name: "RustFramework"), | ||
] | ||
), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,60 @@ | ||
# ConcordiumWalletCrypto | ||
|
||
[Swift package](https://developer.apple.com/documentation/xcode/swift-packages) providing Concordium's [Rust-based crypto library for mobile wallets](https://github.com/Concordium/concordium-base/tree/main/mobile_wallet), compiled for iOS as an [XCFramework](https://developer.apple.com/documentation/xcode/distributing-binary-frameworks-as-swift-packages). | ||
[Swift package](https://developer.apple.com/documentation/xcode/swift-packages) providing bindings for Swift | ||
of Concordium specific cryptographic functions that are written in Rust. | ||
|
||
The binaries are compiled internally and uploaded to S3. The only target of the package is a binary target that references the appropriate version of this file. | ||
The project is a core component of [`ConcordiumSwiftSdk`](https://github.com/Concordium/concordium-swift-sdk.git) | ||
and only has its own repository because of limitations in SwiftPM | ||
that prevent us from publishing everything in a single complete package. | ||
In brief, Swift packages must be downloaded straight from git, | ||
not from a registry to which we can publish the complete build. | ||
This repository serves the dual purpose of hosting the Rust sources while simultaneously standing in as such a registry. | ||
|
||
## Versioning | ||
To avoid storing large binaries in git, a workflow compiles the bindings into an | ||
[XCFramework](https://developer.apple.com/documentation/xcode/distributing-binary-frameworks-as-swift-packages) | ||
and uploads it to GitHub as a release in this repository. | ||
|
||
The available versions of the package are represented by the commit tags of this repository. | ||
The package specification then refers to such a release, not the local Rust sources. | ||
This means that the Swift sources (i.e. generated bridge code) and package spec made up by this repo | ||
and its Rust sources aren't necessarily in sync. | ||
The Swift files always refer to the latest published release, even during development of the next version. | ||
|
||
The version follows the one of the [Rust sources](https://github.com/Concordium/concordium-base/blob/main/mobile_wallet/Cargo.toml) with a "build version" appended with a `-` separator. This extra component counts from 0 for any given library version and is bumped whenever a new Swift package based on the same Rust sources is built. | ||
## Previous usage | ||
|
||
## Relase new version | ||
This repository/package was previously used to host the binaries built from a previous incarnation of the Rust library | ||
which was built and hosted elsewhere. | ||
See commit 6b6af29816b0f966598b170d62334e2faf00062b for details. | ||
|
||
Steps for building and releasing a new version `<version>`: | ||
That package is still available from tag | ||
[`0.24.0-0`](https://github.com/Concordium/concordium-wallet-crypto-swift/releases/tag/0.24.0-0) | ||
and in use by the | ||
[iOS reference wallet](https://github.com/Concordium/concordium-reference-wallet-ios/). | ||
|
||
1. Using the appropriate automated job, run [`./build-ios.sh`](https://github.com/Concordium/concordium-base/blob/main/mobile_wallet/scripts/build-ios.sh) from `concordium-base`, archive `ios/build/libmobile_wallet.xcframework` as a compressed zip file named `libmobile_wallet_<version>.xcframework.zip`, and upload this file to S3 bucket/path `static-libraries.concordium.com/iOS/`. | ||
## Versioning | ||
|
||
2. Compute checksum of the archive using the command | ||
```shell | ||
swift package compute-checksum libmobile_wallet_<version>.xcframework.zip | ||
``` | ||
The available versions of the package are represented by the commit tags of this repository. | ||
The version is defined by the Rust/Cargo project. | ||
|
||
## Release new version | ||
|
||
3. Commit a change to [`Package.swift`](https://github.com/Concordium/concordium-wallet-crypto-swift/blob/main/Package.swift), updating the `libmobile_wallet` binary target with the new version in the `url` string and the new `checksum`. | ||
The Rust code is developed as usually without making changes to `./Sources` nor `Package.swift`. | ||
|
||
4. Push an annotated tag named by the version for the new commit: | ||
Once it's ready for a new release, the steps for building and releasing a new version `<version>` are: | ||
|
||
1. Create and push a tag named `build/<version>-<build-version>`, | ||
where `<build-version>` is bumped (starting from 0) for each attempt at building `<version>`. | ||
This is necessary because GitHub requires releases to be tagged and the following workflow uploads a release. | ||
2. Run the [workflow](./.github/workflows/publish-bindings.yml) for publishing a new version of the binary framework. | ||
Use the tag you just created as "branch" to run from and input `<version>` (i.e. without the counter for "Version"). | ||
3. Run [`./build.sh`](./build.sh) locally to regenerate the Swift bridge sources. | ||
[TODO: Running the "bindgen" step is sufficient.] | ||
4. Update `Package.swift` with the updated `url` and `checksum` of the binary framework. | ||
The workflow prints the checksum as the last step of its execution. | ||
5. Commit the changes and push an annotated tag named by the version for the new commit: | ||
```shell | ||
git tag -a <version> | ||
``` | ||
Give the tag a message describing what changed in the new version. | ||
|
||
The entire process should be done as a single PR which, | ||
in order to preserve the tags, gets merged without squashing. |
Oops, something went wrong.