Skip to content

Performance: optimizations #413

Performance: optimizations

Performance: optimizations #413

Workflow file for this run

name: iOS Build
on:
pull_request:
types: [ready_for_review, synchronize, labeled]
push:
branches:
- development
concurrency:
group: ios-build
cancel-in-progress: true
jobs:
ios-build:
name: iOS Build
if: >
(github.event_name == 'pull_request') ||
(github.event_name == 'push' && github.ref == 'refs/heads/development')
runs-on: macos-latest
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '16.4'
- name: Show host machine information
run: |
uname -a
xcodebuild -showsdks
- name: Checkout PR head
uses: actions/checkout@v4
with:
repository: >
${{ github.event_name == 'push' && github.ref == 'refs/heads/development' && github.repository ||
github.event.pull_request.head.repo.full_name }}
ref: >
${{ github.event_name == 'push' && github.ref == 'refs/heads/development' && 'development' ||
github.event.pull_request.head.sha }}
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.0.0"
- name: Setup Cocoapods
uses: maxim-lobanov/setup-cocoapods@v1
with:
version: 1.15.2
- name: Create Google Services PLIST File
env:
GOOGLE_PLIST: ${{ secrets.GOOGLE_PLIST }}
run: |
echo "$GOOGLE_PLIST" | base64 --decode -o ./ios/GoogleService-Info.plist
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.CERTIFICATES_P12 }}
P12_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.PROVISIONING_PROFILE }}
EXTEN_PROVISION_PROFILE_BASE64: ${{ secrets.EXTEN_PROVISIONING_PROFILE }}
NOTIFI_PROVISION_PROFILE_BASE64: ${{ secrets.NOTIFI_PROVISIONING_PROFILE }}
KEYCHAIN_PASSWORD: ${{ secrets.APPLE_APP_PASS }}
EXPORT_OPTIONS_PLIST: ${{ secrets.EXPORT_OPTIONS_PLIST }}
run: |
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
EX_PATH=$RUNNER_TEMP/build_ex.mobileprovision
NOT_PATH=$RUNNER_TEMP/build_not.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH
echo -n "$EXTEN_PROVISION_PROFILE_BASE64" | base64 --decode -o $EX_PATH
echo -n "$NOTIFI_PROVISION_PROFILE_BASE64" | base64 --decode -o $NOT_PATH
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
cp $EX_PATH ~/Library/MobileDevice/Provisioning\ Profiles
cp $NOT_PATH ~/Library/MobileDevice/Provisioning\ Profiles
for PROVISION in `ls $RUNNER_TEMP/*.mobileprovision`
do
UUID=`/usr/libexec/PlistBuddy -c 'Print :UUID' /dev/stdin <<< $(security cms -D -i $PROVISION)`
cp $PROVISION ~/Library/MobileDevice/Provisioning\ Profiles/$UUID.mobileprovision
done
- name: Create .env file
run: |
echo "ACTIVITY_WEBSOCKET_URL=${{ secrets.ACTIVITY_WEBSOCKET_URL }}" >> .env
echo "SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}" >> .env
echo "DEFAULT_PIN=${{ secrets.DEFAULT_PIN }}" >> .env
echo "ECENCY_BACKEND_API=${{ secrets.ECENCY_BACKEND_API }}" >> .env
echo "NEW_IMAGE_API=${{ secrets.NEW_IMAGE_API }}" >> .env
echo "PIN_KEY=${{ secrets.PIN_KEY }}" >> .env
echo "SERVER_LIST_API=${{ secrets.SERVER_LIST_API }}" >> .env
echo "USER_AGENT=${{ secrets.USER_AGENT }}" >> .env
echo "PLAUSIBLE_API_KEY=${{ secrets.PLAUSIBLE_API_KEY }}" >> .env
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install npm dependency
run: yarn install
- name: Install Cocoapod dependencies
run: |
cd ios
pod install
- name: Set version code
run: |
TIMESTAMP=$(date +%s)
echo "Setting version code to: $TIMESTAMP"
sed -i '' "s/CURRENT_PROJECT_VERSION = [0-9]*/CURRENT_PROJECT_VERSION = $TIMESTAMP/" ios/Ecency.xcodeproj/project.pbxproj
- name: Build iOS JS Bundle
run: |
yarn run bundle:ios
- name: Copy JS bundle and sourcemap to temp directory
run: |
mkdir -p $RUNNER_TEMP/js
cp ios/main.jsbundle $RUNNER_TEMP/js/main.jsbundle
cp ios/main.jsbundle.map $RUNNER_TEMP/js/main.jsbundle.map
- name: Upload source maps to Sentry (iOS)
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
run: |
VERSION=$(node -p "require('./package.json').version")
DIST=$(date +%s)
npx sentry-cli releases new "$VERSION-$DIST" --org ecency --project ecency-mobile
npx sentry-cli releases files "$VERSION-$DIST" upload-sourcemaps \
--dist "$DIST" \
--org ecency --project ecency-mobile \
--rewrite \
--strip-common-prefix \
$RUNNER_TEMP/js/main.jsbundle $RUNNER_TEMP/js/main.jsbundle.map
npx sentry-cli releases finalize "$VERSION-$DIST" --org ecency --project ecency-mobile
- name: Build archive
run: |
export SENTRY_DISABLE_AUTO_UPLOAD=true
cd ios
xcodebuild -workspace Ecency.xcworkspace \
-scheme "Ecency" \
-sdk iphoneos \
-configuration Release \
-destination generic/platform=iOS \
-archivePath $RUNNER_TEMP/Ecency.xcarchive \
clean archive
- name: Export IPA
env:
EXPORT_OPTIONS_PLIST: ${{ secrets.EXPORT_OPTIONS_PLIST }}
run: |
EXPORT_OPTS_PATH=$RUNNER_TEMP/ExportOptions.plist
echo -n "$EXPORT_OPTIONS_PLIST" | base64 --decode -o $EXPORT_OPTS_PATH
xcodebuild -exportArchive \
-archivePath $RUNNER_TEMP/Ecency.xcarchive \
-exportOptionsPlist $EXPORT_OPTS_PATH \
-exportPath $RUNNER_TEMP/build
- name: List build contents
run: |
ls -la $RUNNER_TEMP/build
- name: Upload App
uses: actions/upload-artifact@v4
with:
name: Ecency-iOS
path: ${{ runner.temp }}/build/Ecency.ipa
retention-days: 90
ios-deploy:
name: Deploy iOS Build
needs: ios-build
# Only deploy if the trigger is a pull_request with 'deploy-pr-build' label or a push to 'development'
if: >
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy-pr-build')) ||
(github.event_name == 'push' && github.ref == 'refs/heads/development')
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Get iOS Build from artifacts
uses: actions/download-artifact@v4
- name: Upload to AppStoreConnect
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_PASS: ${{ secrets.APPLE_APP_PASS }}
run: xcrun altool --upload-app -f "Ecency-iOS/Ecency.ipa" -t ios -u "$APPLE_ID" -p "$APPLE_APP_PASS"