Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 23 additions & 32 deletions .github/workflows/publishReactNativeAndroidArtifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ jobs:
ref: ${{ github.event.before }}
token: ${{ secrets.OS_BOTIFY_TOKEN }}

- 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 }}
id: getOldMobileExpensifyHash
run: echo "HASH=$(git rev-parse :Mobile-Expensify)" >> "$GITHUB_OUTPUT"
- name: Get previous patches hash
id: getOldPatchesHash
run: |
if [[ "${{ matrix.is_hybrid }}" == "true" ]]; then
echo "HASH=$(./scripts/compute-patches-hash.sh patches Mobile-Expensify/patches)" >> "$GITHUB_OUTPUT"
else
echo "HASH=$(./scripts/compute-patches-hash.sh patches)" >> "$GITHUB_OUTPUT"
fi

- name: Get previous react-native version

id: getOldVersion
run: echo "VERSION=$(jq -r '.dependencies["react-native"]' package.json)" >> "$GITHUB_OUTPUT"

Expand All @@ -44,14 +45,14 @@ jobs:
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 }}
id: getNewMobileExpensifyHash
run: echo "HASH=$(git rev-parse :Mobile-Expensify)" >> "$GITHUB_OUTPUT"
- name: Get new patches hash
id: getNewPatchesHash
run: |
if [[ "${{ matrix.is_hybrid }}" == "true" ]]; then
echo "HASH=$(./scripts/compute-patches-hash.sh patches Mobile-Expensify/patches)" >> "$GITHUB_OUTPUT"
else
echo "HASH=$(./scripts/compute-patches-hash.sh patches)" >> "$GITHUB_OUTPUT"
fi

- name: Get new react-native version
id: getNewVersion
Expand All @@ -69,22 +70,12 @@ jobs:
- 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 (Standalone NewDot)"
echo "DID_PATCHES_CHANGE=true" >> "$GITHUB_OUTPUT"
exit 0
readonly DID_PATCHES_CHANGE=${{ steps.getOldPatchesHash.outputs.HASH != steps.getNewPatchesHash.outputs.HASH && 'true' || 'false' }}
echo "DID_PATCHES_CHANGE=$DID_PATCHES_CHANGE" >> "$GITHUB_OUTPUT"
if [[ "$DID_PATCHES_CHANGE" == 'true' ]]; then
echo "::notice::Detected changes in patches (${{ steps.getOldPatchesHash.outputs.HASH }} -> ${{ steps.getNewPatchesHash.outputs.HASH }})"
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 (HybridApp)"
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: |
Expand Down Expand Up @@ -128,7 +119,7 @@ jobs:
run: |
echo "Starting artifacts build for ${{ matrix.is_hybrid && '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
Expand All @@ -137,7 +128,7 @@ jobs:
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: ${{ steps.getNewPatchesHash.outputs.HASH }}

- name: Announce failed workflow in Slack
if: ${{ failure() }}
Expand Down
2 changes: 1 addition & 1 deletion patches/react-native+0.77.1+025.patch
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ index 32287a7..5607be3 100644
url = "https://github.com/facebook/react-native"

+ properties = [
+ "commitHash": System.getenv("COMMIT_HASH"),
+ "patchesHash": System.getenv("PATCHES_HASH"),
+ ]
+
developers {
Expand Down
16 changes: 16 additions & 0 deletions scripts/compute-patches-hash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
readonly SCRIPT_DIR
source "$SCRIPT_DIR/shellUtils.sh"

if [ $# -eq 0 ]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is from our bash style guide (currently not open source)

Suggested change
if [ $# -eq 0 ]; then
if [[ $# -eq 0 ]]; then

error "Please provide at least one path as an argument"
exit 1
fi

PATCH_DIRS=("$@")
readonly PATCH_DIRS

# Find all patches, compute their hash, put filename before hash, sort, compute hash of hashes
find "${PATCH_DIRS[@]}" -type f \( -name "react-native+*.patch" -o -name "@react-native+*.patch" \) -exec sha256sum {} \; | awk '{split($2, pathParts, "/"); print pathParts[length(pathParts)], $1 }' | sort | sha256sum | awk '{print $1}'
Loading