Skip to content

Commit 95a1995

Browse files
Update gptdriverscript.yml
1 parent acdb8c2 commit 95a1995

File tree

1 file changed

+83
-53
lines changed

1 file changed

+83
-53
lines changed

.github/workflows/gptdriverscript.yml

Lines changed: 83 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@ on:
66
- 'Release-*' # Trigger for branches starting with "Release-"
77

88
jobs:
9-
BuildAndTestAppOnGPTDriver: # Updated job name
10-
runs-on: macos-latest # macOS runner is required for iOS builds
9+
BuildAndTestAppOnGPTDriver:
10+
runs-on: macos-latest
1111
steps:
1212
# --- Step 1: Extract version from branch name ---
1313
- name: Extract version from branch name
1414
id: extract_version_step
1515
run: |
1616
BRANCH_NAME="${{ github.ref }}"
17-
# Remove 'refs/heads/' prefix (e.g., refs/heads/Release-0.0.0 -> Release-0.0.0)
1817
BRANCH_NAME_WITHOUT_PREFIX="${BRANCH_NAME#refs/heads/}"
19-
# Extract version after "Release-" (e.g., Release-0.0.0 -> 0.0.0)
2018
VERSION=$(echo "$BRANCH_NAME_WITHOUT_PREFIX" | sed -n 's/^Release-\([0-9]*\.[0-9]*\.[0-9]*\)$/\1/p')
2119
2220
if [ -z "$VERSION" ]; then
@@ -27,16 +25,10 @@ jobs:
2725
echo "Extracted versionName: $VERSION"
2826
echo "VERSION_STRING=$VERSION" >> $GITHUB_ENV
2927
30-
# Convert semantic version to an integer for CFBundleVersion (versionCode equivalent)
31-
# Example: 1.2.3 -> 102003 (assuming max 2 digits for minor/patch)
32-
# This should be adjusted based on the maximum expected values for major/minor/patch
3328
MAJOR=$(echo "$VERSION" | cut -d. -f1)
3429
MINOR=$(echo "$VERSION" | cut -d. -f2)
3530
PATCH=$(echo "$VERSION" | cut -d. -f3)
3631
37-
# Calculate versionCode (CFBundleVersion) - ensure this fits in a 32-bit integer
38-
# Standard Android-like conversion: Major * 10000 + Minor * 100 + Patch
39-
# This provides sufficient uniqueness for most common versioning schemes.
4032
VERSION_CODE_INT=$(( MAJOR * 10000 + MINOR * 100 + PATCH ))
4133
echo "Calculated versionCode: $VERSION_CODE_INT"
4234
echo "VERSION_CODE_INT=$VERSION_CODE_INT" >> $GITHUB_ENV
@@ -47,14 +39,14 @@ jobs:
4739
uses: actions/checkout@v4
4840
with:
4941
repository: BranchMetrics/ios-branch-deep-linking-attribution
50-
ref: ${{ github.ref }} # Use the same branch that triggered the workflow
51-
path: ./branch-ios-sdk-repo # Checkout into a subdirectory
42+
ref: ${{ github.ref }}
43+
path: ./branch-ios-sdk-repo
5244

5345
# --- Step 3: Build the iOS Branch SDK Framework ---
5446
- name: Build Branch SDK Framework
5547
run: |
5648
echo "--- Listing contents of the SDK repo directory for debugging ---"
57-
ls -R . # List contents recursively from the current working directory
49+
ls -R .
5850
echo "-------------------------------------------------------------"
5951
echo "Attempting to build the SDK framework..."
6052
xcodebuild build -project BranchSDK.xcodeproj \
@@ -63,83 +55,121 @@ jobs:
6355
-sdk iphonesimulator \
6456
BUILD_DIR="${{ github.workspace }}/branch-ios-sdk-repo/build" \
6557
SKIP_INSTALL=NO
66-
working-directory: ./branch-ios-sdk-repo # Run xcodebuild from the SDK's checkout directory
58+
working-directory: ./branch-ios-sdk-repo
6759

6860
# --- Step 4: Checkout the iOS Branch Link Simulator App repository ---
6961
- name: Checkout BranchMetrics/BranchLinkSimulator (App)
7062
uses: actions/checkout@v4
7163
with:
7264
repository: BranchMetrics/BranchLinkSimulator
73-
ref: gptdriver/linkingTests # Checkout the specific app branch
74-
path: ./ios-app-repo # Checkout into another subdirectory
65+
ref: gptdriver/linkingTests
66+
path: ./ios-app-repo
7567

7668
# --- Step 5: Copy the generated SDK Framework to the App's project ---
7769
- name: Copy generated SDK Framework to App's project
7870
run: |
79-
# Create a 'Frameworks' directory within the app repo for the local SDK
8071
mkdir -p ./ios-app-repo/Frameworks
81-
# Copy the built framework
8272
cp -R ./branch-ios-sdk-repo/build/Debug-iphonesimulator/BranchSDK.framework ./ios-app-repo/Frameworks/
83-
working-directory: ${{ github.workspace }} # Run from the root of the GITHUB_WORKSPACE
73+
working-directory: ${{ github.workspace }}
8474

85-
# --- Step 6: Build the iOS App using the local SDK Framework and get output path ---
86-
- name: Build iOS App with local SDK
75+
# --- Step 6: Archive iOS App (to prepare for IPA export) ---
76+
- name: Archive iOS App
8777
run: |
88-
set -o pipefail # Fail if any part of the pipe fails
78+
ARCHIVE_PATH="${{ github.workspace }}/ios-app-repo/build/BranchLinkSimulator.xcarchive"
79+
echo "Archiving app to: $ARCHIVE_PATH"
8980
90-
# First, perform the build. Pipe to xcpretty for cleaner logs if installed.
91-
# Note: xcpretty is optional, if you don't have it installed in your runner environment, remove '| xcpretty'
92-
xcodebuild build -project BranchLinkSimulator.xcodeproj \
81+
# Use 'xcodebuild archive' to create the .xcarchive
82+
# For simulator builds, you typically don't need real code signing,
83+
# but `archive` still requires some identity for metadata.
84+
xcodebuild archive -project BranchLinkSimulator.xcodeproj \
9385
-scheme BranchLinkSimulator \
9486
-configuration Debug \
9587
-sdk iphonesimulator \
9688
-destination 'platform=iOS Simulator,name=iPhone 15' \
89+
-archivePath "$ARCHIVE_PATH" \
9790
MARKETING_VERSION=${{ env.VERSION_STRING }} \
9891
CURRENT_PROJECT_VERSION=${{ env.VERSION_CODE_INT }} \
9992
FRAMEWORK_SEARCH_PATHS="$(SRCROOT)/Frameworks" \
10093
ONLY_ACTIVE_ARCH=YES \
101-
| xcpretty || true # Added || true to prevent build failure due to xcpretty if it's not installed or errors.
102-
103-
# Now, query build settings to get the exact output directory
104-
BUILT_PRODUCTS_DIR=$(xcodebuild -project BranchLinkSimulator.xcodeproj \
105-
-scheme BranchLinkSimulator \
106-
-configuration Debug \
107-
-sdk iphonesimulator \
108-
-showBuildSettings \
109-
| grep -m 1 "BUILT_PRODUCTS_DIR =" \
110-
| sed 's/.*BUILT_PRODUCTS_DIR = //') # <-- Added missing ')' here
111-
112-
if [ -z "$BUILT_PRODUCTS_DIR" ]; then
113-
echo "Error: Could not determine BUILT_PRODUCTS_DIR."
94+
SKIP_INSTALL=NO \
95+
CODE_SIGN_IDENTITY="" \
96+
CODE_SIGNING_REQUIRED=NO \
97+
CODE_SIGNING_ALLOWED=NO \
98+
| xcpretty || true # xcpretty for cleaner logs, || true to prevent failure if xcpretty is missing
99+
100+
if [ ! -d "$ARCHIVE_PATH" ]; then
101+
echo "Error: Archive not created at $ARCHIVE_PATH"
114102
exit 1
115103
fi
104+
echo "ARCHIVE_PATH=$ARCHIVE_PATH" >> $GITHUB_ENV
105+
working-directory: ./ios-app-repo
116106

117-
echo "Detected BUILT_PRODUCTS_DIR: $BUILT_PRODUCTS_DIR"
118-
echo "BUILT_PRODUCTS_DIR=$BUILT_PRODUCTS_DIR" >> $GITHUB_ENV # Set as environment variable
107+
# --- Step 7: Export IPA from Archive ---
108+
- name: Export IPA from Archive
109+
run: |
110+
IPA_OUTPUT_DIR="${{ github.workspace }}/ios-app-repo/build/IPA_Output"
111+
mkdir -p "$IPA_OUTPUT_DIR"
112+
113+
# Create a simple ExportOptions.plist for 'development' method (suitable for debug/test IPAs)
114+
EXPORT_OPTIONS_PLIST_PATH="$IPA_OUTPUT_DIR/ExportOptions.plist"
115+
cat <<EOF > "$EXPORT_OPTIONS_PLIST_PATH"
116+
<?xml version="1.0" encoding="UTF-8"?>
117+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
118+
<plist version="1.0">
119+
<dict>
120+
<key>method</key>
121+
<string>development</string>
122+
<key>compileBitcode</key>
123+
<false/>
124+
<key>uploadSymbols</key>
125+
<false/>
126+
</dict>
127+
</plist>
128+
EOF
129+
echo "Exporting IPA to: $IPA_OUTPUT_DIR"
130+
xcodebuild -exportArchive \
131+
-archivePath "${{ env.ARCHIVE_PATH }}" \
132+
-exportPath "$IPA_OUTPUT_DIR" \
133+
-exportOptionsPlist "$EXPORT_OPTIONS_PLIST_PATH" \
134+
| xcpretty || true # xcpretty for cleaner logs
135+
136+
# Find the generated IPA file dynamically, as its exact name might vary
137+
GENERATED_IPA=$(find "$IPA_OUTPUT_DIR" -name "*.ipa" -print -quit)
138+
if [ -z "$GENERATED_IPA" ]; then
139+
echo "Error: Could not find generated IPA file in $IPA_OUTPUT_DIR."
140+
exit 1
141+
fi
119142

120-
working-directory: ./ios-app-repo # Run xcodebuild from the App's checkout directory
143+
echo "Generated IPA path: $GENERATED_IPA"
144+
echo "APP_PATH=$GENERATED_IPA" >> $GITHUB_ENV # Overwrite APP_PATH to point to the IPA
145+
echo "--- Contents of IPA Output Directory ---"
146+
ls -R "$IPA_OUTPUT_DIR" # Show what was actually exported
147+
echo "----------------------------------------"
148+
working-directory: ./ios-app-repo # This step also runs from the app's checkout root.
121149

122-
# --- Step 7: Echo the location of the generated .app bundle ---
123-
- name: Echo .app bundle location
150+
# --- Step 8: Echo the location of the generated .ipa file ---
151+
- name: Echo .ipa file location
124152
run: |
125-
APP_PATH="${{ env.BUILT_PRODUCTS_DIR }}/BranchLinkSimulator.app"
126-
echo "Generated .app bundle location: $APP_PATH"
153+
# APP_PATH now holds the path to the .ipa file from the previous step
154+
echo "Generated .ipa file location: ${{ env.APP_PATH }}"
127155
128-
# --- Step 8: Upload Build Artifacts ---
156+
# --- Step 9: Upload Build Artifacts (now the .ipa) ---
129157
- name: Upload Build Artifacts
130158
uses: actions/upload-artifact@v4
131159
with:
132-
name: BranchLinkSimulator-iOS-Debug-Build
133-
path: "${{ env.BUILT_PRODUCTS_DIR }}/BranchLinkSimulator.app"
160+
name: BranchLinkSimulator-iOS-Debug-Build-IPA
161+
path: "${{ env.APP_PATH }}" # This now points to the IPA
134162

135-
# --- Step 9: Upload and run tests on GPTDriver service. ---
163+
# --- Step 10: Upload and run tests on GPTDriver service (using .ipa) ---
136164
- name: Run GPTDriver tests
137165
run: |
138-
# Ensure the script is executable
166+
# !!! IMPORTANT: ENSURE your gptdriverrunscript.sh can handle .ipa files directly !!!
167+
# It currently expects a .app bundle. You MUST verify with the service
168+
# if it accepts .ipa files directly, or if the script needs modification
169+
# to extract the .app from the .ipa before upload.
139170
chmod +x ./branch-ios-sdk-repo/.github/gptdriverrunscript.sh
140-
# Execute the script, passing the .app path and platform
141-
bash ./branch-ios-sdk-repo/.github/gptdriverrunscript.sh "${{ env.BUILT_PRODUCTS_DIR }}/BranchLinkSimulator.app" ios
171+
bash ./branch-ios-sdk-repo/.github/gptdriverrunscript.sh "${{ env.APP_PATH }}" ios
142172
env:
143173
API_ORG_KEY: ${{ secrets.MOBILEBOOST_API_ORG_KEY }}
144-
API_TOKEN: ${{ secrets.MOBILEBOOST_API_ORG_KEY }} # CORRECTED: Mapped secret to API_TOKEN for the script
174+
API_TOKEN: ${{ secrets.MOBILEBOOST_API_ORG_KEY }}
145175
TEST_TAGS: Release

0 commit comments

Comments
 (0)