WPAndroid by default integrates react-native-bridge
as a binary dependency that's fetched from a remote maven repo.
The CI in this repo will deploy a new version each time a commit is pushed to develop
or an open PR, as well as each time a tag is created.
This is the only required dependency.
Whenever a new version is deployed, we can simply update ext.gutenbergMobileVersion
in build.gradle.
During development, we can use composite builds and dependency substitution to point WPAndroid to our local checkout of gutenberg-mobile
.
To do this, we need to copy the local-builds.gradle-example file in WPAndroid renaming it to local-builds.gradle
and change the localGutenbergMobilePath
value.
Building the project as such will make WPAndroid build the source code for react-native-bridge
, react-native-aztec
and other sublibraries from the locally checked out folder.
It'll also expect the metro server to be running to fetch the JS bundle.
- Work with local gutenberg-mobile checkout
- Deploy a new version of
react-native-bridge
from CI - Update WPAndroid's binary version
- How to
From your gutenberg-mobile checkout:
- Make sure you run
npm install
ornpm ci
- Run metro server with
npm run start:reset
From your WordPress-Android checkout:
- Copy local-builds.gradle-example renaming it to
local-builds.gradle
- Update
localGutenbergMobilePath
to your localgutenberg-mobile
checkout - Run the project
When settings.gradle finds localGutenbergMobilePath
in local-builds.gradle
, it'll substitute the below binary dependency with the local folder:
implementation "$rootProject.gradle.ext.gutenbergMobileBinaryPath:$rootProject.ext.gutenbergMobileVersion"
react-native-bridge
is setup to include all the other projects, so no other action is necessary.
There are a few different ways to do this:
- Open a new PR or push a new commit to an open PR which will be published as
<PR number>-<commit full SHA1>
- Merge a PR to
develop
which will be published as<develop>-<commit full SHA1>
- Create a new tag which will be published as
<tag name>
CI will run the following commands:
npm ci
npm run bundle:android
gutenberg/packages/react-native-bridge/android/publish-aztec-and-bridge.sh <version>
- Find the version deployed from CI
- Update
ext.gutenbergMobileVersion
property in build.gradle to the new version
In order to test this, make sure localGutenbergMobilePath
in your local-builds.gradle
file is commented out as otherwise the binary version will be ignored.
Note: The Build Android RN Bridge & Publish to S3
task in gutenberg-mobile
needs to complete before WPAndroid's Installable Build
CI task will succeed. As such, you may see WPAndroid's CI tasks fail with a 403 error if they run before the gutenberg-mobile
task completes. You can either wait for wait for gutenberg-mobile
's CI task to pass before pushing changes to ext.gutenbergMobileVersion
or restart failed WPAndroid CI tasks after gutenberg-mobile
's CI task passes.
Assuming that there is no open WPAndroid PR yet:
- Setup WPAndroid to work with local gutenberg-mobile checkout
- Switch
gutenberg-mobile
to the branch you're testing - Run the app
- Open a
gutenberg-mobile
PR which will publish a new version - Open a WPAndroid PR updating the binary version
- Peril will publish a comment to the WPAndroid PR with a link to the APK
Alternatively, once the react-native-bridge
version is published, we can locally create the APK.
Note that there is no way to use composite build to create a WPAndroid APK that can be shared. This is because composite build only works with the local metro server.
Whenever the CI publishes react-native-bridge
, it will either include the full commit hash or the tag in its name.
So, we can checkout simply checkout the commit hash or the tag.