Add Debug APK Creation #6769
Workflow file for this run
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
| # SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors | |
| # SPDX-FileCopyrightText: 2025 Alper Ozturk <alper.ozturk@nextcloud.com> | |
| # SPDX-FileCopyrightText: 2020-2024 Stefan Niedermann <info@niedermann.it> | |
| # SPDX-FileCopyrightText: 2023 Álvaro Brey <alvaro.brey@nextcloud.com> | |
| # SPDX-License-Identifier: GPL-3.0-or-later | |
| name: Android CI | |
| on: | |
| pull_request: | |
| push: | |
| branches: [ main, stable-* ] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| validation: | |
| name: Validate Gradle Wrapper | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| check-latest: true | |
| cache: 'gradle' | |
| - name: Validate Gradle Wrapper | |
| uses: gradle/actions/wrapper-validation@ac638b010cf58a27ee6c972d7336334ccaf61c96 # v4.4.1 | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| check-latest: true | |
| cache: 'gradle' | |
| - name: Lint | |
| run: bash ./gradlew lintDevDebug --stacktrace --no-configuration-cache | |
| test: | |
| name: Unit tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| check-latest: true | |
| cache: 'gradle' | |
| - name: Unit tests | |
| run: bash ./gradlew test --stacktrace --no-configuration-cache | |
| apk: | |
| name: Generate APK | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| check-latest: true | |
| cache: 'gradle' | |
| - name: Build debug APK | |
| run: bash ./gradlew assembleDev --stacktrace --no-configuration-cache | |
| - name: Upload APK | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: app-dev-debug | |
| path: app/build/outputs/apk/dev/debug/app-dev-debug.apk | |
| - name: Upload to Nextcloud and comment | |
| env: | |
| USER: ${{ secrets.NEXTCLOUD_USER }} | |
| PASS: ${{ secrets.NEXTCLOUD_PASSWORD }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| BUILD: pr-${{ github.event.pull_request.number }}-${{ github.sha }} | |
| PR: ${{ github.event.pull_request.number }} | |
| PUBLIC_URL: https://www.kaminsky.me/nc-dev/android-artifacts | |
| DAV_URL: https://nextcloud.kaminsky.me/remote.php/dav/files/${{ secrets.NEXTCLOUD_USER }}/android-artifacts | |
| run: | | |
| APK=$(find app/build/outputs/apk/qa/debug -name "qa-debug-*.apk" | head -n1) | |
| [ -f "$APK" ] || { echo "APK not found"; exit 1; } | |
| curl -u "$USER:$PASS" -T "$APK" "$DAV_URL/$BUILD.apk" | |
| qrencode -o "$PR.png" "$PUBLIC_URL/$BUILD.apk" | |
| curl -u "$USER:$PASS" -T "$PR.png" "$DAV_URL/$BUILD.png" | |
| COMMENT="APK file: $PUBLIC_URL/$BUILD.apk\n\n\n\nTo test this change or fix, download and install the APK above. It can run in parallel to your existing app." | |
| curl -s -X POST \ | |
| -H "Authorization: token $GITHUB_TOKEN" \ | |
| -H "Content-Type: application/json" \ | |
| -d "$(jq -n --arg body "$COMMENT" '{body: $body}')" \ | |
| https://api.github.com/repos/${{ github.repository }}/issues/$PR/comments |