workflow (rn): added ccache-action for faster builds #30
This file contains 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
name: Create an iOS Simulator build | |
on: | |
push: | |
paths: | |
- '*' | |
- '.github/workflows/build-ios-simulator.yml' | |
- 'ios/**' | |
- '!**/*.md' | |
- '!android/**' | |
branches: | |
- react-native | |
jobs: | |
build-ios-simulator: | |
name: Create an iOS Simulator build | |
runs-on: macos-latest | |
steps: | |
- 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@v4 | |
with: | |
node-version: '20' | |
cache: 'yarn' | |
- uses: hendrikmuhs/[email protected] | |
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- | |
# 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 | |
# # improve iOS build compilation time | |
# - name: Restore buildcache | |
# uses: mikehardy/buildcache-action@v2 | |
# continue-on-error: true | |
- name: Restore Pods cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
ios/Pods | |
~/Library/Caches/CocoaPods | |
~/.cocoapods | |
key: ${{ runner.os }}-pods-${{ hashFiles('ios/Podfile.lock') }} | |
restore-keys: ${{ runner.os }}-pods- | |
- name: Install Pod files | |
run: npx pod-install ios | |
# - name: Restore build artifacts from cache | |
# uses: actions/cache@v4 | |
# with: | |
# path: ~/Library/Developer/Xcode/DerivedData | |
# key: ${{ runner.os }}-ios-derived-data-${{ hashFiles('ios/Podfile.lock') }} | |
# restore-keys: | | |
# ${{ runner.os }}-ios-derived-data- | |
# - name: Run app on iOS | |
# run: npx react-native run-ios --simulator 'iPhone 14 Pro Max' --configuration Release | |
# - name: Store build .app file as zip | |
# working-directory: ios | |
# run: | | |
# cd ~/Library/Developer/Xcode/DerivedData/rn_test_github_actions-*/Build/Products/Release-iphonesimulator | |
# mkdir -p output | |
# zip -r -y -o output/rn_test_github_actions.zip rn_test_github_actions.app | |
# - name: Save build file as artifact | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: rn-ios-simulator-build | |
# path: ~/Library/Developer/Xcode/DerivedData/rn_test_github_actions-*/Build/Products/Release-iphonesimulator/output | |
- name: Restore build artifacts from cache | |
uses: actions/cache@v4 | |
with: | |
path: build | |
key: ${{ runner.os }}-ios-derived-data-${{ hashFiles('ios/Podfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-ios-derived-data- | |
- name: Install xcpretty | |
run: gem install xcpretty | |
- 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++ \ | |
-scheme rn_test_github_actions \ | |
-workspace rn_test_github_actions.xcworkspace \ | |
-sdk iphonesimulator \ | |
-configuration Release \ | |
-derivedDataPath build | xcpretty | |
ccache -s | |
- name: Store build .app file as zip | |
working-directory: ios | |
run: | | |
cd build/Build/Products/Release-iphonesimulator | |
mkdir -p output | |
zip -r -y -o output/rn_test_github_actions.zip rn_test_github_actions.app | |
- name: Save build file as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: rn-ios-simulator-build | |
path: ios/build/Build/Products/Release-iphonesimulator/output |