| Package | Contents |
|---|---|
Matrix.RustSdk |
the helpers on top of the bindings, depends on the bindings |
Matrix.RustSdk.Bindings |
the generated C# bindings, no native libraries |
Matrix.RustSdk.Bindings.Native.Linux |
linux-x64, linux-arm64, linux-musl-x64, linux-musl-arm64 |
Matrix.RustSdk.Bindings.Native.Windows |
win-x64, win-arm64 |
Matrix.RustSdk.Bindings.Native.MacOS |
osx-x64, osx-arm64 |
Matrix.RustSdk.Bindings.Native.All |
depends on all native packages |
All packages are built from the same commit and share one version. The native packages depend on exactly that
version of Matrix.RustSdk.Bindings ([x.y.z], see ExactProjectReferenceVersions in Directory.Build.targets):
uniffi verifies API checksums when the native library is loaded, so bindings and native libraries of different versions
never work together. The exact dependency turns such a mismatch into a NuGet restore error instead of a runtime
exception. Matrix.RustSdk depends on exactly that version of the bindings as well: it is compiled against them, and
their API changes with every matrix-sdk-ffi update, so newer bindings would fail at runtime with missing members.
Matrix.RustSdk packs its XML documentation, and unlike the rest of the repository it fails the build for public
members without docs (CS1591). Its public API is snapshotted by PublicApiTests, a changed snapshot is a change of the
published API.
Versions are computed by Nerdbank.GitVersioning from
version.json, the patch number (or prerelease number) is the git height: the number of commits since the version
field was last changed, minus one (versionHeightOffset).
version in version.json |
Resulting versions |
|---|---|
0.1-rc.{height} |
0.1.0-rc.0, 0.1.0-rc.1, ... |
0.1 |
0.1.0, 0.1.1, ... |
Only builds of main (and vX.Y servicing branches) get clean versions, other branches get a -g<commit> suffix, so
packages are only published from main.
The packages follow SemVer with a 0.x major version. The bindings mirror the upstream
matrix-sdk-ffi API, which has breaking changes in almost every release. A release that only changes docs, checksums
or behavior keeps the bindings API (the generated *.cs have no changed signatures and the PublicApiTests snapshot
is unchanged), so:
| Change | Version bump |
|---|---|
A new matrix-sdk-ffi release that changes the bindings API |
minor, e.g. 0.1 → 0.2 in version.json |
A new matrix-sdk-ffi release with the same bindings API |
patch, automatic via the git height |
| Fixes to packaging, CI or the bindings generation, same API | patch, automatic via the git height |
A stable, hand-written API in Matrix.RustSdk |
consider 1.0 |
The matrix-sdk-ffi release the bindings are generated from is MatrixSdkFfiTag in Directory.Build.props. It ends
up in the release notes of every package and in the MatrixSdkFfiTag assembly metadata of the bindings, and CI checks
that it matches the external/matrix-rust-sdk submodule (scripts/check-sdk-version.sh).
- Make sure the latest Build and Test run on
mainis green, it builds and tests the native libraries for all platforms and packs the packages, exactly like the release. - Check the version that will be published: the
nuget-packagesartifact of that run contains the packages, or rundotnet nbgv get-versionlocally onmain(afterdotnet tool restore). If the version should change, editversion.jsonin a pull request first, see Versioning. - Run the Publish NuGet package workflow on
main(Actions → Publish NuGet package → Run workflow). It builds and tests everything again, then thepublishjob pushes all packages to nuget.org with trusted publishing. Configure required reviewers on theproductionenvironment to get an approval step before the push. Afterwards thereleasejob creates thev<version>tag and the GitHub release, see GitHub releases. - Verify the release: reference
Matrix.RustSdkand the native package from a small console app on the platforms you care about, e.g. Windows, macOS and an Alpine container, and create a client (seetest/Matrix.RustSdk.Tests/NativeLibraryTests.cs).
After the packages were pushed, the release job of the NuGet workflow (.github/scripts/create-release.sh) creates a
GitHub release with a v<version> tag on the published commit:
- versions without a prerelease suffix (
0.1.0) are marked as the latest release, all others (0.1.0-rc.3) as prereleases - the notes name the
matrix-sdk-ffirelease and the uniffi-bindgen-cs version, link the packages on nuget.org and contain the changelog generated by GitHub from the merged pull requests - it uses the job token (
contents: write), no personal access token is needed. Releases created with the job token don't trigger other workflows. - if the release already exists, e.g. when the workflow is re-run, the job skips it
To create a release for packages published before the job existed, run the script locally with the packages of that workflow run:
gh run download <run id> -n nuget-packages -D packages
GITHUB_SHA=<published commit> .github/scripts/create-release.sh packagesRelease candidates use 0.1-rc.{height}. Once a release candidate is verified, change version in version.json to
0.1, the first commit with that change is 0.1.0. Publishing that commit releases the same code as the verified
release candidate if nothing else changed.
To publish a fix for an older minor version, create a vX.Y branch (e.g. v0.1) from its last release, these branches
are public release branches in version.json, and run the publish workflow on it.
The publish job doesn't use a long-lived API key: NuGet/login exchanges the GitHub OIDC token for an API key that is
valid for one hour. This requires, once:
- A trusted publishing policy on nuget.org (username → Trusted Publishing → Add), owned by the account that owns the
packages:
- Repository Owner:
meenzen - Repository:
Matrix - Workflow File:
nuget.yml - Environment:
production
- Repository Owner:
- A
NUGET_USERsecret (in theproductionenvironment or the repository) with the nuget.org profile name of that account, not the email address.
The old NUGET_API_KEY secret is no longer used and can be deleted, as can the API key on nuget.org. A policy for a
private repository is only temporarily active until the first successful publish, see the
nuget.org documentation.
The packages redistribute matrix-rust-sdk (Apache-2.0) and the ~430 crates linked into the native libraries (mostly MIT and Apache-2.0, some MPL-2.0, BSD, ISC, Zlib and others), the generated bindings contain code from the templates of uniffi-bindgen-cs (MPL-2.0). Most of these licenses require their copyright notices and license texts to be included in binary distributions, so every package contains:
LICENSE: the license of this project (Apache-2.0)THIRD-PARTY-NOTICES.txt: the notices of matrix-rust-sdk, uniffi-bindgen-cs and the license texts of all crates with the crates they apply to, generated byscripts/generate-notices.shwith cargo-about (licenses/about.toml,licenses/about.hbs)
The pack job generates the notices, release builds fail without them. When a matrix-rust-sdk update brings a crate with
a license that isn't in accepted in licenses/about.toml, the generation fails: check whether the license allows
redistribution in binary form (copyleft licenses like GPL or LGPL don't, without further obligations) before adding
it. The cargo-about version is pinned in the pack job and should match devenv.
The uniffi version of matrix-rust-sdk has to match the one uniffi-bindgen-cs
is built for, otherwise the generated bindings don't work. uniffi-bindgen-cs usually lags behind, so the newest
matrix-sdk-ffi release is often not usable yet.
The check-updates.yml workflow checks daily for new matrix-sdk-ffi/* snapshots and uniffi-bindgen-cs releases and
keeps an issue for each open with the uniffi versions and whether they are compatible
(.github/scripts/check-updates.sh, DRY_RUN=1 prints the issues locally instead).
-
Find the latest uniffi-bindgen-cs release, its tag names the uniffi version (
vX.Y.Z+vA.B.Ctargets uniffiA.B.C):git ls-remote --tags https://github.com/NordSecurity/uniffi-bindgen-cs | grep -v '\^{}' | sort -V -k2 | tail -3
-
Find the newest
matrix-sdk-ffi/*release using a compatible uniffi version (sameA.B):for t in $(git ls-remote --tags https://github.com/matrix-org/matrix-rust-sdk 'matrix-sdk-ffi/*' \ | awk '{print $2}' | grep -v '\^{}' | sed 's#refs/tags/##' | sort -V | tail -10); do echo "$t $(curl -fsSL "https://raw.githubusercontent.com/matrix-org/matrix-rust-sdk/$t/Cargo.toml" \ | grep -E '^uniffi = ' | grep -oE 'version = "[0-9.]+"')" done
-
Update the submodule to that tag and
MatrixSdkFfiTaginDirectory.Build.props:git -C external/matrix-rust-sdk fetch --depth 1 origin tag matrix-sdk-ffi/YYYYMMDD git -C external/matrix-rust-sdk checkout matrix-sdk-ffi/YYYYMMDD ./scripts/check-sdk-version.sh
-
If a newer uniffi-bindgen-cs is needed, update
UNIFFI_BINDGEN_CS_VERSION,UNIFFI_BINDGEN_CS_REV(the commit to build, the commit of the release tag if there is one) andUNIFFI_RS_VERSIONindevenv.nix, devenv builds it when entering the shell. The patches inpatches/uniffi-bindgen-csare applied on top, remove the ones that are included upstream. The update check only reports the release again while the revision isn't its commit. Also check therust-versionof matrix-rust-sdk, devenv uses the latest stable Rust. -
Regenerate the bindings, check the licenses of the new dependencies and run the tests:
devenv shell ./scripts/build-debug.sh ./scripts/generate-notices.sh dotnet build && dotnet test
Fix generator or API issues, see the known issues in AGENTS.md. The tests may need updates for upstream API changes.
-
Bump the minor version in
version.json(e.g.0.1→0.2) if the bindings API changed. If the generated code only differs in docs and checksums, leave it, the update is a patch release (see Versioning). The checksums don't make it breaking, the native packages depend on the exact bindings version. -
Open a pull request, CI builds and tests the native libraries for all platforms.