Skip to content

Commit

Permalink
Use version released to Cocoapods and npm (#184)
Browse files Browse the repository at this point in the history
Follow up to #166, now that has been released.

Once this is landed, we should:

1. land anything that is to be in the next release.
2. do a release.

We need to do a release now because:
* The generated podspec file now includes a dependency on
`uniffi-bindgen-react-native`.
* We can remove pre-release caveats from the documentation.
  • Loading branch information
jhugman authored Dec 10, 2024
1 parent 28ec914 commit a241dfb
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 30 deletions.
2 changes: 1 addition & 1 deletion crates/ubrn_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "uniffi-bindgen-react-native"
version = "0.28.3-0"
version = "0.28.3-1"
edition = "2021"

[[bin]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Pod::Spec.new do |s|
{%- let bindings = self.relative_to(root, dir) -%}
s.source_files = "{{ ios }}/**/*.{h,m,mm}", "{{ codegen }}/**/*.{h,m,mm}", "{{ tm }}/**/*.{hpp,cpp,c,h}", "{{ bindings }}/**/*.{hpp,cpp,c,h}"
s.vendored_frameworks = "{{ framework }}"
s.dependency "uniffi-bindgen-react-native", "{{ self.config.project.ubrn_version() }}"
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
Expand Down
4 changes: 4 additions & 0 deletions crates/ubrn_cli/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ impl ProjectConfig {
trim_react_native(name).to_upper_camel_case()
}
}

pub(crate) fn ubrn_version(&self) -> String {
env!("CARGO_PKG_VERSION").to_string()
}
}

impl ProjectConfig {
Expand Down
13 changes: 12 additions & 1 deletion docs/src/contributing/cutting-a-release.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
# Cutting a Release

1. The version number should be incremented in the [`package.json`](https://github.com/jhugman/uniffi-bindgen-react-native/blob/main/package.json#L3) and the [`crates/ubrn_cli/Cargo.toml`](https://github.com/jhugman/uniffi-bindgen-react-native/blob/main/crates/ubrn_cli/Cargo.toml#L3).
1. Push as a PR as usual, with subject: `Release ${VERSION_NUMBER}`.
1. Once this has landed, [draft a new release](https://github.com/jhugman/uniffi-bindgen-react-native/releases/new).
1. Create a new tag (in the choose a new tag dialog) with the version number (without a `v`).
1. Use the version number again, but with a `v` prepended for the release title, `v${VERSION_NUMBER}`.
1. Publish the release.
1. Wait until the [Cocoapods](https://github.com/jhugman/uniffi-bindgen-react-native/actions/workflows/cocoapods.yml) and [NPM](https://github.com/jhugman/uniffi-bindgen-react-native/actions/workflows/npm.yml) publishing jobs are finished.
1. Tell your friends, make a song and dance, you've done a new release.

## Version numbers

Uniffi has a `semver` versioning scheme. At time of writing, the current version of `uniffi-rs` is `0.28.3`

`uniffi-bindgen-react-native` uses this version number with prepended with a `-` and a variant number, starting at `0`.

Thus, at first release, the version of `uniffi-bindgen-react-native` will be `0.28.3-0`.
Thus, at first release, the version of `uniffi-bindgen-react-native` was `0.28.3-0`.

### Compatibility with other packages

Other versioning we should take care to note:

- React Native
- `create-react-native-library`

A version matrix is built during CI: [![version compatibility](https://github.com/jhugman/uniffi-bindgen-react-native/actions/workflows/compat.yml/badge.svg?query=branch%3Amain) compatibility matrix](https://github.com/jhugman/uniffi-bindgen-react-native/actions/workflows/compat.yml?query=branch%3Amain).
27 changes: 0 additions & 27 deletions docs/src/guides/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ Using `yarn` add the `uniffi-bindgen-react-native` package to your project.
yarn add uniffi-bindgen-react-native
```

```admonish warning title="Pre-release"
While this is before the first release, we're installing straight from github.
`yarn add uniffi-bindgen-react-native@https://github.com/jhugman/uniffi-bindgen-react-native`
```

Opening `package.json` add the following:

```diff
Expand Down Expand Up @@ -122,27 +116,6 @@ There is a guide to the `ubrn` command [here][cli].

[cli]: ../reference/commandline.md


```admonish warning title="Pre-release"
While this is before the first release, we're installing straight from local `node_modules`.
After release, the C++ runtime will be published to Cocoa Pods.
Until then, you need to add the dependency to the app's Podfile, in this case `example/ios/Podfile`:
```

```diff
use_react_native!(
:path => config[:reactNativePath],
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)

+ # We need to specify this here in the app because we can't add a local dependency within
+ # the library package
+ pod 'uniffi-bindgen-react-native', :path => '../../node_modules/uniffi-bindgen-react-native'
```

## Step 3: Create the `ubrn.config.yaml` file

Full documentation on how to configure your library can be found in [the YAML configuration file page][config] of this book.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uniffi-bindgen-react-native",
"version": "0.28.3-0",
"version": "0.28.3-1",
"description": "Uniffi bindings generator for calling Rust from React Native",
"homepage": "https://github.com/jhugman/uniffi-bindgen-react-native",
"repository": {
Expand Down
3 changes: 3 additions & 0 deletions scripts/test-turbo-modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,10 @@ build_ios_example() {
enter_dir "$PROJECT_DIR"
echo "-- Running ubrn build ios"
"$UBRN_BIN" build ios --config "$UBRN_CONFIG" --and-generate --targets aarch64-apple-ios-sim
# Comment out the dependency from CocoaPods
sed -i '' -E 's|s.dependency *"uniffi-bindgen-react-native"|# &|' ./*.podspec
exit_dir
# Use local version, but added via the Podfile.
enter_dir "$PROJECT_DIR/example/ios"
echo "pod 'uniffi-bindgen-react-native', :path => '../../node_modules/uniffi-bindgen-react-native'" >> Podfile
pod install || error "Cannot run Podfile"
Expand Down

0 comments on commit a241dfb

Please sign in to comment.