Update Android SDK Version #18
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: Update Android SDK Version | |
| on: | |
| schedule: | |
| - cron: "0 9 * * MON" | |
| workflow_dispatch: | |
| workflow_call: | |
| inputs: | |
| target-version: | |
| description: "Specific Android SDK version to update to (optional)" | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| update-android-sdk: | |
| name: Update Android SDK Version | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.AUTOMATION_USER_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Fetch latest Android SDK version | |
| id: android-version | |
| run: | | |
| if [ -n "${{ inputs.target-version }}" ]; then | |
| TARGET_VERSION=$(echo "${{ inputs.target-version }}" | sed 's/^v//') | |
| echo "version=$TARGET_VERSION" >> $GITHUB_OUTPUT | |
| echo "Using specified Android SDK version: $TARGET_VERSION" | |
| else | |
| LATEST_ANDROID_VERSION=$(curl -s https://api.github.com/repos/DevCycleHQ/android-client-sdk/releases/latest | jq -r '.tag_name' | sed 's/^v//') | |
| echo "version=$LATEST_ANDROID_VERSION" >> $GITHUB_OUTPUT | |
| echo "Latest Android SDK version: $LATEST_ANDROID_VERSION" | |
| fi | |
| - name: Get current Android SDK version | |
| id: current-android | |
| run: | | |
| CURRENT_ANDROID=$(grep "android-client-sdk" android/build.gradle | sed -E 's/.*:([^"]+)".*/\1/') | |
| echo "version=$CURRENT_ANDROID" >> $GITHUB_OUTPUT | |
| echo "Current Android SDK version: $CURRENT_ANDROID" | |
| - name: Check if Android update is needed | |
| id: check-update | |
| run: | | |
| if [ "${{ steps.android-version.outputs.version }}" != "${{ steps.current-android.outputs.version }}" ]; then | |
| echo "update-needed=true" >> $GITHUB_OUTPUT | |
| echo "Android SDK update needed: ${{ steps.current-android.outputs.version }} -> ${{ steps.android-version.outputs.version }}" | |
| else | |
| echo "update-needed=false" >> $GITHUB_OUTPUT | |
| echo "Android SDK is already up to date" | |
| fi | |
| - name: Update Android SDK version | |
| if: steps.check-update.outputs.update-needed == 'true' | |
| run: | | |
| sed -i -E 's/(implementation\("com\.devcycle:android-client-sdk:)[^"]+("\))/\1${{ steps.android-version.outputs.version }}\2/' android/build.gradle | |
| echo "Updated Android SDK version to ${{ steps.android-version.outputs.version }}" | |
| - name: Setup Flutter | |
| if: steps.check-update.outputs.update-needed == 'true' | |
| uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046 # v2.19.0 | |
| with: | |
| flutter-version: "3.x" | |
| channel: "stable" | |
| - name: Prepare Flutter | |
| if: steps.check-update.outputs.update-needed == 'true' | |
| run: | | |
| cd example | |
| flutter pub get | |
| - name: Setup Java for Gradle | |
| if: steps.check-update.outputs.update-needed == 'true' | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: "temurin" | |
| java-version: "17" | |
| - name: Update Android dependency resolution | |
| if: steps.check-update.outputs.update-needed == 'true' | |
| run: | | |
| cd example/android | |
| ./gradlew dependencies --configuration implementation > /dev/null 2>&1 || true | |
| echo "✅ Updated Android dependency resolution for version ${{ steps.android-version.outputs.version }}" | |
| - name: Create Pull Request | |
| if: steps.check-update.outputs.update-needed == 'true' | |
| uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 | |
| with: | |
| token: ${{ secrets.AUTOMATION_USER_TOKEN }} | |
| commit-message: | | |
| chore: update Android SDK version to ${{ steps.android-version.outputs.version }} | |
| - Android SDK: ${{ steps.current-android.outputs.version }} -> ${{ steps.android-version.outputs.version }} | |
| title: "chore: update Android SDK to v${{ steps.android-version.outputs.version }}" | |
| body: | | |
| ## Summary | |
| This PR updates the DevCycle Android SDK to the latest version. | |
| ## Changes | |
| - **Android SDK**: `${{ steps.current-android.outputs.version }}` → `${{ steps.android-version.outputs.version }}` | |
| ## Files Modified | |
| - `android/build.gradle` - Updated Android SDK dependency version | |
| - Android dependency resolution updated for example app | |
| ## Testing | |
| This PR will be automatically tested by the Flutter SDK Unit Tests workflow which validates: | |
| - Flutter package dependencies | |
| - Code analysis with `flutter analyze` | |
| - Unit tests with `flutter test` | |
| - Package publishing validation with `flutter pub publish --dry-run` | |
| ## Release Notes | |
| See the [Android SDK release notes](https://github.com/DevCycleHQ/android-client-sdk/releases/tag/v${{ steps.android-version.outputs.version }}) for details on what's new in this version. | |
| --- | |
| This PR was automatically generated by the Update Android SDK Version workflow. | |
| branch: update-android-sdk-${{ steps.android-version.outputs.version }} | |
| delete-branch: true | |
| base: main | |
| labels: | | |
| dependencies | |
| android | |
| automated-pr | |
| - name: Output results | |
| run: | | |
| if [ "${{ steps.check-update.outputs.update-needed }}" = "true" ]; then | |
| echo "::notice title=Android SDK Updated::Created PR to update Android SDK to v${{ steps.android-version.outputs.version }}" | |
| else | |
| echo "::notice title=No Updates::Android SDK is already up to date (v${{ steps.current-android.outputs.version }})" | |
| fi |