Skip to content

Instantly share code, notes, and snippets.

@himesh-cm
Last active December 11, 2023 10:27
Show Gist options
  • Save himesh-cm/a99890ce89528b0221d80df84dfe6df4 to your computer and use it in GitHub Desktop.
Save himesh-cm/a99890ce89528b0221d80df84dfe6df4 to your computer and use it in GitHub Desktop.
Codemagic yaml file with Emerge Tools Integration
workflows:
ios-native-workflow:
name: iOS Native APNS
max_build_duration: 120
instance_type: mac_mini_m1
integrations:
app_store_connect: Himesh APNS
environment:
groups:
- emerge_tools
ios_signing:
distribution_type: app_store
bundle_identifier: io.nevercode.iOSNativeAPNS
vars:
BUNDLE_ID: "io.nevercode.iOSNativeAPNS"
XCODE_WORKSPACE: "iOSNativeAPNS.xcworkspace" # <-- Put the name of your Xcode workspace here
XCODE_SCHEME: "iOSNativeAPNS" # <-- Put the name of your Xcode scheme here
APP_ID: "6444186776"
xcode: 14.3
cocoapods: default
scripts:
- name: Install CocoaPods dependencies
script: |
pod install
- name: Set up provisioning profiles settings on Xcode project
script: xcode-project use-profiles
- name: Increment build number
script: |
#!/bin/sh
cd $CM_BUILD_DIR
LATEST_BUILD_NUMBER=$(app-store-connect get-latest-testflight-build-number "$APP_ID")
agvtool new-version -all $(($LATEST_BUILD_NUMBER + 1))
- name: Build IPA
script: |
xcode-project build-ipa \
--workspace "$CM_BUILD_DIR/$XCODE_WORKSPACE" \
--scheme "$XCODE_SCHEME" \
- name: Create Zip file
working_directory: build/ios/xcarchive/
script: |
find . -type d -name "*.xcarchive" -print | while read -r dir; do
base_name=$(basename "$dir")
zip -r "iOSNative.zip" "$base_name"
done
- name: Emerge Tools Analysis
working_directory: build/ios/xcarchive/
script: |
set -e
PATH_TO_BUILD_ARTIFACT=/Users/builder/clone/build/ios/xcarchive/iOSNative.zip
BASE_SHA=$(git rev-parse HEAD~1)
json_body=$(jq -n \
--arg filename "iOSNative.zip" \
--arg branch "$CM_BRANCH" \
--arg repoName "$CM_REPO_SLUG" \
--arg buildType "main" \
--arg prNumber "$CM_PULL_REQUEST_NUMBER" \
--arg sha "$CM_COMMIT" \
--arg baseSha "$BASE_SHA" \
'{
filename: $filename,
branch: $branch,
repoName: $repoName,
buildType: $buildType,
prNumber: $prNumber,
sha: $sha,
baseSha: $baseSha
}')
upload_response=$(curl \
--url "https://api.emergetools.com/upload" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header "X-API-Token: $EMERGE_API_KEY" \
--data "$json_body")
# Pull the uploadURL field from the response using jq - main build available
upload_url=$(echo "$upload_response" | jq -r .uploadURL)
curl -v -H 'Content-Type: application/zip' -T "$PATH_TO_BUILD_ARTIFACT" "$upload_url"
artifacts:
- /Users/builder/clone/build/ios/xcarchive/iOSNative.zip
- build/ios/ipa/*.ipa
- $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.app
- $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.dSYM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment