diff --git a/.github/workflows/custom_release.yml b/.github/workflows/custom_release.yml new file mode 100644 index 00000000000..81887dd4251 --- /dev/null +++ b/.github/workflows/custom_release.yml @@ -0,0 +1,58 @@ +# Workflow to deploy custom builds on ODK Collect + +name: 🔧 Build and Release + +on: + release: + types: [published] + # Allow manual trigger (workflow_dispatch) + workflow_dispatch: + +jobs: + build_upload_apk: + runs-on: ubuntu-latest + permissions: + contents: write + + container: + image: docker.io/cimg/android:2023.10.1 + + env: + APK_TARGET_PATH: "./apks/odkcollect_${{ github.event.release.tag_name }}.apk" + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Add Robolectric Deps + run: ./download-robolectric-deps.sh + + - name: Compile Code + run: ./gradlew assembleDebug + + - name: Build Self-Signed APK + run: | + ./gradlew assembleSelfSignedRelease + + apk_source_path=$(find ./collect_app/build/outputs/apk/selfSignedRelease -name '*.apk' -type f) + echo "Generated APK file: ${apk_source_path}" + + mkdir -p apks + echo "cp ${apk_source_path} ${APK_TARGET_PATH}" + cp "${apk_source_path}" "${APK_TARGET_PATH}" + + - name: Install Github CLI + run: | + sudo apt update + sudo apt install --no-install-recommends -y gh + + - name: Upload Release APK + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: + echo "Current PWD:" + echo "$PWD" + echo "Files in apk dir:" + ls -lahs "./apks/" + + gh release upload ${{ github.event.release.tag_name }} "${APK_TARGET_PATH}"