From ffa70f594fc5fc0e452e05c38b0631f4781d8450 Mon Sep 17 00:00:00 2001 From: Ashutosh Date: Thu, 11 Jul 2024 01:04:48 +0530 Subject: [PATCH] workflow: updated actions and commands to their latest --- .github/workflows/build-android.yml | 38 +++++++++++++---- .github/workflows/build-ios-simulator.yml | 51 +++++++++++++++++------ 2 files changed, 68 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index bafe753..54ddbd8 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -19,26 +19,46 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + + # Optional security step: Validate whether gradle-wrapper.jar is valid or malicious + - name: Validate Gradle Wrapper + uses: gradle/actions/wrapper-validation@v3 + + # 'corepack enable' is needed for now till it's experimental, may remove the command once it becomes stable in later node releases + - name: Enable Corepack + run: corepack enable # Setup Web environment to install packages. - name: Setup Web environment - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: '16' + node-version: '20' cache: 'yarn' # Setup Java environment in order to build the Android app. - name: Setup Java environment - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: '11' - cache: 'gradle' - # Here '--frozen-lockfile' will only use commited 'yarn.lock', and will throw error if some update is needed + # Setup gradle using official gradle action + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + add-job-summary: 'on-failure' + + - name: Restore node_modules from cache + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }} + restore-keys: ${{ runner.os }}-node-modules- + + # Here '--immutable' will only use commited 'yarn.lock', and will throw error if some update is needed - name: Install node_modules - run: yarn install --frozen-lockfile + run: yarn install --immutable # In some cases, Gradle is not executable by default, so we do this before the build process - name: Make gradlew executable @@ -50,7 +70,7 @@ jobs: run: ./gradlew assembleRelease --no-daemon - name: Save apk file as artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: rn-animation-samples - path: android/app/build/outputs/apk/release/app-release.apk \ No newline at end of file + path: android/app/build/outputs/apk/release/app-release.apk diff --git a/.github/workflows/build-ios-simulator.yml b/.github/workflows/build-ios-simulator.yml index 87b9915..617756b 100644 --- a/.github/workflows/build-ios-simulator.yml +++ b/.github/workflows/build-ios-simulator.yml @@ -17,26 +17,39 @@ jobs: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + + # 'corepack enable' is needed for now till it's experimental, may remove the command once it becomes stable in later node releases + - name: Enable Corepack + run: corepack enable # Setup Web environment to install packages. - name: Setup Web environment - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: '16' + node-version: '20' cache: 'yarn' - # Here '--frozen-lockfile' will only use commited 'yarn.lock', and will throw error if some update is needed - - name: Install node_modules - run: yarn install --frozen-lockfile + - uses: hendrikmuhs/ccache-action@v1.2 + name: Xcode Compile Cache + with: + key: ${{ runner.os }}-ccache # makes a unique key w/related restore key internally + create-symlink: true + max-size: 1500M + + - name: Restore node_modules from cache + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }} + restore-keys: ${{ runner.os }}-node-modules- - # improve iOS build compilation time - - name: Restore buildcache - uses: mikehardy/buildcache-action@v2 - continue-on-error: true + # Here '--immutable' will only use commited 'yarn.lock', and will throw error if some update is needed + - name: Install node_modules + run: yarn install --immutable - name: Restore Pods cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ios/Pods @@ -45,6 +58,13 @@ jobs: key: ${{ runner.os }}-pods-${{ hashFiles('ios/Podfile.lock') }} restore-keys: ${{ runner.os }}-pods- + - name: Restore build artifacts from cache + uses: actions/cache@v4 + with: + path: ios/build + key: ${{ runner.os }}-ios-derived-data-${{ hashFiles('ios/Podfile.lock') }} + restore-keys: ${{ runner.os }}-ios-derived-data- + - name: Install Pod files run: npx pod-install ios @@ -54,6 +74,12 @@ jobs: - name: Run simulator build command working-directory: ios run: | + export CCACHE_SLOPPINESS=clang_index_store,file_stat_matches,include_file_ctime,include_file_mtime,ivfsoverlay,pch_defines,modules,system_headers,time_macros + export CCACHE_FILECLONE=true + export CCACHE_DEPEND=true + export CCACHE_INODECACHE=true + export CCACHE_LIMIT_MULTIPLE=0.95 + ccache -s set -o pipefail xcodebuild \ CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ \ @@ -62,6 +88,7 @@ jobs: -sdk iphonesimulator \ -configuration Release \ -derivedDataPath build | xcpretty + ccache -s - name: Store build .app file as zip working-directory: ios @@ -71,7 +98,7 @@ jobs: zip -r -y -o output/RN_Animations.zip RN_Animations.app - name: Save build file as artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: rn_animation_samples_ios path: ios/build/Build/Products/Release-iphonesimulator/output