name: Build APK and root module (and create nightly release) on: push: branches: - '*' workflow_dispatch: inputs: release: description: 'Create a nightly release' required: true type: boolean default: false workflow_call: jobs: build-debug-apk: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: true - uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: 21 - uses: gradle/actions/setup-gradle@v4 - name: Build debug APK run: ./gradlew assembleDebug working-directory: android - name: Upload artifact uses: actions/upload-artifact@v4 with: name: Debug APK path: android/app/build/outputs/apk/**/*.apk nightly-release: runs-on: ubuntu-latest if: github.event_name == 'push' && github.ref == 'refs/heads/release-nightly' || github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'true' needs: build-debug-apk permissions: contents: write steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 - name: Export APK_NAME for later use run: echo "APK_NAME=ALN-$(echo ${{ github.sha }} | cut -c1-7).apk" >> $GITHUB_ENV - name: Rename .apk file run: mv "./Debug APK/debug/"*.apk "./$APK_NAME" - name: Decode keystore file run: echo "${{ secrets.DEBUG_KEYSTORE_FILE }}" | base64 --decode > debug.keystore - name: Install apksigner run: sudo apt-get update && sudo apt-get install -y apksigner - name: Sign APK run: | apksigner sign --ks debug.keystore --ks-key-alias androiddebugkey --ks-pass pass:android --key-pass pass:android "./$APK_NAME" - name: Verify APK run: apksigner verify "./$APK_NAME" - name: Fetch the latest non-nightly release tag id: fetch-tag run: echo "::set-output name=tag::$(git describe --tags $(git rev-list --tags --max-count=1))" - name: Retrieve commits since the last release id: get-commits run: | COMMITS=$(git log ${{ steps.fetch-tag.outputs.tag }}..HEAD --pretty=format:"- %s (%h)" --abbrev-commit) echo "::set-output name=commits::${COMMITS}" - name: Zip root-module directory run: zip -r -0 ../btl2capfix.zip * --verbose working-directory: root-module - name: Delete release if exist then create release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh release view "nightly" && gh release delete "nightly" -y --cleanup-tag gh release create "nightly" "./$APK_NAME" "./btl2capfix.zip" -p -t "Nightly Release" -n "${{ steps.get-commits.outputs.commits }}" --generate-notes