1+ name : Release Version Extraction and Local AAR Build
2+
3+ on :
4+ push :
5+ branches :
6+ - ' Release-*' # Trigger for branches starting with "Release-"
7+
8+ jobs :
9+ extract_version_and_build :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - name : Extract version from branch name
13+ id : extract_version_step
14+ run : |
15+ BRANCH_NAME="${{ github.ref }}"
16+ # Remove 'refs/heads/' prefix
17+ BRANCH_NAME_WITHOUT_PREFIX="${BRANCH_NAME#refs/heads/}"
18+ # Extract version after "Release-"
19+ VERSION=$(echo "$BRANCH_NAME_WITHOUT_PREFIX" | sed -n 's/^Release-\([0-9]*\.[0-9]*\.[0-9]*\)$/\1/p')
20+
21+ if [ -z "$VERSION" ]; then
22+ echo "Error: Could not extract version from branch name '$BRANCH_NAME_WITHOUT_PREFIX'. Expected format: Release-X.Y.Z"
23+ exit 1
24+ fi
25+
26+ echo "Extracted version: $VERSION"
27+ echo "VERSION_STRING=$VERSION" >> $GITHUB_ENV
28+
29+ # --- Step 1: Checkout the Branch SDK repository ---
30+ - name : Checkout BranchMetrics/android-branch-deep-linking-attribution (SDK)
31+ uses : actions/checkout@v4
32+ with :
33+ repository : BranchMetrics/android-branch-deep-linking-attribution
34+ ref : master # Assuming 'master' is the current release branch for the SDK
35+ path : ./branch-sdk-repo # Checkout into a subdirectory
36+
37+ # --- Step 2: Build the Branch SDK AAR ---
38+ - name : Set up JDK for SDK build
39+ uses : actions/setup-java@v4
40+ with :
41+ distribution : ' temurin'
42+ java-version : ' 17' # Ensure this matches the SDK's build requirements
43+
44+ - name : Build Branch SDK AAR
45+ run : ./gradlew :Branch-SDK:assembleDebug # Use the specific module command
46+ working-directory : ./branch-sdk-repo # Run Gradle from the SDK's checkout directory
47+
48+ # --- Step 3: Checkout the BranchLinkSimulatorAndroid repository ---
49+ - name : Checkout BranchMetrics/BranchLinkSimulatorAndroid (App)
50+ uses : actions/checkout@v4
51+ with :
52+ repository : BranchMetrics/BranchLinkSimulatorAndroid
53+ ref : gptdriver/linkingTests # Checkout the specific app branch
54+ path : ./app-repo # Checkout into another subdirectory
55+
56+ # --- Step 4: Copy the generated AAR to the App's libs directory ---
57+ - name : Copy generated AAR to App's libs directory
58+ run : |
59+ mkdir -p ./app-repo/app/libs # Create libs directory if it doesn't exist
60+ cp ./branch-sdk-repo/Branch-SDK/build/outputs/aar/Branch-SDK-debug.aar ./app-repo/app/libs/branch-sdk-debug.aar
61+ # Adjust the AAR name (Branch-SDK-debug.aar) if the actual output name is different
62+ # The path within the SDK repo might vary based on its build structure
63+ working-directory : ${{ github.workspace }} # Run from the root of the GITHUB_WORKSPACE
64+
65+ # --- Step 5: Build the BranchLinkSimulatorAndroid App using the local AAR ---
66+ - name : Set up JDK for App build
67+ uses : actions/setup-java@v4
68+ with :
69+ distribution : ' temurin'
70+ java-version : ' 17' # Ensure this matches the App's build requirements
71+
72+ - name : Build App with local AAR and pass version
73+ run : ./gradlew build -PversionNameFromCi=${{ env.VERSION_STRING }}
74+ working-directory : ./app-repo # Run Gradle from the App's checkout directory
75+
76+ # --- Step 6: Echo the location of the generated APK file ---
77+ - name : Echo APK location
78+ run : |
79+ APK_PATH="./app-repo/app/build/outputs/apk/debug/app-debug.apk"
80+ echo "Generated APK location: $APK_PATH"
81+
82+ # --- Step 7: Upload APK and other artifacts ---
83+ - name : Upload Build Artifacts
84+ uses : actions/upload-artifact@v4
85+ with :
86+ name : BranchLinkSimulator-App-Debug-Build
87+ path : ./app-repo/app/build/outputs/apk/debug/app-debug.apk
88+ # If you have other artifacts you want to save, you can add them here.
89+ # For example, to save all APKs:
90+ # path: ./app-repo/app/build/outputs/apk/
91+ # Or specific files:
92+ # path: |
93+ # ./app-repo/app/build/outputs/apk/debug/app-debug.apk
94+ # ./app-repo/app/build/reports/
95+ # ./app-repo/some_other_file.log
0 commit comments