Attach Debug APKs To Release #88
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: Attach Debug APKs To Release | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| package_variant: [ apt-android-7, apt-android-5 ] | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| - name: Clone repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ env.GITHUB_REF }} | |
| submodules: 'true' | |
| - name: Set up Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 17 | |
| distribution: "temurin" | |
| - name: Build | |
| shell: bash {0} | |
| env: | |
| PACKAGE_VARIANT: ${{ matrix.package_variant }} | |
| run: | | |
| # Set RELEASE_VERSION_NAME to "<CURRENT_VERSION_NAME>+<last_commit_hash>" | |
| CURRENT_VERSION_NAME_REGEX='\s+versionName "([^"]+)"$' | |
| CURRENT_VERSION_NAME="$(grep -m 1 -E "$CURRENT_VERSION_NAME_REGEX" ./app/build.gradle | sed -r "s/$CURRENT_VERSION_NAME_REGEX/\1/")" | |
| RELEASE_VERSION_NAME="v$CURRENT_VERSION_NAME+${GITHUB_SHA:0:7}" # The "+" is necessary so that versioning precedence is not affected | |
| APK_DIR_PATH="./app/build/outputs/apk/debug" | |
| APK_VERSION_TAG="$RELEASE_VERSION_NAME+${{ env.PACKAGE_VARIANT }}-github-debug" | |
| APK_BASENAME_PREFIX="termux-app_$APK_VERSION_TAG" | |
| echo "Building APKs for 'APK_VERSION_TAG' release" | |
| export TERMUX_APK_VERSION_TAG="$APK_VERSION_TAG" # Used by app/build.gradle | |
| export TERMUX_PACKAGE_VARIANT="${{ env.PACKAGE_VARIANT }}" # Used by app/build.gradle | |
| ./gradlew assembleDebug | |
| echo "Validating APKs" | |
| for abi in universal arm64-v8a armeabi-v7a x86_64 x86; do | |
| if ! test -f "$APK_DIR_PATH/${APK_BASENAME_PREFIX}_$abi.apk"; then | |
| files_found="$(ls "$APK_DIR_PATH")" | |
| echo "Failed to find built APK at '$APK_DIR_PATH/${APK_BASENAME_PREFIX}_$abi.apk'. Files found: "$'\n'"$files_found" | |
| exit 1 | |
| fi | |
| done | |
| - name: Upload APKs to GitHub artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.package_variant }} | |
| path: ./app/build/outputs/apk/debug/*.apk | |
| upload: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| - name: Download artifact | |
| uses: actions/download-artifact@v4 | |
| - name: Upload APKs to release | |
| uses: termux/upload-release-action@v4.1.0 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: "**/*.apk" | |
| file_glob: true | |
| release_name: "v1.0.7-beta" | |
| tag: 1.0.7 | |
| checksums: sha256,sha512,md5 |