From 0eca5a89390ba202bb17cb38e81eb46d79177c8e Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Mon, 7 Apr 2025 16:33:08 +0200 Subject: [PATCH 01/22] Adjust gradle to enable artifacts publication process --- android/build.gradle | 8 +++ ...act-native+0.77.1+024+publish-gradle.patch | 66 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 patches/react-native+0.77.1+024+publish-gradle.patch diff --git a/android/build.gradle b/android/build.gradle index fdd6b5ab2e45..ad16663894ef 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -78,3 +78,11 @@ allprojects { } apply plugin: "com.facebook.react.rootproject" + +task buildReactNativeArtifacts { + dependsOn(gradle.includedBuild('react-native').task(':packages:react-native:ReactAndroid:build')) +} + +task publishReactNativeArtifacts { + dependsOn(gradle.includedBuild('react-native').task(':packages:react-native:ReactAndroid:publishReleasePublicationToMavenRepository')) +} \ No newline at end of file diff --git a/patches/react-native+0.77.1+024+publish-gradle.patch b/patches/react-native+0.77.1+024+publish-gradle.patch new file mode 100644 index 000000000000..eb4b8e734bab --- /dev/null +++ b/patches/react-native+0.77.1+024+publish-gradle.patch @@ -0,0 +1,66 @@ +diff --git a/node_modules/react-native/ReactAndroid/publish.gradle b/node_modules/react-native/ReactAndroid/publish.gradle +index 32287a7..68c9284 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 isHybridRelease = System.getenv("IS_HYBRID_RELEASE")?.toBoolean() ++def groupId = isHybridRelease ? "com.expensify.react-standalone" : "com.expensify.react-hybrid" + + publishing { + publications { +@@ -26,12 +30,14 @@ publishing { + } + } + ++ groupId = groupId ++ + // 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,15 @@ publishing { + description = "A framework for building native apps with React" + url = "https://github.com/facebook/react-native" + ++ properties = [ ++ "patchesHash": System.getenv("PATCHES_HASH"), ++ "commitHash": System.getenv("COMMIT_HASH"), ++ ] ++ + developers { + developer { +- id = "facebook" +- name = "Facebook" ++ id = "expensify" ++ name = "Expensify" + } + } + +@@ -65,8 +76,11 @@ publishing { + + repositories { + maven { +- name = "mavenTempLocal" +- url = mavenTempLocalUrl ++ url = mavenURL ++ credentials { ++ username = System.getenv("GH_PUBLISH_ACTOR") ++ password = System.getenv("GH_PUBLISH_TOKEN") ++ } + } + } + From ca911026c1d9694ddeb32762a8631f2ca4213565 Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Tue, 8 Apr 2025 16:19:59 +0200 Subject: [PATCH 02/22] Add verification jobs --- .../buildAndPublishReactNativeArtifacts.yml | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 .github/workflows/buildAndPublishReactNativeArtifacts.yml diff --git a/.github/workflows/buildAndPublishReactNativeArtifacts.yml b/.github/workflows/buildAndPublishReactNativeArtifacts.yml new file mode 100644 index 000000000000..22df73e3f66e --- /dev/null +++ b/.github/workflows/buildAndPublishReactNativeArtifacts.yml @@ -0,0 +1,81 @@ +name: Build and publish React Native artifacts + +on: + push: + branches: + - testworkflows + paths: + - package.json + - patches/react-native+*.patch + - Mobile-Expensify + +jobs: + verifyNewDotPatchesAndReactNativeVersionBump: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Check if NewDot patches or react-native version bump have changed + run: | + VERSION=$(jq -r '.dependencies["react-native"]' package.json) + HASH=$(find patches -type f -name "react-native+${VERSION}*.patch" -exec sha256sum {} + | sort | sha256sum | awk '{print $1}') + + git fetch origin ${{ github.event.before }} + git checkout ${{ github.event.before }} + + OLD_VERSION=$(jq -r '.dependencies["react-native"]' package.json) + OLD_HASH=$(find patches -type f -name "react-native+${VERSION}*.patch" -exec sha256sum {} + | sort | sha256sum | awk '{print $1}') + + if [ "$CURRENT_HASH" == "$OLD_HASH" ] && [ "$VERSION" == "$OLD_VERSION" ]; then + echo "No relevant changes Skipping artifacts build" + exit 1 + else + + + if [ "$VERSION" != "$OLD_VERSION" ]; then + echo "Detected react-native version bump ($OLD_VERSION -> $VERSION)" + exit 0 + fi + + if [ "$HASH" != "$OLD_HASH" ]; then + echo "Detected changes in NewDot patches:" + git diff --name-only ${{ github.event.before }}..${{ github.event.after }} -- "patches/react-native+*.patch" + fi + verifyHybridAppPatches: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + - name: Check if HybridApp patches have changed + run: | + VERSION=$(jq -r '.dependencies["react-native"]' package.json) + cd Mobile-Expensify + CURRENT_SUBMODULE_COMMIT=$(git rev-parse HEAD) + CURRENT_PATCHES_HASH=$(find patches -type f -name "react-native+${VERSION}*.patch" -exec sha256sum {} + | sort | sha256sum | awk '{print $1}') + cd .. + + git fetch origin + git checkout ${{ github.event.before }} + + if [ "$CURRENT_SUBMODULE_COMMIT" == "$PREVIOUS_SUBMODULE_COMMIT" ]; then + echo "Submodule commit is the same as the previous one, skipping patch check" + exit 1 + fi + + git submodule update + + cd Mobile-Expensify + PREVIOUS_SUBMODULE_COMMIT=$(git rev-parse HEAD) + PREVIOUS_PATCHES_HASH=$(find patches -type f -name "react-native+${VERSION}*.patch" -exec sha256sum {} + | sort | sha256sum | awk '{print $1}') + + if [ "$CURRENT_PATCHES_HASH" == "$PREVIOUS_PATCHES_HASH" ]; then + echo "No changes in HybridApp patches" + exit 1 + fi + + echo "Detected changes in HybridApp patches:" + git diff --name-only $PREVIOUS_SUBMODULE_COMMIT..$CURRENT_SUBMODULE_COMMIT -- "patches/react-native+*.patch" + exit 0 From 9f5aa4df7be4359426e913dc544d7cd67ae9a45c Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Tue, 8 Apr 2025 16:21:36 +0200 Subject: [PATCH 03/22] Rename job --- .github/workflows/buildAndPublishReactNativeArtifacts.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/buildAndPublishReactNativeArtifacts.yml b/.github/workflows/buildAndPublishReactNativeArtifacts.yml index 22df73e3f66e..abfbf08eb3b8 100644 --- a/.github/workflows/buildAndPublishReactNativeArtifacts.yml +++ b/.github/workflows/buildAndPublishReactNativeArtifacts.yml @@ -10,12 +10,12 @@ on: - Mobile-Expensify jobs: - verifyNewDotPatchesAndReactNativeVersionBump: + verifyNewDotPatchesAndReactNativeVersion: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - - name: Check if NewDot patches or react-native version bump have changed + - name: Check if NewDot patches or react-native version have changed run: | VERSION=$(jq -r '.dependencies["react-native"]' package.json) HASH=$(find patches -type f -name "react-native+${VERSION}*.patch" -exec sha256sum {} + | sort | sha256sum | awk '{print $1}') From 897335d57535127b5ce79cd214958f2c3264b039 Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Tue, 8 Apr 2025 17:12:12 +0200 Subject: [PATCH 04/22] Fix typos --- .github/workflows/buildAndPublishReactNativeArtifacts.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/buildAndPublishReactNativeArtifacts.yml b/.github/workflows/buildAndPublishReactNativeArtifacts.yml index abfbf08eb3b8..3463f2d34893 100644 --- a/.github/workflows/buildAndPublishReactNativeArtifacts.yml +++ b/.github/workflows/buildAndPublishReactNativeArtifacts.yml @@ -3,7 +3,7 @@ name: Build and publish React Native artifacts on: push: branches: - - testworkflows + - main paths: - package.json - patches/react-native+*.patch @@ -29,7 +29,7 @@ jobs: if [ "$CURRENT_HASH" == "$OLD_HASH" ] && [ "$VERSION" == "$OLD_VERSION" ]; then echo "No relevant changes Skipping artifacts build" exit 1 - else + fi if [ "$VERSION" != "$OLD_VERSION" ]; then From 4e281081fda2dd94104981bd3c1b5de31ae8892c Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Tue, 8 Apr 2025 17:23:48 +0200 Subject: [PATCH 05/22] Fix typo --- .github/workflows/buildAndPublishReactNativeArtifacts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildAndPublishReactNativeArtifacts.yml b/.github/workflows/buildAndPublishReactNativeArtifacts.yml index 3463f2d34893..662755c3cd2f 100644 --- a/.github/workflows/buildAndPublishReactNativeArtifacts.yml +++ b/.github/workflows/buildAndPublishReactNativeArtifacts.yml @@ -26,7 +26,7 @@ jobs: OLD_VERSION=$(jq -r '.dependencies["react-native"]' package.json) OLD_HASH=$(find patches -type f -name "react-native+${VERSION}*.patch" -exec sha256sum {} + | sort | sha256sum | awk '{print $1}') - if [ "$CURRENT_HASH" == "$OLD_HASH" ] && [ "$VERSION" == "$OLD_VERSION" ]; then + if [ "$HASH" == "$OLD_HASH" ] && [ "$VERSION" == "$OLD_VERSION" ]; then echo "No relevant changes Skipping artifacts build" exit 1 fi From e7e4f010233de4e8304f307c4171ed74d228459b Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Wed, 9 Apr 2025 12:48:40 +0200 Subject: [PATCH 06/22] Fix HybridApp check --- .../buildAndPublishReactNativeArtifacts.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/buildAndPublishReactNativeArtifacts.yml b/.github/workflows/buildAndPublishReactNativeArtifacts.yml index 662755c3cd2f..d7ce765c8a69 100644 --- a/.github/workflows/buildAndPublishReactNativeArtifacts.yml +++ b/.github/workflows/buildAndPublishReactNativeArtifacts.yml @@ -41,6 +41,7 @@ jobs: echo "Detected changes in NewDot patches:" git diff --name-only ${{ github.event.before }}..${{ github.event.after }} -- "patches/react-native+*.patch" fi + verifyHybridAppPatches: runs-on: ubuntu-latest steps: @@ -57,13 +58,8 @@ jobs: CURRENT_PATCHES_HASH=$(find patches -type f -name "react-native+${VERSION}*.patch" -exec sha256sum {} + | sort | sha256sum | awk '{print $1}') cd .. - git fetch origin - git checkout ${{ github.event.before }} - - if [ "$CURRENT_SUBMODULE_COMMIT" == "$PREVIOUS_SUBMODULE_COMMIT" ]; then - echo "Submodule commit is the same as the previous one, skipping patch check" - exit 1 - fi + git fetch origin ${{ github.event.before }} + git checkout ${{ github.event.before }} git submodule update @@ -71,6 +67,11 @@ jobs: PREVIOUS_SUBMODULE_COMMIT=$(git rev-parse HEAD) PREVIOUS_PATCHES_HASH=$(find patches -type f -name "react-native+${VERSION}*.patch" -exec sha256sum {} + | sort | sha256sum | awk '{print $1}') + if [ "$CURRENT_SUBMODULE_COMMIT" == "$PREVIOUS_SUBMODULE_COMMIT" ]; then + echo "Submodule commit is the same as the previous one, skipping patch check" + exit 1 + fi + if [ "$CURRENT_PATCHES_HASH" == "$PREVIOUS_PATCHES_HASH" ]; then echo "No changes in HybridApp patches" exit 1 @@ -78,4 +79,3 @@ jobs: echo "Detected changes in HybridApp patches:" git diff --name-only $PREVIOUS_SUBMODULE_COMMIT..$CURRENT_SUBMODULE_COMMIT -- "patches/react-native+*.patch" - exit 0 From 6f33a83ed991232269a7668b1f2b0dda40150a3a Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Wed, 9 Apr 2025 13:36:45 +0200 Subject: [PATCH 07/22] Add executable computePatchesHash.sh --- .github/scripts/computePatchesHash.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 .github/scripts/computePatchesHash.sh diff --git a/.github/scripts/computePatchesHash.sh b/.github/scripts/computePatchesHash.sh new file mode 100755 index 000000000000..49bd4c3b9ffd --- /dev/null +++ b/.github/scripts/computePatchesHash.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +version="$1" + +if [ -z "$version" ]; then + echo "Missing version argument" + exit 1 +fi + +find patches -type f -name "react-native+${version}*.patch" -exec sha256sum {} + | sort | sha256sum | awk '{print $1}' From 39298e9a81418c0f65ffbb75f8c4c5006b84cf35 Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Wed, 9 Apr 2025 13:38:19 +0200 Subject: [PATCH 08/22] Use script instead of inlined commands --- .../workflows/buildAndPublishReactNativeArtifacts.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/buildAndPublishReactNativeArtifacts.yml b/.github/workflows/buildAndPublishReactNativeArtifacts.yml index d7ce765c8a69..e14d04f043c0 100644 --- a/.github/workflows/buildAndPublishReactNativeArtifacts.yml +++ b/.github/workflows/buildAndPublishReactNativeArtifacts.yml @@ -18,13 +18,13 @@ jobs: - name: Check if NewDot patches or react-native version have changed run: | VERSION=$(jq -r '.dependencies["react-native"]' package.json) - HASH=$(find patches -type f -name "react-native+${VERSION}*.patch" -exec sha256sum {} + | sort | sha256sum | awk '{print $1}') + HASH=$(./.github/scripts/computePatchesHash.sh $VERSION) git fetch origin ${{ github.event.before }} git checkout ${{ github.event.before }} OLD_VERSION=$(jq -r '.dependencies["react-native"]' package.json) - OLD_HASH=$(find patches -type f -name "react-native+${VERSION}*.patch" -exec sha256sum {} + | sort | sha256sum | awk '{print $1}') + OLD_HASH=$(./.github/scripts/computePatchesHash.sh $VERSION) if [ "$HASH" == "$OLD_HASH" ] && [ "$VERSION" == "$OLD_VERSION" ]; then echo "No relevant changes Skipping artifacts build" @@ -55,17 +55,17 @@ jobs: VERSION=$(jq -r '.dependencies["react-native"]' package.json) cd Mobile-Expensify CURRENT_SUBMODULE_COMMIT=$(git rev-parse HEAD) - CURRENT_PATCHES_HASH=$(find patches -type f -name "react-native+${VERSION}*.patch" -exec sha256sum {} + | sort | sha256sum | awk '{print $1}') + CURRENT_PATCHES_HASH=$(../.github/scripts/computePatchesHash.sh $VERSION) cd .. git fetch origin ${{ github.event.before }} - git checkout ${{ github.event.before }} + git checkout ${{ github.event.before }} git submodule update cd Mobile-Expensify PREVIOUS_SUBMODULE_COMMIT=$(git rev-parse HEAD) - PREVIOUS_PATCHES_HASH=$(find patches -type f -name "react-native+${VERSION}*.patch" -exec sha256sum {} + | sort | sha256sum | awk '{print $1}') + PREVIOUS_PATCHES_HASH=$(../.github/scripts/computePatchesHash.sh $VERSION) if [ "$CURRENT_SUBMODULE_COMMIT" == "$PREVIOUS_SUBMODULE_COMMIT" ]; then echo "Submodule commit is the same as the previous one, skipping patch check" From a30a1952e22520e435239e5d05ada46587dbc8f8 Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Wed, 9 Apr 2025 15:31:26 +0200 Subject: [PATCH 09/22] Add NewDot artifacts build and publication job --- .github/scripts/getNewPatchedRNVersion.sh | 32 +++++++++++++ .../buildAndPublishReactNativeArtifacts.yml | 45 ++++++++++++++++++- 2 files changed, 75 insertions(+), 2 deletions(-) create mode 100755 .github/scripts/getNewPatchedRNVersion.sh diff --git a/.github/scripts/getNewPatchedRNVersion.sh b/.github/scripts/getNewPatchedRNVersion.sh new file mode 100755 index 000000000000..bb93c3dde630 --- /dev/null +++ b/.github/scripts/getNewPatchedRNVersion.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +VERSION="$1" + +if [ -z "$VERSION" ]; then + echo "Missing version argument" + exit 1 +fi + +if [[ "$IS_HYBRID_BUILD" == "true" ]]; then + PACKAGE="react-hybrid" +else + PACKAGE="react-standalone" +fi + +MAVEN_METADATA_URL="https://maven.pkg.github.com/mateuuszzzzz/App/com/example/${PACKAGE}/react-android/maven-metadata.xml" + +VERSIONS_FROM_MAVEN_REPOSITORY=$(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + "$MAVEN_METADATA_URL" | \ + grep -o "${VERSION}-[0-9]\+" | \ + grep -o "${VERSION}-[0-9]" | \ + sort -t'-' -k2 -n) + +LATEST_PATCHED_VERSION=$(echo "$VERSIONS_FROM_MAVEN_REPOSITORY" | 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 diff --git a/.github/workflows/buildAndPublishReactNativeArtifacts.yml b/.github/workflows/buildAndPublishReactNativeArtifacts.yml index e14d04f043c0..41364f0513fb 100644 --- a/.github/workflows/buildAndPublishReactNativeArtifacts.yml +++ b/.github/workflows/buildAndPublishReactNativeArtifacts.yml @@ -14,7 +14,8 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + # v4 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - name: Check if NewDot patches or react-native version have changed run: | VERSION=$(jq -r '.dependencies["react-native"]' package.json) @@ -46,7 +47,8 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + # v4 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: submodules: true fetch-depth: 0 @@ -79,3 +81,42 @@ jobs: echo "Detected changes in HybridApp patches:" git diff --name-only $PREVIOUS_SUBMODULE_COMMIT..$CURRENT_SUBMODULE_COMMIT -- "patches/react-native+*.patch" + buildAndPublishRNArtifactsForStandaloneNewDot: + runs-on: ubuntu-latest + if: ${{ always() && needs.verifyNewDotPatchesAndReactNativeVersion.result == 'success'}} + needs: verifyNewDotPatchesAndReactNativeVersion + steps: + - name: Checkout + # v4 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + + - name: Setup Node + uses: ./.github/actions/composite/setupNode + + - name: Setup Java + # v4 + uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 + with: + distribution: oracle + java-version: 17 + + - name: Setup Gradle + # v4 + uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 + + - name: Determine new patched RN version + run: | + VERSION=$(jq -r '.dependencies["react-native"]' package.json) + echo "NEW_PATCHED_VERSION=$(./.github/scripts/getNewPatchedRNVersion.sh $VERSION)" >> $GITHUB_ENV + - name: Build and publish RN artifacts + run: | + cd android + 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: ${{ secrets.GITHUB_TOKEN }} + IS_HYBRID_BUILD: "false" + PATCHED_VERSION: ${{ env.NEW_PATCHED_VERSION }} + COMMIT_HASH: ${{ github.event.after }} From 6af47e6079fb2952da816ca09d9cdd2d1c7c9f21 Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Wed, 9 Apr 2025 15:32:33 +0200 Subject: [PATCH 10/22] Fix maven url --- .github/scripts/getNewPatchedRNVersion.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/getNewPatchedRNVersion.sh b/.github/scripts/getNewPatchedRNVersion.sh index bb93c3dde630..bba8ba9bbb11 100755 --- a/.github/scripts/getNewPatchedRNVersion.sh +++ b/.github/scripts/getNewPatchedRNVersion.sh @@ -13,7 +13,7 @@ else PACKAGE="react-standalone" fi -MAVEN_METADATA_URL="https://maven.pkg.github.com/mateuuszzzzz/App/com/example/${PACKAGE}/react-android/maven-metadata.xml" +MAVEN_METADATA_URL="https://maven.pkg.github.com/Expensify/App/com/example/${PACKAGE}/react-android/maven-metadata.xml" VERSIONS_FROM_MAVEN_REPOSITORY=$(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" \ "$MAVEN_METADATA_URL" | \ From ab62ab0d3dfe695f66149ac3e6b88e73fa2e0617 Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Wed, 9 Apr 2025 16:15:08 +0200 Subject: [PATCH 11/22] Update envs names --- .../workflows/buildAndPublishReactNativeArtifacts.yml | 10 ++++++++++ patches/react-native+0.77.1+024+publish-gradle.patch | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/buildAndPublishReactNativeArtifacts.yml b/.github/workflows/buildAndPublishReactNativeArtifacts.yml index 41364f0513fb..781bb49a4b80 100644 --- a/.github/workflows/buildAndPublishReactNativeArtifacts.yml +++ b/.github/workflows/buildAndPublishReactNativeArtifacts.yml @@ -104,6 +104,11 @@ jobs: # v4 uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 + - name: Save patches hash + run: | + VERSION=$(jq -r '.dependencies["react-native"]' package.json) + echo "PATCHES_HASH=$(./.github/scripts/computePatchesHash.sh $VERSION)" >> $GITHUB_ENV + - name: Determine new patched RN version run: | VERSION=$(jq -r '.dependencies["react-native"]' package.json) @@ -111,6 +116,10 @@ jobs: - name: Build and publish RN artifacts run: | cd android + echo "Starting artifacts build for standalone NewDot" + echo "Version: ${{ env.NEW_PATCHED_VERSION }}" + echo "Commit hash: ${{ env.COMMIT_HASH }}" + echo "Patches hash: ${{ env.PATCHES_HASH }}" export ORG_GRADLE_PROJECT_reactNativeArchitectures="armeabi-v7a,arm64-v8a,x86,x86_64" ./gradlew buildReactNativeArtifacts -x lint -x test -x check ./gradlew publishReactNativeArtifacts @@ -120,3 +129,4 @@ jobs: IS_HYBRID_BUILD: "false" PATCHED_VERSION: ${{ env.NEW_PATCHED_VERSION }} COMMIT_HASH: ${{ github.event.after }} + PATCHES_HASH: ${{ env.PATCHES_HASH }} diff --git a/patches/react-native+0.77.1+024+publish-gradle.patch b/patches/react-native+0.77.1+024+publish-gradle.patch index eb4b8e734bab..5e9e8245b158 100644 --- a/patches/react-native+0.77.1+024+publish-gradle.patch +++ b/patches/react-native+0.77.1+024+publish-gradle.patch @@ -10,8 +10,8 @@ index 32287a7..68c9284 100644 +def mavenURL = "https://maven.pkg.github.com/Expensify/App" + +def patchedVersion = System.getenv("PATCHED_VERSION") -+def isHybridRelease = System.getenv("IS_HYBRID_RELEASE")?.toBoolean() -+def groupId = isHybridRelease ? "com.expensify.react-standalone" : "com.expensify.react-hybrid" ++def isHybridBuild = System.getenv("IS_HYBRID_BUILD")?.toBoolean() ++def groupId = isHybridBuild ? "com.expensify.react-standalone" : "com.expensify.react-hybrid" publishing { publications { From 8bd01f932e47ef0dec73ea608bdcf8885d5662e6 Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Thu, 10 Apr 2025 16:44:27 +0200 Subject: [PATCH 12/22] Add flow for HybridApp --- .github/scripts/computePatchesHash.sh | 12 +- .github/scripts/getNewPatchedRNVersion.sh | 4 +- .../buildAndPublishReactNativeArtifacts.yml | 115 +++++++++++++++--- 3 files changed, 107 insertions(+), 24 deletions(-) diff --git a/.github/scripts/computePatchesHash.sh b/.github/scripts/computePatchesHash.sh index 49bd4c3b9ffd..196f49bcf21d 100755 --- a/.github/scripts/computePatchesHash.sh +++ b/.github/scripts/computePatchesHash.sh @@ -1,10 +1,14 @@ #!/bin/bash -version="$1" +if [ -z "$VERSION" ]; then + echo "VERSION env variable is not set" + exit 1 +fi -if [ -z "$version" ]; then - echo "Missing version argument" +if [ -z "$PATCHES_PATHS" ]; then + echo "PATCHES_PATHS env variable is not set" exit 1 fi -find patches -type f -name "react-native+${version}*.patch" -exec sha256sum {} + | sort | sha256sum | awk '{print $1}' +IFS=' ' read -ra PATCH_DIRS <<< "$PATCHES_PATHS" +find "${PATCH_DIRS[@]}" -type f -name "react-native+${VERSION}*.patch" -exec sha256sum {} + | sort | sha256sum | awk '{print $1}' diff --git a/.github/scripts/getNewPatchedRNVersion.sh b/.github/scripts/getNewPatchedRNVersion.sh index bba8ba9bbb11..8b84b8cd5e84 100755 --- a/.github/scripts/getNewPatchedRNVersion.sh +++ b/.github/scripts/getNewPatchedRNVersion.sh @@ -1,9 +1,7 @@ #!/bin/bash -VERSION="$1" - if [ -z "$VERSION" ]; then - echo "Missing version argument" + echo "VERSION env variable is not set" exit 1 fi diff --git a/.github/workflows/buildAndPublishReactNativeArtifacts.yml b/.github/workflows/buildAndPublishReactNativeArtifacts.yml index 781bb49a4b80..b39aeaca0d6b 100644 --- a/.github/workflows/buildAndPublishReactNativeArtifacts.yml +++ b/.github/workflows/buildAndPublishReactNativeArtifacts.yml @@ -16,23 +16,24 @@ jobs: - name: Checkout # v4 uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - name: Check if NewDot patches or react-native version have changed run: | VERSION=$(jq -r '.dependencies["react-native"]' package.json) - HASH=$(./.github/scripts/computePatchesHash.sh $VERSION) + HASH=$(VERSION=$VERSION ./.github/scripts/computePatchesHash.sh) git fetch origin ${{ github.event.before }} git checkout ${{ github.event.before }} OLD_VERSION=$(jq -r '.dependencies["react-native"]' package.json) - OLD_HASH=$(./.github/scripts/computePatchesHash.sh $VERSION) + # If version has changed and we want to find differences in patches, we need to consider pattern that involves previous react-native version + OLD_HASH=$(VERSION=$OLD_VERSION ./.github/scripts/computePatchesHash.sh) if [ "$HASH" == "$OLD_HASH" ] && [ "$VERSION" == "$OLD_VERSION" ]; then - echo "No relevant changes Skipping artifacts build" + echo "No relevant changes" exit 1 fi - if [ "$VERSION" != "$OLD_VERSION" ]; then echo "Detected react-native version bump ($OLD_VERSION -> $VERSION)" exit 0 @@ -42,6 +43,8 @@ jobs: echo "Detected changes in NewDot patches:" git diff --name-only ${{ github.event.before }}..${{ github.event.after }} -- "patches/react-native+*.patch" fi + env: + PATCHES_PATHS: "patches" verifyHybridAppPatches: runs-on: ubuntu-latest @@ -52,35 +55,40 @@ jobs: with: submodules: true fetch-depth: 0 + - name: Get react-native version + run: | + echo "VERSION=$(jq -r '.dependencies["react-native"]' package.json)" >> $GITHUB_ENV + - name: Check if HybridApp patches have changed run: | - VERSION=$(jq -r '.dependencies["react-native"]' package.json) - cd Mobile-Expensify - CURRENT_SUBMODULE_COMMIT=$(git rev-parse HEAD) - CURRENT_PATCHES_HASH=$(../.github/scripts/computePatchesHash.sh $VERSION) - cd .. + CURRENT_SUBMODULE_COMMIT=$(git rev-parse :Mobile-Expensify) + CURRENT_PATCHES_HASH=$(./.github/scripts/computePatchesHash.sh) git fetch origin ${{ github.event.before }} git checkout ${{ github.event.before }} git submodule update - cd Mobile-Expensify - PREVIOUS_SUBMODULE_COMMIT=$(git rev-parse HEAD) - PREVIOUS_PATCHES_HASH=$(../.github/scripts/computePatchesHash.sh $VERSION) + PREVIOUS_SUBMODULE_COMMIT=$(git rev-parse :Mobile-Expensify) if [ "$CURRENT_SUBMODULE_COMMIT" == "$PREVIOUS_SUBMODULE_COMMIT" ]; then echo "Submodule commit is the same as the previous one, skipping patch check" exit 1 fi + PREVIOUS_PATCHES_HASH=$(./.github/scripts/computePatchesHash.sh) + if [ "$CURRENT_PATCHES_HASH" == "$PREVIOUS_PATCHES_HASH" ]; then echo "No changes in HybridApp patches" exit 1 fi echo "Detected changes in HybridApp patches:" - git diff --name-only $PREVIOUS_SUBMODULE_COMMIT..$CURRENT_SUBMODULE_COMMIT -- "patches/react-native+*.patch" + git -C Mobile-Expensify diff --name-only $PREVIOUS_SUBMODULE_COMMIT..$CURRENT_SUBMODULE_COMMIT -- "patches/react-native+*.patch" + env: + PATCHES_PATHS: "Mobile-Expensify/patches" + VERSION: ${{ env.VERSION }} + buildAndPublishRNArtifactsForStandaloneNewDot: runs-on: ubuntu-latest if: ${{ always() && needs.verifyNewDotPatchesAndReactNativeVersion.result == 'success'}} @@ -90,6 +98,10 @@ jobs: # v4 uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - name: Get react-native version + run: | + echo "VERSION=$(jq -r '.dependencies["react-native"]' package.json)" >> $GITHUB_ENV + - name: Setup Node uses: ./.github/actions/composite/setupNode @@ -106,13 +118,19 @@ jobs: - name: Save patches hash run: | - VERSION=$(jq -r '.dependencies["react-native"]' package.json) - echo "PATCHES_HASH=$(./.github/scripts/computePatchesHash.sh $VERSION)" >> $GITHUB_ENV + echo "PATCHES_HASH=$(./.github/scripts/computePatchesHash.sh)" >> $GITHUB_ENV + env: + VERSION: ${{ env.VERSION }} + PATCHES_PATHS: "patches" - name: Determine new patched RN version run: | - VERSION=$(jq -r '.dependencies["react-native"]' package.json) - echo "NEW_PATCHED_VERSION=$(./.github/scripts/getNewPatchedRNVersion.sh $VERSION)" >> $GITHUB_ENV + echo "NEW_PATCHED_VERSION=$(./.github/scripts/getNewPatchedRNVersion.sh)" >> $GITHUB_ENV + env: + VERSION: ${{ env.VERSION }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + IS_HYBRID_BUILD: "false" + - name: Build and publish RN artifacts run: | cd android @@ -130,3 +148,66 @@ jobs: PATCHED_VERSION: ${{ env.NEW_PATCHED_VERSION }} COMMIT_HASH: ${{ github.event.after }} PATCHES_HASH: ${{ env.PATCHES_HASH }} + + buildAndPublishRNArtifactsForHybridApp: + runs-on: ubuntu-latest + if: ${{ always() && (needs.verifyNewDotPatchesAndReactNativeVersion.result == 'success' || needs.verifyHybridAppPatches.result == 'success')}} + needs: [verifyNewDotPatchesAndReactNativeVersion, verifyHybridAppPatches] + steps: + - name: Checkout + # v4 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + with: + submodules: true + + - name: Get react-native version + run: | + echo "VERSION=$(jq -r '.dependencies["react-native"]' package.json)" >> $GITHUB_ENV + + - name: Setup Node + uses: ./.github/actions/composite/setupNode + with: + IS_HYBRID_BUILD: "true" + + - name: Setup Java + # v4 + uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 + with: + distribution: oracle + java-version: 17 + + - name: Setup Gradle + # v4 + uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 + + - name: Save patches hash + run: | + echo "PATCHES_HASH=$(./.github/scripts/computePatchesHash.sh)" >> $GITHUB_ENV + env: + VERSION: ${{ env.VERSION }} + PATCHES_PATHS: "patches Mobile-Expensify/patches" + + - name: Determine new patched RN version + run: | + echo "NEW_PATCHED_VERSION=$(./.github/scripts/getNewPatchedRNVersion.sh)" >> $GITHUB_ENV + env: + VERSION: ${{ env.VERSION }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + IS_HYBRID_BUILD: "true" + - name: Build and publish RN artifacts + run: | + cd Mobile-Expensify/Android + echo "Starting artifacts build for HybridApp" + echo "Version: ${{ env.NEW_PATCHED_VERSION }}" + echo "Commit hash: ${{ env.COMMIT_HASH }}" + echo "Patches hash: ${{ env.PATCHES_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: ${{ secrets.GITHUB_TOKEN }} + IS_HYBRID_BUILD: "true" + PATCHED_VERSION: ${{ env.NEW_PATCHED_VERSION }} + COMMIT_HASH: ${{ github.event.after }} + PATCHES_HASH: ${{ env.PATCHES_HASH }} From d19f7ed8c3727a6f70d8aa5e5b6fcb8ff00a40b9 Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Thu, 10 Apr 2025 18:19:54 +0200 Subject: [PATCH 13/22] Fix issue with groovy --- android/build.gradle | 2 +- patches/react-native+0.77.1+024+publish-gradle.patch | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index ad16663894ef..0bbb4f8f611d 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -85,4 +85,4 @@ task buildReactNativeArtifacts { task publishReactNativeArtifacts { dependsOn(gradle.includedBuild('react-native').task(':packages:react-native:ReactAndroid:publishReleasePublicationToMavenRepository')) -} \ No newline at end of file +} diff --git a/patches/react-native+0.77.1+024+publish-gradle.patch b/patches/react-native+0.77.1+024+publish-gradle.patch index 5e9e8245b158..415b83af56e5 100644 --- a/patches/react-native+0.77.1+024+publish-gradle.patch +++ b/patches/react-native+0.77.1+024+publish-gradle.patch @@ -11,7 +11,7 @@ index 32287a7..68c9284 100644 + +def patchedVersion = System.getenv("PATCHED_VERSION") +def isHybridBuild = System.getenv("IS_HYBRID_BUILD")?.toBoolean() -+def groupId = isHybridBuild ? "com.expensify.react-standalone" : "com.expensify.react-hybrid" ++def publishingGroupId = isHybridBuild ? "com.expensify.react-standalone" : "com.expensify.react-hybrid" publishing { publications { @@ -19,7 +19,7 @@ index 32287a7..68c9284 100644 } } -+ groupId = groupId ++ groupId = publishingGroupId + // We populate the publishing version using the project version, // appending -SNAPSHOT if on nightly or prerelase. From 1e6bc286bcd38705796e5462dbe5345b93d48458 Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Tue, 22 Apr 2025 13:49:48 +0200 Subject: [PATCH 14/22] Address review comments associated to workflow --- .../buildAndPublishReactNativeArtifacts.yml | 229 ++++++------------ 1 file changed, 69 insertions(+), 160 deletions(-) diff --git a/.github/workflows/buildAndPublishReactNativeArtifacts.yml b/.github/workflows/buildAndPublishReactNativeArtifacts.yml index b39aeaca0d6b..1bc35e49e64f 100644 --- a/.github/workflows/buildAndPublishReactNativeArtifacts.yml +++ b/.github/workflows/buildAndPublishReactNativeArtifacts.yml @@ -7,207 +7,116 @@ on: paths: - package.json - patches/react-native+*.patch + - patches/@react-native+*.patch - Mobile-Expensify jobs: - verifyNewDotPatchesAndReactNativeVersion: - runs-on: ubuntu-latest + publish: + runs-on: ${{ github.repository_owner == 'Expensify' && 'ubuntu-latest-xl' || 'ubuntu-latest' }} + strategy: + matrix: + is_hybrid: [true, false] + env: + PATCHES_PATHS: ${{ matrix.is_hybrid && 'Mobile-Expensify/patches' || 'patches' }} steps: + # v4 - name: Checkout - # v4 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - - name: Check if NewDot patches or react-native version have changed - run: | - VERSION=$(jq -r '.dependencies["react-native"]' package.json) - HASH=$(VERSION=$VERSION ./.github/scripts/computePatchesHash.sh) - - git fetch origin ${{ github.event.before }} - git checkout ${{ github.event.before }} - - OLD_VERSION=$(jq -r '.dependencies["react-native"]' package.json) - # If version has changed and we want to find differences in patches, we need to consider pattern that involves previous react-native version - OLD_HASH=$(VERSION=$OLD_VERSION ./.github/scripts/computePatchesHash.sh) - - if [ "$HASH" == "$OLD_HASH" ] && [ "$VERSION" == "$OLD_VERSION" ]; then - echo "No relevant changes" - exit 1 - fi - - if [ "$VERSION" != "$OLD_VERSION" ]; then - echo "Detected react-native version bump ($OLD_VERSION -> $VERSION)" - exit 0 - fi - - if [ "$HASH" != "$OLD_HASH" ]; then - echo "Detected changes in NewDot patches:" - git diff --name-only ${{ github.event.before }}..${{ github.event.after }} -- "patches/react-native+*.patch" - fi - env: - PATCHES_PATHS: "patches" - - verifyHybridAppPatches: - runs-on: ubuntu-latest - steps: - - name: Checkout - # v4 uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: - submodules: true - fetch-depth: 0 - - name: Get react-native version - run: | - echo "VERSION=$(jq -r '.dependencies["react-native"]' package.json)" >> $GITHUB_ENV + submodules: ${{ matrix.is_hybrid }} + ref: ${{ github.event.before }} - - name: Check if HybridApp patches have changed - run: | - CURRENT_SUBMODULE_COMMIT=$(git rev-parse :Mobile-Expensify) - CURRENT_PATCHES_HASH=$(./.github/scripts/computePatchesHash.sh) - - git fetch origin ${{ github.event.before }} - git checkout ${{ github.event.before }} + - name: Get previous commit hash + id: getOldHash + run: echo "HASH=$(git rev-parse ${{ matrix.is_hybrid == 'true' && ':Mobile-Expensify' || 'HEAD' }})" >> "$GITHUB_OUTPUT" - git submodule update - - PREVIOUS_SUBMODULE_COMMIT=$(git rev-parse :Mobile-Expensify) - - if [ "$CURRENT_SUBMODULE_COMMIT" == "$PREVIOUS_SUBMODULE_COMMIT" ]; then - echo "Submodule commit is the same as the previous one, skipping patch check" - exit 1 - fi - - PREVIOUS_PATCHES_HASH=$(./.github/scripts/computePatchesHash.sh) - - if [ "$CURRENT_PATCHES_HASH" == "$PREVIOUS_PATCHES_HASH" ]; then - echo "No changes in HybridApp patches" - exit 1 - fi - - echo "Detected changes in HybridApp patches:" - git -C Mobile-Expensify diff --name-only $PREVIOUS_SUBMODULE_COMMIT..$CURRENT_SUBMODULE_COMMIT -- "patches/react-native+*.patch" - env: - PATCHES_PATHS: "Mobile-Expensify/patches" - VERSION: ${{ env.VERSION }} + - name: Get previous react-native version + id: getOldVersion + run: echo "VERSION=$(jq -r '.dependencies["react-native"]' package.json)" >> "$GITHUB_OUTPUT" - buildAndPublishRNArtifactsForStandaloneNewDot: - runs-on: ubuntu-latest - if: ${{ always() && needs.verifyNewDotPatchesAndReactNativeVersion.result == 'success'}} - needs: verifyNewDotPatchesAndReactNativeVersion - steps: - - name: Checkout - # v4 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - - name: Get react-native version + - name: Checkout new ref run: | - echo "VERSION=$(jq -r '.dependencies["react-native"]' package.json)" >> $GITHUB_ENV - - - name: Setup Node - uses: ./.github/actions/composite/setupNode - - - name: Setup Java - # v4 - uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 - with: - distribution: oracle - java-version: 17 + git fetch origin ${{ github.event.after }} --depth=1 + git checkout ${{ github.event.after }} + git submodule update - - name: Setup Gradle - # v4 - uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 + - name: Get new commit hash + id: getNewHash + run: echo "HASH=$(git rev-parse ${{ matrix.is_hybrid == 'true' && ':Mobile-Expensify' || 'HEAD' }})" >> "$GITHUB_OUTPUT" - - name: Save patches hash - run: | - echo "PATCHES_HASH=$(./.github/scripts/computePatchesHash.sh)" >> $GITHUB_ENV - env: - VERSION: ${{ env.VERSION }} - PATCHES_PATHS: "patches" + - name: Get new react-native version + id: getNewVersion + run: echo "VERSION=$(jq -r '.dependencies["react-native"]' package.json)" >> "$GITHUB_OUTPUT" - - name: Determine new patched RN version + - name: Check if version changed + id: didVersionChange run: | - echo "NEW_PATCHED_VERSION=$(./.github/scripts/getNewPatchedRNVersion.sh)" >> $GITHUB_ENV - env: - VERSION: ${{ env.VERSION }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - IS_HYBRID_BUILD: "false" + 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: Build and publish RN artifacts + - name: Check if patches changed + id: didPatchesChange run: | - cd android - echo "Starting artifacts build for standalone NewDot" - echo "Version: ${{ env.NEW_PATCHED_VERSION }}" - echo "Commit hash: ${{ env.COMMIT_HASH }}" - echo "Patches hash: ${{ env.PATCHES_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: ${{ secrets.GITHUB_TOKEN }} - IS_HYBRID_BUILD: "false" - PATCHED_VERSION: ${{ env.NEW_PATCHED_VERSION }} - COMMIT_HASH: ${{ github.event.after }} - PATCHES_HASH: ${{ env.PATCHES_HASH }} - - buildAndPublishRNArtifactsForHybridApp: - runs-on: ubuntu-latest - if: ${{ always() && (needs.verifyNewDotPatchesAndReactNativeVersion.result == 'success' || needs.verifyHybridAppPatches.result == 'success')}} - needs: [verifyNewDotPatchesAndReactNativeVersion, verifyHybridAppPatches] - steps: - - name: Checkout - # v4 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - submodules: true + if git ${{ matrix.is_hybrid == 'true' && '-C Mobile-Expensify' }} diff --exit-code --name-only ${{ steps.getOldHash.outputs.HASH }}..${{ steps.getNewHash.outputs.HASH }} -- patches/react-native+*.patch patches/@react-native+*.patch; then + echo "::notice::Detected changes in NewDot patches" + echo "DID_PATCHES_CHANGE=true" >> "$GITHUB_OUTPUT" + else + echo "DID_PATCHES_CHANGE=false" >> "$GITHUB_OUTPUT" + fi - - name: Get react-native version + - name: Check if we should build and publish the package + id: shouldPublish run: | - echo "VERSION=$(jq -r '.dependencies["react-native"]' package.json)" >> $GITHUB_ENV + 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: "true" + IS_HYBRID_BUILD: ${{ matrix.is_hybrid }} + # v4 - name: Setup Java - # v4 + if: ${{ steps.shouldPublish.outputs.SHOULD_PUBLISH == 'true' }} uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 with: distribution: oracle java-version: 17 + # v4 - name: Setup Gradle - # v4 + if: ${{ steps.shouldPublish.outputs.SHOULD_PUBLISH == 'true' }} uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 - - name: Save patches hash - run: | - echo "PATCHES_HASH=$(./.github/scripts/computePatchesHash.sh)" >> $GITHUB_ENV - env: - VERSION: ${{ env.VERSION }} - PATCHES_PATHS: "patches Mobile-Expensify/patches" - - name: Determine new patched RN version - run: | - echo "NEW_PATCHED_VERSION=$(./.github/scripts/getNewPatchedRNVersion.sh)" >> $GITHUB_ENV + if: ${{ steps.shouldPublish.outputs.SHOULD_PUBLISH == 'true' }} + id: getNewPatchedVersion + run: echo "NEW_PATCHED_VERSION=$(./.github/scripts/getNewPatchedRNVersion.sh)" >> $GITHUB_OUTPUT env: - VERSION: ${{ env.VERSION }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - IS_HYBRID_BUILD: "true" + 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: | - cd Mobile-Expensify/Android - echo "Starting artifacts build for HybridApp" - echo "Version: ${{ env.NEW_PATCHED_VERSION }}" + echo "Starting artifacts build for ${{ matrix.is_hybrid == 'true' && 'HybridApp' || 'NewDot Standalone' }}" + echo "Version: ${{ env.PATCHED_VERSION }}" echo "Commit hash: ${{ env.COMMIT_HASH }}" - echo "Patches hash: ${{ env.PATCHES_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: ${{ secrets.GITHUB_TOKEN }} - IS_HYBRID_BUILD: "true" - PATCHED_VERSION: ${{ env.NEW_PATCHED_VERSION }} + GH_PUBLISH_TOKEN: ${{ github.token }} + IS_HYBRID_BUILD: ${{ matrix.is_hybrid }} + PATCHED_VERSION: ${{ steps.getNewPatchedVersion.outputs.NEW_PATCHED_VERSION }} COMMIT_HASH: ${{ github.event.after }} - PATCHES_HASH: ${{ env.PATCHES_HASH }} From b225e52fa5f3dd2ffaeb784316bc92b4ab787a45 Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Tue, 22 Apr 2025 14:25:52 +0200 Subject: [PATCH 15/22] Take NewDot patches into consideration on Hybrid builds --- .../buildAndPublishReactNativeArtifacts.yml | 39 ++++++++++++++----- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/.github/workflows/buildAndPublishReactNativeArtifacts.yml b/.github/workflows/buildAndPublishReactNativeArtifacts.yml index 1bc35e49e64f..2fc398f3480a 100644 --- a/.github/workflows/buildAndPublishReactNativeArtifacts.yml +++ b/.github/workflows/buildAndPublishReactNativeArtifacts.yml @@ -26,9 +26,14 @@ jobs: submodules: ${{ matrix.is_hybrid }} ref: ${{ github.event.before }} - - name: Get previous commit hash - id: getOldHash - run: echo "HASH=$(git rev-parse ${{ matrix.is_hybrid == 'true' && ':Mobile-Expensify' || 'HEAD' }})" >> "$GITHUB_OUTPUT" + - 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 @@ -40,9 +45,14 @@ jobs: git checkout ${{ github.event.after }} git submodule update - - name: Get new commit hash - id: getNewHash - run: echo "HASH=$(git rev-parse ${{ matrix.is_hybrid == 'true' && ':Mobile-Expensify' || 'HEAD' }})" >> "$GITHUB_OUTPUT" + - 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 @@ -60,13 +70,22 @@ jobs: - name: Check if patches changed id: didPatchesChange run: | - if git ${{ matrix.is_hybrid == 'true' && '-C Mobile-Expensify' }} diff --exit-code --name-only ${{ steps.getOldHash.outputs.HASH }}..${{ steps.getNewHash.outputs.HASH }} -- patches/react-native+*.patch patches/@react-native+*.patch; then - echo "::notice::Detected changes in NewDot patches" + 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" - else - echo "DID_PATCHES_CHANGE=false" >> "$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: | From 02e651c4f3429617222c5a76d4e95a3fc633eaca Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Tue, 22 Apr 2025 14:33:36 +0200 Subject: [PATCH 16/22] Rename workflow --- ...tiveArtifacts.yml => publishReactNativeAndroidArtifacts.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{buildAndPublishReactNativeArtifacts.yml => publishReactNativeAndroidArtifacts.yml} (99%) diff --git a/.github/workflows/buildAndPublishReactNativeArtifacts.yml b/.github/workflows/publishReactNativeAndroidArtifacts.yml similarity index 99% rename from .github/workflows/buildAndPublishReactNativeArtifacts.yml rename to .github/workflows/publishReactNativeAndroidArtifacts.yml index 2fc398f3480a..29bbfa44aacc 100644 --- a/.github/workflows/buildAndPublishReactNativeArtifacts.yml +++ b/.github/workflows/publishReactNativeAndroidArtifacts.yml @@ -1,4 +1,4 @@ -name: Build and publish React Native artifacts +name: Publish React Native Android Artifacts on: push: From a46915925b5bbf32f315d4a553e18a693cc03f1d Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Tue, 22 Apr 2025 14:50:24 +0200 Subject: [PATCH 17/22] Adjust workflow scripts --- .github/scripts/computePatchesHash.sh | 14 -------------- .github/scripts/getNewPatchedRNVersion.sh | 10 ++++++---- 2 files changed, 6 insertions(+), 18 deletions(-) delete mode 100755 .github/scripts/computePatchesHash.sh diff --git a/.github/scripts/computePatchesHash.sh b/.github/scripts/computePatchesHash.sh deleted file mode 100755 index 196f49bcf21d..000000000000 --- a/.github/scripts/computePatchesHash.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -if [ -z "$VERSION" ]; then - echo "VERSION env variable is not set" - exit 1 -fi - -if [ -z "$PATCHES_PATHS" ]; then - echo "PATCHES_PATHS env variable is not set" - exit 1 -fi - -IFS=' ' read -ra PATCH_DIRS <<< "$PATCHES_PATHS" -find "${PATCH_DIRS[@]}" -type f -name "react-native+${VERSION}*.patch" -exec sha256sum {} + | sort | sha256sum | awk '{print $1}' diff --git a/.github/scripts/getNewPatchedRNVersion.sh b/.github/scripts/getNewPatchedRNVersion.sh index 8b84b8cd5e84..298a37fecf07 100755 --- a/.github/scripts/getNewPatchedRNVersion.sh +++ b/.github/scripts/getNewPatchedRNVersion.sh @@ -1,16 +1,18 @@ #!/bin/bash -if [ -z "$VERSION" ]; then - echo "VERSION env variable is not set" +if [ -z "$GITHUB_TOKEN" ]; then + echo "GITHUB_TOKEN env variable is not set" exit 1 fi if [[ "$IS_HYBRID_BUILD" == "true" ]]; then - PACKAGE="react-hybrid" + readonly PACKAGE="react-hybrid" else - PACKAGE="react-standalone" + readonly PACKAGE="react-standalone" fi +readonly VERSION="$(jq -r '.dependencies["react-native"]' package.json)" + MAVEN_METADATA_URL="https://maven.pkg.github.com/Expensify/App/com/example/${PACKAGE}/react-android/maven-metadata.xml" VERSIONS_FROM_MAVEN_REPOSITORY=$(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" \ From dc119f8a76d94eef8c20424d0d00bc6a8ed43ecf Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Tue, 22 Apr 2025 14:56:33 +0200 Subject: [PATCH 18/22] Remove unused env from workflow --- .github/workflows/publishReactNativeAndroidArtifacts.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/publishReactNativeAndroidArtifacts.yml b/.github/workflows/publishReactNativeAndroidArtifacts.yml index 29bbfa44aacc..8b91bc5a1754 100644 --- a/.github/workflows/publishReactNativeAndroidArtifacts.yml +++ b/.github/workflows/publishReactNativeAndroidArtifacts.yml @@ -16,8 +16,6 @@ jobs: strategy: matrix: is_hybrid: [true, false] - env: - PATCHES_PATHS: ${{ matrix.is_hybrid && 'Mobile-Expensify/patches' || 'patches' }} steps: # v4 - name: Checkout From ed9aef9e762bca30b0806618bf63914277009694 Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Wed, 23 Apr 2025 14:24:26 +0200 Subject: [PATCH 19/22] Use gh api instead of curl --- .github/scripts/getNewPatchedRNVersion.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/scripts/getNewPatchedRNVersion.sh b/.github/scripts/getNewPatchedRNVersion.sh index 298a37fecf07..49345e71b1c5 100755 --- a/.github/scripts/getNewPatchedRNVersion.sh +++ b/.github/scripts/getNewPatchedRNVersion.sh @@ -11,19 +11,19 @@ else readonly PACKAGE="react-standalone" fi -readonly VERSION="$(jq -r '.dependencies["react-native"]' package.json)" +VERSION="$(jq -r '.dependencies["react-native"]' package.json)" +readonly VERSION -MAVEN_METADATA_URL="https://maven.pkg.github.com/Expensify/App/com/example/${PACKAGE}/react-android/maven-metadata.xml" +# List all versions of the package +PACKAGE_VERSIONS="$(gh api "/orgs/Expensify/packages/maven/com.expensify.${PACKAGE}.react-android/versions" --paginate --jq '.[].name')" -VERSIONS_FROM_MAVEN_REPOSITORY=$(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" \ - "$MAVEN_METADATA_URL" | \ - grep -o "${VERSION}-[0-9]\+" | \ - grep -o "${VERSION}-[0-9]" | \ - sort -t'-' -k2 -n) +# Filter only versions matching the base React Native version +PACKAGE_VERSIONS="$(echo "$PACKAGE_VERSIONS" | grep "$VERSION")" -LATEST_PATCHED_VERSION=$(echo "$VERSIONS_FROM_MAVEN_REPOSITORY" | tail -n1) +# Grab the highest patch version from there +LATEST_PATCHED_VERSION="$(echo "$PACKAGE_VERSIONS" | sort | tail -n1)" -if [ -n "$LATEST_PATCHED_VERSION" ]; then +if [[ -n "$LATEST_PATCHED_VERSION" ]]; then PATCH_ITERATION=${LATEST_PATCHED_VERSION##*-} INCREMENTED_PATCH_ITERATION=$((PATCH_ITERATION + 1)) echo "${VERSION}-${INCREMENTED_PATCH_ITERATION}" From c93d49cbd3a8f9a941db61f0fc1c0a18a15f8ca3 Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Wed, 23 Apr 2025 15:27:40 +0200 Subject: [PATCH 20/22] Remove patches hash from publish.gradle --- ...act-native+0.77.1+024+publish-gradle.patch | 66 ------------------- 1 file changed, 66 deletions(-) delete mode 100644 patches/react-native+0.77.1+024+publish-gradle.patch diff --git a/patches/react-native+0.77.1+024+publish-gradle.patch b/patches/react-native+0.77.1+024+publish-gradle.patch deleted file mode 100644 index 415b83af56e5..000000000000 --- a/patches/react-native+0.77.1+024+publish-gradle.patch +++ /dev/null @@ -1,66 +0,0 @@ -diff --git a/node_modules/react-native/ReactAndroid/publish.gradle b/node_modules/react-native/ReactAndroid/publish.gradle -index 32287a7..68c9284 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,15 @@ publishing { - description = "A framework for building native apps with React" - url = "https://github.com/facebook/react-native" - -+ properties = [ -+ "patchesHash": System.getenv("PATCHES_HASH"), -+ "commitHash": System.getenv("COMMIT_HASH"), -+ ] -+ - developers { - developer { -- id = "facebook" -- name = "Facebook" -+ id = "expensify" -+ name = "Expensify" - } - } - -@@ -65,8 +76,11 @@ publishing { - - repositories { - maven { -- name = "mavenTempLocal" -- url = mavenTempLocalUrl -+ url = mavenURL -+ credentials { -+ username = System.getenv("GH_PUBLISH_ACTOR") -+ password = System.getenv("GH_PUBLISH_TOKEN") -+ } - } - } - From e502011e4d67c204aa12701d951cc70f9371bb0a Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Wed, 23 Apr 2025 15:30:22 +0200 Subject: [PATCH 21/22] Add new patch --- patches/react-native+0.77.1+025.patch | 73 +++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 patches/react-native+0.77.1+025.patch diff --git a/patches/react-native+0.77.1+025.patch b/patches/react-native+0.77.1+025.patch new file mode 100644 index 000000000000..60c7e59ce0df --- /dev/null +++ b/patches/react-native+0.77.1+025.patch @@ -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") ++ } + } + } + From f95710a12602acff94e3716fc00168aa9905fcbd Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Thu, 24 Apr 2025 10:16:25 +0200 Subject: [PATCH 22/22] Add missing double and single quotes --- .github/workflows/publishReactNativeAndroidArtifacts.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publishReactNativeAndroidArtifacts.yml b/.github/workflows/publishReactNativeAndroidArtifacts.yml index 8b91bc5a1754..30c2f05ecd61 100644 --- a/.github/workflows/publishReactNativeAndroidArtifacts.yml +++ b/.github/workflows/publishReactNativeAndroidArtifacts.yml @@ -31,7 +31,7 @@ jobs: - name: Get previous Mobile-Expensify commit hash if: ${{ matrix.is_hybrid == 'true' }} id: getOldMobileExpensifyHash - run: echo "HASH=$(git rev-parse :Mobile-Expensify) >> "$GITHUB_OUTPUT" + run: echo "HASH=$(git rev-parse :Mobile-Expensify)" >> "$GITHUB_OUTPUT" - name: Get previous react-native version id: getOldVersion @@ -87,7 +87,7 @@ jobs: - 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 + 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" @@ -116,7 +116,7 @@ jobs: - 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 + run: echo "NEW_PATCHED_VERSION=$(./.github/scripts/getNewPatchedRNVersion.sh)" >> "$GITHUB_OUTPUT" env: GITHUB_TOKEN: ${{ github.token }} IS_HYBRID_BUILD: ${{ matrix.is_hybrid }}