-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[No QA] Create prebuilt React Native artifacts #59738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
roryabraham
merged 23 commits into
Expensify:main
from
software-mansion-labs:create-react-native-artifacts
Apr 24, 2025
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
0eca5a8
Adjust gradle to enable artifacts publication process
mateuuszzzzz ca91102
Add verification jobs
mateuuszzzzz 9f5aa4d
Rename job
mateuuszzzzz 897335d
Fix typos
mateuuszzzzz 4e28108
Fix typo
mateuuszzzzz e7e4f01
Fix HybridApp check
mateuuszzzzz 6f33a83
Add executable computePatchesHash.sh
mateuuszzzzz 39298e9
Use script instead of inlined commands
mateuuszzzzz a30a195
Add NewDot artifacts build and publication job
mateuuszzzzz 6af47e6
Fix maven url
mateuuszzzzz ab62ab0
Update envs names
mateuuszzzzz 8bd01f9
Add flow for HybridApp
mateuuszzzzz d19f7ed
Fix issue with groovy
mateuuszzzzz 1e6bc28
Address review comments associated to workflow
mateuuszzzzz b225e52
Take NewDot patches into consideration on Hybrid builds
mateuuszzzzz 02e651c
Rename workflow
mateuuszzzzz a469159
Adjust workflow scripts
mateuuszzzzz dc119f8
Remove unused env from workflow
mateuuszzzzz ed9aef9
Use gh api instead of curl
mateuuszzzzz 01d27fc
Merge branch 'main' into create-react-native-artifacts
mateuuszzzzz c93d49c
Remove patches hash from publish.gradle
mateuuszzzzz e502011
Add new patch
mateuuszzzzz f95710a
Add missing double and single quotes
mateuuszzzzz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #!/bin/bash | ||
|
|
||
| if [ -z "$GITHUB_TOKEN" ]; then | ||
| echo "GITHUB_TOKEN env variable is not set" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "$IS_HYBRID_BUILD" == "true" ]]; then | ||
| readonly PACKAGE="react-hybrid" | ||
| else | ||
| readonly PACKAGE="react-standalone" | ||
| fi | ||
|
|
||
| VERSION="$(jq -r '.dependencies["react-native"]' package.json)" | ||
| readonly VERSION | ||
|
|
||
| # List all versions of the package | ||
| PACKAGE_VERSIONS="$(gh api "/orgs/Expensify/packages/maven/com.expensify.${PACKAGE}.react-android/versions" --paginate --jq '.[].name')" | ||
|
|
||
| # Filter only versions matching the base React Native version | ||
| PACKAGE_VERSIONS="$(echo "$PACKAGE_VERSIONS" | grep "$VERSION")" | ||
|
|
||
| # Grab the highest patch version from there | ||
| LATEST_PATCHED_VERSION="$(echo "$PACKAGE_VERSIONS" | sort | tail -n1)" | ||
|
|
||
| if [[ -n "$LATEST_PATCHED_VERSION" ]]; then | ||
| PATCH_ITERATION=${LATEST_PATCHED_VERSION##*-} | ||
| INCREMENTED_PATCH_ITERATION=$((PATCH_ITERATION + 1)) | ||
| echo "${VERSION}-${INCREMENTED_PATCH_ITERATION}" | ||
| else | ||
| echo "$VERSION-0" | ||
| fi | ||
139 changes: 139 additions & 0 deletions
139
.github/workflows/publishReactNativeAndroidArtifacts.yml
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| name: Publish React Native Android Artifacts | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - package.json | ||
| - patches/react-native+*.patch | ||
| - patches/@react-native+*.patch | ||
| - Mobile-Expensify | ||
|
|
||
| jobs: | ||
| publish: | ||
| runs-on: ${{ github.repository_owner == 'Expensify' && 'ubuntu-latest-xl' || 'ubuntu-latest' }} | ||
| strategy: | ||
| matrix: | ||
| is_hybrid: [true, false] | ||
| steps: | ||
| # v4 | ||
| - name: Checkout | ||
| uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 | ||
| with: | ||
| submodules: ${{ matrix.is_hybrid }} | ||
| ref: ${{ github.event.before }} | ||
|
|
||
| - name: Get previous App commit hash | ||
| id: getOldAppHash | ||
| run: echo "HASH=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Get previous Mobile-Expensify commit hash | ||
| if: ${{ matrix.is_hybrid == 'true' }} | ||
| id: getOldMobileExpensifyHash | ||
| run: echo "HASH=$(git rev-parse :Mobile-Expensify)" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Get previous react-native version | ||
| id: getOldVersion | ||
| run: echo "VERSION=$(jq -r '.dependencies["react-native"]' package.json)" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Checkout new ref | ||
| run: | | ||
| git fetch origin ${{ github.event.after }} --depth=1 | ||
| git checkout ${{ github.event.after }} | ||
| git submodule update | ||
|
|
||
| - name: Get new App commit hash | ||
| id: getNewAppHash | ||
| run: echo "HASH=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Get new Mobile-Expensify commit hash | ||
| if: ${{ matrix.is_hybrid == 'true' }} | ||
| id: getNewMobileExpensifyHash | ||
| run: echo "HASH=$(git rev-parse :Mobile-Expensify)" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Get new react-native version | ||
| id: getNewVersion | ||
| run: echo "VERSION=$(jq -r '.dependencies["react-native"]' package.json)" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Check if version changed | ||
| id: didVersionChange | ||
| run: | | ||
| readonly DID_VERSION_CHANGE=${{ steps.getOldVersion.outputs.VERSION != steps.getNewVersion.outputs.VERSION && 'true' || 'false' }} | ||
| echo "DID_VERSION_CHANGE=$DID_VERSION_CHANGE" >> "$GITHUB_OUTPUT" | ||
| if [[ "$DID_VERSION_CHANGE" == 'true' ]]; then | ||
| echo "::notice::Detected react-native version bump (${{ steps.getOldVersion.outputs.VERSION }} -> ${{ steps.getNewVersion.outputs.VERSION }})" | ||
| fi | ||
|
|
||
| - name: Check if patches changed | ||
| id: didPatchesChange | ||
| run: | | ||
| if git diff --exit-code --name-only ${{ steps.getOldAppHash.outputs.HASH }}..${{ steps.getNewAppHash.outputs.HASH }} -- patches/react-native+*.patch patches/@react-native+*.patch; then | ||
| echo "::notice::Detected changes in patches" | ||
| echo "DID_PATCHES_CHANGE=true" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [[ '${{ matrix.is_hybrid }}' == 'true' ]]; then | ||
| if git -C Mobile-Expensify diff --exit-code --name-only ${{ steps.getOldMobileExpensifyHash.outputs.HASH }}..${{ steps.getNewMobileExpensifyHash.outputs.HASH }} -- patches/react-native+*.patch patches/@react-native+*.patch; then | ||
| echo "::notice::Detected changes in patches" | ||
| echo "DID_PATCHES_CHANGE=true" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| fi | ||
|
|
||
| echo "DID_PATCHES_CHANGE=false" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Check if we should build and publish the package | ||
| id: shouldPublish | ||
| run: | | ||
| if [[ '${{ steps.didVersionChange.outputs.DID_VERSION_CHANGE }}' == 'true' || '${{ steps.didPatchesChange.outputs.DID_PATCHES_CHANGE }}' == 'true' ]]; then | ||
| echo "SHOULD_PUBLISH=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "::notice::No relevant changes, skipping publishing a new React Native build" | ||
| echo "SHOULD_PUBLISH=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Setup Node | ||
| if: ${{ steps.shouldPublish.outputs.SHOULD_PUBLISH == 'true' }} | ||
| uses: ./.github/actions/composite/setupNode | ||
| with: | ||
| IS_HYBRID_BUILD: ${{ matrix.is_hybrid }} | ||
|
|
||
| # v4 | ||
| - name: Setup Java | ||
| if: ${{ steps.shouldPublish.outputs.SHOULD_PUBLISH == 'true' }} | ||
| uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 | ||
| with: | ||
| distribution: oracle | ||
| java-version: 17 | ||
|
|
||
| # v4 | ||
| - name: Setup Gradle | ||
| if: ${{ steps.shouldPublish.outputs.SHOULD_PUBLISH == 'true' }} | ||
| uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 | ||
|
|
||
| - name: Determine new patched RN version | ||
| if: ${{ steps.shouldPublish.outputs.SHOULD_PUBLISH == 'true' }} | ||
| id: getNewPatchedVersion | ||
| run: echo "NEW_PATCHED_VERSION=$(./.github/scripts/getNewPatchedRNVersion.sh)" >> "$GITHUB_OUTPUT" | ||
| env: | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
| IS_HYBRID_BUILD: ${{ matrix.is_hybrid }} | ||
|
|
||
| - name: Build and publish RN artifacts | ||
| if: ${{ steps.shouldPublish.outputs.SHOULD_PUBLISH == 'true' }} | ||
| working-directory: ${{ matrix.is_hybrid == 'true' && 'Mobile-Expensify/Android' || 'android' }} | ||
| run: | | ||
| echo "Starting artifacts build for ${{ matrix.is_hybrid == 'true' && 'HybridApp' || 'NewDot Standalone' }}" | ||
| echo "Version: ${{ env.PATCHED_VERSION }}" | ||
| echo "Commit hash: ${{ env.COMMIT_HASH }}" | ||
| export ORG_GRADLE_PROJECT_reactNativeArchitectures="armeabi-v7a,arm64-v8a,x86,x86_64" | ||
| ./gradlew buildReactNativeArtifacts -x lint -x test -x check | ||
| ./gradlew publishReactNativeArtifacts | ||
| env: | ||
| GH_PUBLISH_ACTOR: ${{ github.actor }} | ||
| GH_PUBLISH_TOKEN: ${{ github.token }} | ||
| IS_HYBRID_BUILD: ${{ matrix.is_hybrid }} | ||
| PATCHED_VERSION: ${{ steps.getNewPatchedVersion.outputs.NEW_PATCHED_VERSION }} | ||
| COMMIT_HASH: ${{ github.event.after }} |
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| diff --git a/node_modules/react-native/.DS_Store b/node_modules/react-native/.DS_Store | ||
| new file mode 100644 | ||
| index 0000000..60811a9 | ||
| Binary files /dev/null and b/node_modules/react-native/.DS_Store differ | ||
| diff --git a/node_modules/react-native/ReactAndroid/.DS_Store b/node_modules/react-native/ReactAndroid/.DS_Store | ||
| new file mode 100644 | ||
| index 0000000..8bfcb73 | ||
| Binary files /dev/null and b/node_modules/react-native/ReactAndroid/.DS_Store differ | ||
| diff --git a/node_modules/react-native/ReactAndroid/publish.gradle b/node_modules/react-native/ReactAndroid/publish.gradle | ||
| index 32287a7..5607be3 100644 | ||
| --- a/node_modules/react-native/ReactAndroid/publish.gradle | ||
| +++ b/node_modules/react-native/ReactAndroid/publish.gradle | ||
| @@ -13,7 +13,11 @@ def signingKey = findProperty("SIGNING_KEY") | ||
| def signingPwd = findProperty("SIGNING_PWD") | ||
|
|
||
| def reactAndroidProjectDir = project(':packages:react-native:ReactAndroid').projectDir | ||
| -def mavenTempLocalUrl = "file:///tmp/maven-local" | ||
| +def mavenURL = "https://maven.pkg.github.com/Expensify/App" | ||
| + | ||
| +def patchedVersion = System.getenv("PATCHED_VERSION") | ||
| +def isHybridBuild = System.getenv("IS_HYBRID_BUILD")?.toBoolean() | ||
| +def publishingGroupId = isHybridBuild ? "com.expensify.react-standalone" : "com.expensify.react-hybrid" | ||
|
|
||
| publishing { | ||
| publications { | ||
| @@ -26,12 +30,14 @@ publishing { | ||
| } | ||
| } | ||
|
|
||
| + groupId = publishingGroupId | ||
| + | ||
| // We populate the publishing version using the project version, | ||
| // appending -SNAPSHOT if on nightly or prerelase. | ||
| if (isSnapshot) { | ||
| - version = this.version + "-SNAPSHOT" | ||
| + version = patchedVersion + "-SNAPSHOT" | ||
| } else { | ||
| - version = this.version | ||
| + version = patchedVersion | ||
| } | ||
|
|
||
| pom { | ||
| @@ -39,10 +45,14 @@ publishing { | ||
| description = "A framework for building native apps with React" | ||
| url = "https://github.com/facebook/react-native" | ||
|
|
||
| + properties = [ | ||
| + "commitHash": System.getenv("COMMIT_HASH"), | ||
| + ] | ||
| + | ||
| developers { | ||
| developer { | ||
| - id = "facebook" | ||
| - name = "Facebook" | ||
| + id = "expensify" | ||
| + name = "Expensify" | ||
| } | ||
| } | ||
|
|
||
| @@ -65,8 +75,11 @@ publishing { | ||
|
|
||
| repositories { | ||
| maven { | ||
| - name = "mavenTempLocal" | ||
| - url = mavenTempLocalUrl | ||
| + url = mavenURL | ||
| + credentials { | ||
| + username = System.getenv("GH_PUBLISH_ACTOR") | ||
| + password = System.getenv("GH_PUBLISH_TOKEN") | ||
| + } | ||
| } | ||
| } | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.