Skip to content

Update ios.yml

Update ios.yml #737

Workflow file for this run

name: iOS Build
on:
push:
branches:
- Development
workflow_dispatch:
env:
ARTIFACT_PATH_STAGING: ${{ 'ParentBuddyAppDev/' }}
CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
KEY_PWD: ${{ secrets.APPLE_KEY_PWD }}
DISTRIBUTION_CERTIFICATE: ${{ secrets.APPLE_APP_DISTRIBUTION_CERTIFICATE }}
DISTRIBUTION_PROFILE_PROD: ${{ secrets.APPLE_DISTRIBUTION_PROFILE }}
DISTRIBUTION_PROFILE_BUILD: ${{ secrets.APPLE_AD_HOC_PROFILE }}
TEAM_ID: ${{ secrets.TEAM_ID }}
jobs:
build:
runs-on: macOS-latest
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-node@master
with:
node-version: '21.2.0'
- name: Install dependencies
run: npm install
- name: 'Create env file'
run: |
touch .env
echo apiUrlDevelop=${{ secrets.APIURLDEVELOP }} >> .env
echo facebookAppDisplayName=${{ secrets.FACEBOOKAPPDISPLAYNAME }} >> .env
echo facebookAppId=${{ secrets.FACEBOOKAPPID }} >> .env
echo facebookClientToken=${{ secrets.FACEBOOKCLIENTTOKEN }} >> .env
echo projectNumber=${{ secrets.PROJECTNUMBER }} >> .env
echo clientIdKey=${{ secrets.CLIENTIDKEY }} >> .env
- name: Putting data google service Dev file
env:
DATA: ${{ secrets.GOOGLE_SERVICES_PLIST_DEV }}
run: |
touch /Users/runner/work/parenting-app-bebbo-mobile/parenting-app-bebbo-mobile/ios/GoogleServices/Development/GoogleService-Info.plist
echo -n $DATA | base64 -d > /Users/runner/work/parenting-app-bebbo-mobile/parenting-app-bebbo-mobile/ios/GoogleServices/Development/GoogleService-Info.plist
- name: Install CocoaPods
run: |
sudo gem install cocoapods
- name: Set environment variable for modular headers
run: echo "USE_MODULAR_HEADERS=true" >> $GITHUB_ENV
- name: Modify Podfile for Modular Headers
run: |
cd ios # Update this path if necessary
sed -i '' '1s/^/if ENV["USE_MODULAR_HEADERS"] == "true"\nuse_modular_headers!\nend\n\n/' Podfile
cat Podfile
- name: Install pod dependencies
run: |
cd ios && rm -rf Pods Podfile.lock && pod install --repo-update
- name: Authenticate with Apple Developer account
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APP_SPECIFIC_PASSWORD: ${{ secrets.APP_SPECIFIC_PASSWORD }}
run: |
echo "machine apple.com login $APPLE_ID password $APP_SPECIFIC_PASSWORD" > ~/.netrc
security add-internet-password -a $APPLE_ID -s idmsa.apple.com -w $APP_SPECIFIC_PASSWORD -T /usr/bin/security
- name: Create and unlock keychain
run: |
security create-keychain -p $KEY_PWD build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p $KEY_PWD build.keychain
security set-keychain-settings -t 3600 -l ~/Library/Keychains/build.keychain
security list-keychains -d user
security show-keychain-info build.keychain || echo "Keychain info not available"
- name: Install Certificate
run: |
# Decode and install certificate
echo -n "$DISTRIBUTION_CERTIFICATE" | base64 -Dd -o certificate.p12
security import certificate.p12 -k ~/Library/Keychains/build.keychain -P "$CERTIFICATE_PASSWORD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple: -s -k $CERTIFICATE_PASSWORD ~/Library/Keychains/build.keychain
- name: Install Provisioning Export
run: |
# Install provisioning profile
echo -n "$DISTRIBUTION_PROFILE_PROD" | base64 -Dd -o $RUNNER_TEMP/provisioning_profile.mobileprovision
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $RUNNER_TEMP/provisioning_profile.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles
UUID=$(security cms -D -i $RUNNER_TEMP/provisioning_profile.mobileprovision | plutil -extract UUID raw -)
mv $RUNNER_TEMP/provisioning_profile.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/$UUID.mobileprovision
# Confirm installation
if [ -f ~/Library/MobileDevice/Provisioning\ Profiles/$UUID.mobileprovision ]; then
echo "Provisioning profile installed successfully."
else
echo "Failed to install provisioning profile."
exit 1
fi
- name: Install Provisioning build
run: |
# Install provisioning profile
echo -n "$DISTRIBUTION_PROFILE_BUILD" | base64 -Dd -o $RUNNER_TEMP/provisioning_profile_build.mobileprovision
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $RUNNER_TEMP/provisioning_profile_build.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles
UUID1=$(security cms -D -i $RUNNER_TEMP/provisioning_profile_build.mobileprovision | plutil -extract UUID raw -)
mv $RUNNER_TEMP/provisioning_profile_build.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/$UUID1.mobileprovision
# Confirm installation
if [ -f ~/Library/MobileDevice/Provisioning\ Profiles/$UUID1.mobileprovision ]; then
echo "Provisioning profile build installed successfully."
else
echo "Failed to install provisioning profile for build."
exit 1
fi
- name: Prepare exportOptions.plist
run: |
cd ios &&
cat > exportOptions.plist <<EOL
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>compileBitcode</key>
<false/>
<key>destination</key>
<string>export</string>
<key>method</key>
<string>enterprise</string>
<key>signingStyle</key>
<string>automatic</string>
<key>stripSwiftSymbols</key>
<true/>
<key>teamID</key>
<string>$TEAM_ID</string>
<key>thinning</key>
<string>&lt;none&gt;</string>
</dict>
</plist>
EOL
- name: Prepare exportOptions.plist
run: |
cd ios
if [ -f exportOptions.plist ]; then
echo "exportOptions.plist created successfully."
cat exportOptions.plist # Optionally print the contents for verification
else
echo "Failed to create exportOptions.plist."
exit 1
fi
- name: Select Xcode
run: sudo xcode-select -switch /Applications/Xcode_15.1.app
- name: Xcode Version
run: /usr/bin/xcodebuild -version
- name: Create build folder
run: |
cd ./ios && mkdir -p build && mkdir -p staging
- name: Build Archive
run: |
cd ios && xcodebuild archive -workspace "ParentBuddyApp.xcworkspace" -scheme "ParentBuddyAppDev" -configuration "Release" -sdk iphoneos -UseModernBuildSystem=0 IPHONEOS_DEPLOYMENT_TARGET=12.0 -archivePath "./build/ParentBuddyApp.xcarchive" -allowProvisioningUpdates -quiet -hideShellScriptEnvironment
- name: Export Archive
run: |
cd ios && xcodebuild -verbose -exportArchive -allowProvisioningUpdates \
-archivePath "./build/ParentBuddyApp.xcarchive" \
-exportPath "ParentBuddyAppDev/" \
-exportOptionsPlist "exportOptions.plist"
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: Bebbo.ipa
path: "ios/ParentBuddyAppDev/"
- name: Clean up keychain and provisioning profile
if: ${{ always() }}
run: |
security delete-keychain ~/Library/Keychains/build.keychain
security delete-keychain ~/Library/Keychains/login.keychain-db
rm -f /Library/MobileDevice/Provisioning\ Profiles/*