From f34aa6bf41f15c58deaba2370861f08a9b02ee22 Mon Sep 17 00:00:00 2001 From: ErrrorMaxx Date: Sun, 11 Feb 2024 08:45:05 +0300 Subject: [PATCH] Setup GitHub Actions --- .github/workflows/build.yml | 83 +++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..fb63ca1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,83 @@ +name: Android CI + +on: + workflow_dispatch: + + push: + branches: [ master, main ] + paths-ignore: [ '*.md' ] + pull_request: + branches: [ master, main ] + paths-ignore: [ '*.md' ] + + release: + types: [ published ] + +jobs: + validation: + name: Gradle Validation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: gradle/wrapper-validation-action@v1 + + build: + name: Build (debug) + runs-on: ubuntu-latest + needs: validation + + if: ${{ needs.validation.result == 'success' && (github.event_name != 'push' || !startsWith(github.event.head_commit.message, '[skip ci]')) }} + + steps: + - uses: actions/checkout@v4 + - uses: errr-maxx-builds/android-setup-build-env@master + with: + usePatchedSDK: true # custom + + - shell: bash + run: | + + # Setup GITHUB_SHA + if [[ "$GITHUB_EVENT_NAME" = 'pull_request' ]]; then + GITHUB_SHA="${{ github.event.pull_request.head.sha }}" # Do not use last merge commit set in GITHUB_SHA + fi + GITHUB_SHA="${GITHUB_SHA:0:7}" + + # App/apk name + APP_NAME="${{ github.event.repository.name }}-${GITHUB_SHA}" + echo APP_NAME="$APP_NAME" >> "$GITHUB_ENV" + + # Build + ./gradlew assembleDebug || exit $? + mv ./app/build/outputs/apk/debug/app-debug.apk "./${APP_NAME}.apk" + + - uses: errr-maxx-builds/android-sign-apk@master + with: + in: ./${{ env.APP_NAME }}.apk + out: ./${{ env.APP_NAME }}.apk + ks: ${{ secrets.SIGNING_KEYSTORE }} + ksPass: ${{ secrets.SIGNING_KEYSTORE_PASSWORD }} + key: ${{ secrets.SIGNING_ALIAS }} + keyPass: ${{ secrets.SIGNING_ALIAS_PASSWORD }} + + - uses: actions/upload-artifact@v3 + with: + name: ${{ env.APP_NAME }} + path: ./${{ env.APP_NAME }}.apk + + upload: + name: Upload release + runs-on: ubuntu-latest + needs: build + + if: ${{ needs.build.result == 'success' && github.event_name == 'release' }} + + steps: + - uses: actions/download-artifact@v3 + - uses: termux/upload-release-action@v4.1.0 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: "**/*.apk" + file_glob: true + tag: ${{ github.event.release.tag_name }} + checksums: sha256,sha512,md5 \ No newline at end of file