Update gpt-driver-tests.yml #24
This file contains hidden or 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: iOS Release Build and GPTDriver Tests | ||
Check failure on line 1 in .github/workflows/gpt-driver-tests.yml
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
jobs: | ||
BuildAndTestAppOnGPTDriver: # Job name, as chosen | ||
runs-on: macos-latest # macOS runner is required for iOS builds | ||
steps: | ||
# --- Step 1: Extract version from branch name --- | ||
- name: Extract version from branch name | ||
id: extract_version_step | ||
run: | | ||
BRANCH_NAME="${{ github.ref }}" | ||
# Remove 'refs/heads/' prefix (e.g., refs/heads/Release-0.0.0 -> Release-0.0.0) | ||
BRANCH_NAME_WITHOUT_PREFIX="${BRANCH_NAME#refs/heads/}" | ||
# Extract version after "Release-" (e.g., Release-0.0.0 -> 0.0.0) | ||
VERSION=$(echo "$BRANCH_NAME_WITHOUT_PREFIX" | sed -n 's/^Release-\([0-9]*\.[0-9]*\.[0-9]*\)$/\1/p') | ||
if [ -z "$VERSION" ]; then | ||
echo "Error: Could not extract version from branch name '$BRANCH_NAME_WITHOUT_PREFIX'. Expected format: Release-X.Y.Z" | ||
exit 1 | ||
fi | ||
echo "Extracted versionName: $VERSION" | ||
echo "VERSION_STRING=$VERSION" >> $GITHUB_ENV | ||
# Convert semantic version to an integer for CFBundleVersion (versionCode equivalent) | ||
# Example: 1.2.3 -> 102003 (assuming max 2 digits for minor/patch) | ||
# This should be adjusted based on the maximum expected values for major/minor/patch | ||
MAJOR=$(echo "$VERSION" | cut -d. -f1) | ||
MINOR=$(echo "$VERSION" | cut -d. -f2) | ||
PATCH=$(echo "$VERSION" | cut -d. -f3) | ||
# Calculate versionCode (CFBundleVersion) - ensure this fits in a 32-bit integer | ||
# Standard Android-like conversion: Major * 10000 + Minor * 100 + Patch | ||
# This provides sufficient uniqueness for most common versioning schemes. | ||
VERSION_CODE_INT=$(( MAJOR * 10000 + MINOR * 100 + PATCH )) | ||
echo "Calculated versionCode: $VERSION_CODE_INT" | ||
echo "VERSION_CODE_INT=$VERSION_CODE_INT" >> $GITHUB_ENV | ||
# --- Step 2: Checkout the iOS Branch SDK repository --- | ||
- name: Checkout BranchMetrics/ios-branch-deep-linking-attribution (SDK) | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: BranchMetrics/ios-branch-deep-linking-attribution | ||
ref: ${{ github.ref }} # Use the same branch that triggered the workflow | ||
path: ./branch-ios-sdk-repo # Checkout into a subdirectory | ||
# --- Step 3: Build the iOS Branch SDK Framework --- | ||
- name: Build Branch SDK Framework | ||
run: | | ||
# Build for simulator. Adjust scheme if necessary. | ||
# The output framework will be in build/Debug-iphonesimulator/BranchSDK.framework | ||
xcodebuild -scheme xcframework \ | ||
BUILD_DIR="${{ github.workspace }}/branch-ios-sdk-repo/build" | ||
working-directory: ./branch-ios-sdk-repo # Run xcodebuild from the SDK's checkout directory | ||
# --- Step 4: Checkout the iOS Branch Link Simulator App repository --- | ||
- name: Checkout BranchMetrics/BranchLinkSimulator (App) | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: BranchMetrics/BranchLinkSimulator | ||
ref: gptdriver/linkingTests # Checkout the specific app branch | ||
path: ./ios-app-repo # Checkout into another subdirectory | ||
# --- Step 5: Copy the generated SDK Framework to the App's project --- | ||
- name: Copy generated SDK Framework to App's libs directory | ||
run: | | ||
# Create a 'Frameworks' directory within the app repo for the local SDK | ||
mkdir -p ./ios-app-repo/Frameworks | ||
# Copy the built framework | ||
cp -R ./branch-ios-sdk-repo/build/BranchSDK.xcframework ./ios-app-repo/Frameworks/ | ||
working-directory: ${{ github.workspace }} # Run from the root of the GITHUB_WORKSPACE | ||
- name: Install the Apple certificate and provisioning profile | ||
env: | ||
BUILD_CERTIFICATE_BASE64: ${{ secrets.BS_BUILD_CERTIFICATE }} | ||
P12_PASSWORD: ${{ secrets.BS_P12_PASSWORD }} | ||
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BS_BUILD_PROVISION_PROFILE_BASE64_PART_AA }} | ||
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} | ||
run: | | ||
# create variables | ||
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 | ||
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db | ||
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision | ||
# import certificate | ||
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH | ||
# Create Provisioning Profiles | ||
echo "${{ secrets.BS_BUILD_PROVISION_PROFILE_BASE64_PART_AA }}" >> part_aa | ||
echo "${{ secrets.BS_BUILD_PROVISION_PROFILE_BASE64_PART_AB }}" >> part_aa | ||
echo "${{ secrets.BS_BUILD_PROVISION_PROFILE_BASE64_PART_AC }}" >> part_aa | ||
base64 -D -i part_aa > $PP_PATH | ||
# create temporary keychain | ||
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | ||
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH | ||
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | ||
# import certificate to keychain | ||
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH | ||
security list-keychain -d user -s $KEYCHAIN_PATH | ||
# apply provisioning profile | ||
mkdir -p ~/Library/Developer/Xcode/UserData/Provisioning\ Profiles | ||
cp $PP_PATH ~/Library/Developer/Xcode/UserData/Provisioning\ Profiles/ | ||
# --- Step 6: Build the iOS Branch Link Simulator App using the local SDK Framework --- | ||
- name: Build iOS App with local SDK | ||
run: | | ||
# Build the app. Adjust project/workspace, scheme, and destination if necessary. | ||
# We're passing MARKETING_VERSION (versionName) and CURRENT_PROJECT_VERSION (versionCode) | ||
xcodebuild -scheme BranchLinkSimulator -allowProvisioningUpdates \ | ||
MARKETING_VERSION=${{ env.VERSION_STRING }} \ | ||
CURRENT_PROJECT_VERSION=${{ env.VERSION_CODE_INT } \ | ||
-sdk iphoneos archive -archivePath ./IPA/BranchLinkSimulator.xcarchive | ||
xcodebuild -exportArchive -archivePath ./IPA/BranchLinkSimulator.xcarchive -exportOptionsPlist IPA/Info.plist -exportPath IPA/ | ||
working-directory: ./ios-app-repo # Run xcodebuild from the App's checkout directory | ||
# --- Step 7: Echo the location of the generated .app bundle --- | ||
- name: Echo .app bundle location | ||
run: | | ||
APP_PATH="./ios-app-repo/IPA/BranchLinkSimulator.ipa" | ||
echo "Generated IPA location: $APP_PATH" | ||
# --- Step 8: Upload Build Artifacts --- | ||
- name: Upload Build Artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: BranchLinkSimulator-iOS-Debug-Build | ||
path: ./ios-app-repo/IPA/BranchLinkSimulator.ipa | ||
# --- Step 9: Upload and run tests on GPTDriver service. --- | ||
- name: Run GPTDriver tests | ||
run: | | ||
call=$(curl -i -X POST \ | ||
-H "Content-Type: multipart/form-data" \ | ||
-F "build=@./ios-app-repo/IPA/BranchLinkSimulator.ipa" \ | ||
-F "organisation_key=${{ secrets.MOBILEBOOST_API_ORG_KEY }}" \ | ||
-F "platform=ios" \ | ||
-F "metadata={}" \ | ||
https://api.mobileboost.io/uploadBuild/) | ||
mobileboost_url=$(echo "$call" | grep -o '"app_link":"[^"]*"' | cut -d '"' -f 4) | ||
echo "${mobileboost_url}" >>$GITHUB_ENV | ||
env: | ||
API_ORG_KEY: ${{ secrets.MOBILEBOOST_API_ORG_KEY }} | ||
API_KEY: ${{ secrets.MOBILEBOOST_API_ORG_KEY }} # As per vendor design | ||
TEST_TAGS: Release |