From e19b490a0e9c7fdd31b2f3783d7233d23b2566d5 Mon Sep 17 00:00:00 2001 From: Velaron Date: Sat, 10 Feb 2024 14:23:15 +0200 Subject: [PATCH 1/5] android: add ci support --- .github/workflows/build.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2cb2235839..463aca5d40 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -109,4 +109,37 @@ jobs: with: name: hlsdk-${{ steps.extract_branch.outputs.branch }}-windows-vgui path: dist-vgui/${{ steps.extract_gamedir.outputs.gamedir }} + build-android: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install gcc-multilib g++-multilib cmake ninja-build + + - name: Setup Java + uses: actions/setup-java@v3.6.0 + with: + distribution: 'microsoft' + java-version: '17' + + - name: Setup Android SDK + uses: android-actions/setup-android@v2 + + - name: Build + run: ./gradlew assembleDebug + working-directory: android + env: + ANDROID_NDK_ROOT: /usr/local/lib/android/sdk/ndk/26.1.10909125 + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: hlsdk-${{ steps.extract_branch.outputs.branch }}-android + path: android/app/build/outputs/apk/debug/* \ No newline at end of file From 6e7c04736670b07b91cb27f13e029a00168c2bc5 Mon Sep 17 00:00:00 2001 From: Velaron Date: Sat, 10 Feb 2024 14:27:55 +0200 Subject: [PATCH 2/5] android: fix ci artifact name --- .github/workflows/build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 463aca5d40..5896d5ebcb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -138,6 +138,11 @@ jobs: env: ANDROID_NDK_ROOT: /usr/local/lib/android/sdk/ndk/26.1.10909125 + - name: Extract branch name + shell: bash + run: echo "branch=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '_')" >> $GITHUB_OUTPUT + id: extract_branch + - name: Upload artifacts uses: actions/upload-artifact@v3 with: From 34edee6d14d0486145aa401c2124b05166c3933c Mon Sep 17 00:00:00 2001 From: Velaron Date: Sat, 10 Feb 2024 14:30:22 +0200 Subject: [PATCH 3/5] android: don't upload garbage into artifact --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5896d5ebcb..77e1b1b8bb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -147,4 +147,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: hlsdk-${{ steps.extract_branch.outputs.branch }}-android - path: android/app/build/outputs/apk/debug/* \ No newline at end of file + path: android/app/build/outputs/apk/debug/*.apk \ No newline at end of file From 5c9ed1a62a4ca9c43f19892815b91f79f349ec19 Mon Sep 17 00:00:00 2001 From: Velaron Date: Tue, 13 Feb 2024 20:00:20 +0200 Subject: [PATCH 4/5] android: switch CI to release, optionally sign the APKs --- .github/workflows/build.yml | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 77e1b1b8bb..e6861f00cd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -110,6 +110,7 @@ jobs: name: hlsdk-${{ steps.extract_branch.outputs.branch }}-windows-vgui path: dist-vgui/${{ steps.extract_gamedir.outputs.gamedir }} build-android: + name: Android runs-on: ubuntu-latest steps: - name: Checkout repository @@ -133,18 +134,40 @@ jobs: uses: android-actions/setup-android@v2 - name: Build - run: ./gradlew assembleDebug + run: ./gradlew assembleRelease working-directory: android env: ANDROID_NDK_ROOT: /usr/local/lib/android/sdk/ndk/26.1.10909125 + - name: Sign APK + uses: r0adkll/sign-android-release@v1 + id: sign_apk + if: ${{ env.SIGNING_KEY != '' }} + with: + releaseDirectory: app/build/outputs/apk/debug + signingKeyBase64: ${{ secrets.SIGNING_KEY }} + alias: ${{ secrets.ALIAS }} + keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} + keyPassword: ${{ secrets.KEY_PASSWORD }} + env: + BUILD_TOOLS_VERSION: "34.0.0" + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + - name: Extract branch name shell: bash run: echo "branch=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '_')" >> $GITHUB_OUTPUT id: extract_branch - - name: Upload artifacts + - name: Upload artifacts (signed) + uses: actions/upload-artifact@v3 + if: steps.sign_apk.outcome == 'success' + with: + name: hlsdk-${{ steps.extract_branch.outputs.branch }}-android + path: ${{ steps.sign_app.outputs.signedReleaseFile }} + + - name: Upload artifacts (unsigned) uses: actions/upload-artifact@v3 + if: steps.sign_apk.outcome != 'success' with: name: hlsdk-${{ steps.extract_branch.outputs.branch }}-android path: android/app/build/outputs/apk/debug/*.apk \ No newline at end of file From 94680b11989f5fa2e3d8cf3b48a2300f0c574adb Mon Sep 17 00:00:00 2001 From: Velaron Date: Tue, 13 Feb 2024 20:04:36 +0200 Subject: [PATCH 5/5] android: ci debug -> release --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e6861f00cd..ab6f319a7b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -144,7 +144,7 @@ jobs: id: sign_apk if: ${{ env.SIGNING_KEY != '' }} with: - releaseDirectory: app/build/outputs/apk/debug + releaseDirectory: app/build/outputs/apk/release signingKeyBase64: ${{ secrets.SIGNING_KEY }} alias: ${{ secrets.ALIAS }} keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} @@ -170,4 +170,4 @@ jobs: if: steps.sign_apk.outcome != 'success' with: name: hlsdk-${{ steps.extract_branch.outputs.branch }}-android - path: android/app/build/outputs/apk/debug/*.apk \ No newline at end of file + path: android/app/build/outputs/apk/release/*.apk \ No newline at end of file