|
3 | 3 | workflow_dispatch: {} |
4 | 4 |
|
5 | 5 | jobs: |
6 | | - static-analysis: |
7 | | - runs-on: macos-latest |
| 6 | + BuildAndTestAppOnGPTDriver: # Job name, as chosen |
| 7 | + runs-on: macos-latest # macOS runner is required for iOS builds |
8 | 8 | steps: |
9 | | - - name: Check out code |
| 9 | + # --- Step 1: Extract version from branch name --- |
| 10 | + - name: Extract version from branch name |
| 11 | + id: extract_version_step |
| 12 | + run: | |
| 13 | + BRANCH_NAME="${{ github.ref }}" |
| 14 | + # Remove 'refs/heads/' prefix (e.g., refs/heads/Release-0.0.0 -> Release-0.0.0) |
| 15 | + BRANCH_NAME_WITHOUT_PREFIX="${BRANCH_NAME#refs/heads/}" |
| 16 | + # Extract version after "Release-" (e.g., Release-0.0.0 -> 0.0.0) |
| 17 | + VERSION=$(echo "$BRANCH_NAME_WITHOUT_PREFIX" | sed -n 's/^Release-\([0-9]*\.[0-9]*\.[0-9]*\)$/\1/p') |
| 18 | +
|
| 19 | + if [ -z "$VERSION" ]; then |
| 20 | + echo "Error: Could not extract version from branch name '$BRANCH_NAME_WITHOUT_PREFIX'. Expected format: Release-X.Y.Z" |
| 21 | + exit 1 |
| 22 | + fi |
| 23 | +
|
| 24 | + echo "Extracted versionName: $VERSION" |
| 25 | + echo "VERSION_STRING=$VERSION" >> $GITHUB_ENV |
| 26 | +
|
| 27 | + # Convert semantic version to an integer for CFBundleVersion (versionCode equivalent) |
| 28 | + # Example: 1.2.3 -> 102003 (assuming max 2 digits for minor/patch) |
| 29 | + # This should be adjusted based on the maximum expected values for major/minor/patch |
| 30 | + MAJOR=$(echo "$VERSION" | cut -d. -f1) |
| 31 | + MINOR=$(echo "$VERSION" | cut -d. -f2) |
| 32 | + PATCH=$(echo "$VERSION" | cut -d. -f3) |
| 33 | +
|
| 34 | + # Calculate versionCode (CFBundleVersion) - ensure this fits in a 32-bit integer |
| 35 | + # Standard Android-like conversion: Major * 10000 + Minor * 100 + Patch |
| 36 | + # This provides sufficient uniqueness for most common versioning schemes. |
| 37 | + VERSION_CODE_INT=$(( MAJOR * 10000 + MINOR * 100 + PATCH )) |
| 38 | + echo "Calculated versionCode: $VERSION_CODE_INT" |
| 39 | + echo "VERSION_CODE_INT=$VERSION_CODE_INT" >> $GITHUB_ENV |
| 40 | +
|
| 41 | +
|
| 42 | + # --- Step 2: Checkout the iOS Branch SDK repository --- |
| 43 | + - name: Checkout BranchMetrics/ios-branch-deep-linking-attribution (SDK) |
10 | 44 | uses: actions/checkout@v4 |
11 | | - - name: Run static analysis |
| 45 | + with: |
| 46 | + repository: BranchMetrics/ios-branch-deep-linking-attribution |
| 47 | + ref: ${{ github.ref }} # Use the same branch that triggered the workflow |
| 48 | + path: ./branch-ios-sdk-repo # Checkout into a subdirectory |
| 49 | + |
| 50 | + # --- Step 3: Build the iOS Branch SDK Framework --- |
| 51 | + - name: Build Branch SDK Framework |
| 52 | + run: | |
| 53 | + # Build for simulator. Adjust scheme if necessary. |
| 54 | + # The output framework will be in build/Debug-iphonesimulator/BranchSDK.framework |
| 55 | + xcodebuild build -project Branch-SDK/Branch-SDK.xcodeproj \ |
| 56 | + -scheme BranchSDK \ |
| 57 | + -configuration Debug \ |
| 58 | + -sdk iphonesimulator \ |
| 59 | + BUILD_DIR="${{ github.workspace }}/branch-ios-sdk-repo/build" \ |
| 60 | + SKIP_INSTALL=NO |
| 61 | + working-directory: ./branch-ios-sdk-repo # Run xcodebuild from the SDK's checkout directory |
| 62 | + |
| 63 | + # --- Step 4: Checkout the iOS Branch Link Simulator App repository --- |
| 64 | + - name: Checkout BranchMetrics/BranchLinkSimulator (App) |
| 65 | + uses: actions/checkout@v4 |
| 66 | + with: |
| 67 | + repository: BranchMetrics/BranchLinkSimulator |
| 68 | + ref: gptdriver/linkingTests # Checkout the specific app branch |
| 69 | + path: ./ios-app-repo # Checkout into another subdirectory |
| 70 | + |
| 71 | + # --- Step 5: Copy the generated SDK Framework to the App's project --- |
| 72 | + - name: Copy generated SDK Framework to App's libs directory |
| 73 | + run: | |
| 74 | + # Create a 'Frameworks' directory within the app repo for the local SDK |
| 75 | + mkdir -p ./ios-app-repo/Frameworks |
| 76 | + # Copy the built framework |
| 77 | + cp -R ./branch-ios-sdk-repo/build/Debug-iphonesimulator/BranchSDK.framework ./ios-app-repo/Frameworks/ |
| 78 | + working-directory: ${{ github.workspace }} # Run from the root of the GITHUB_WORKSPACE |
| 79 | + |
| 80 | + # --- Step 6: Build the iOS Branch Link Simulator App using the local SDK Framework --- |
| 81 | + - name: Build iOS App with local SDK |
| 82 | + run: | |
| 83 | + # Build the app. Adjust project/workspace, scheme, and destination if necessary. |
| 84 | + # We're passing MARKETING_VERSION (versionName) and CURRENT_PROJECT_VERSION (versionCode) |
| 85 | + xcodebuild build -project BranchLinkSimulator.xcodeproj \ |
| 86 | + -scheme BranchLinkSimulator \ |
| 87 | + -configuration Debug \ |
| 88 | + -sdk iphonesimulator \ |
| 89 | + -destination 'platform=iOS Simulator,name=iPhone 15' \ |
| 90 | + MARKETING_VERSION=${{ env.VERSION_STRING }} \ |
| 91 | + CURRENT_PROJECT_VERSION=${{ env.VERSION_CODE_INT }} \ |
| 92 | + # Adjust Framework Search Paths if your Xcode project doesn't automatically find it |
| 93 | + # For example, if you need to point directly to the copied framework: |
| 94 | + # FRAMEWORK_SEARCH_PATHS="$(SRCROOT)/Frameworks" |
| 95 | + working-directory: ./ios-app-repo # Run xcodebuild from the App's checkout directory |
| 96 | + |
| 97 | + # --- Step 7: Echo the location of the generated .app bundle --- |
| 98 | + - name: Echo .app bundle location |
| 99 | + run: | |
| 100 | + APP_PATH="./ios-app-repo/build/Debug-iphonesimulator/BranchLinkSimulator.app" |
| 101 | + echo "Generated .app bundle location: $APP_PATH" |
| 102 | + # You can also use 'find' to be more dynamic if the name might change |
| 103 | + # find ./ios-app-repo/build -name "*.app" |
| 104 | +
|
| 105 | + # --- Step 8: Upload Build Artifacts --- |
| 106 | + - name: Upload Build Artifacts |
| 107 | + uses: actions/upload-artifact@v4 |
| 108 | + with: |
| 109 | + name: BranchLinkSimulator-iOS-Debug-Build |
| 110 | + path: ./ios-app-repo/build/Debug-iphonesimulator/BranchLinkSimulator.app |
| 111 | + |
| 112 | + # --- Step 9: Upload and run tests on GPTDriver service. --- |
| 113 | + - name: Run GPTDriver tests |
12 | 114 | run: | |
13 | | - xcodebuild analyze -project BranchSDK.xcodeproj |
| 115 | + # Ensure the script is executable |
| 116 | + chmod +x ./branch-ios-sdk-repo/.github/gptdriverrunscript.sh |
| 117 | + # Execute the script, passing the .app path and platform |
| 118 | + bash ./branch-ios-sdk-repo/.github/gptdriverrunscript.sh ./ios-app-repo/build/Debug-iphonesimulator/BranchLinkSimulator.app ios |
| 119 | + env: |
| 120 | + API_ORG_KEY: ${{ secrets.MOBILEBOOST_API_ORG_KEY }} |
| 121 | + API_KEY: ${{ secrets.MOBILEBOOST_API_ORG_KEY }} # As per vendor design |
| 122 | + TEST_TAGS: Release |
0 commit comments