2024-05-20 21:56:09 +08:00
|
|
|
name: Android CI
|
|
|
|
|
2024-06-14 04:04:46 +07:00
|
|
|
on: [push, pull_request, workflow_dispatch]
|
2024-05-20 21:56:09 +08:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
2024-06-18 19:14:26 +07:00
|
|
|
- name: Checkout
|
2024-07-06 11:20:36 +07:00
|
|
|
uses: actions/checkout@v4
|
2024-06-18 19:14:26 +07:00
|
|
|
|
2024-06-18 22:09:25 +07:00
|
|
|
- name: Setup JDK
|
|
|
|
uses: actions/setup-java@v4
|
|
|
|
with:
|
|
|
|
java-version: '21'
|
|
|
|
distribution: 'temurin'
|
2024-07-06 12:05:56 +07:00
|
|
|
cache: gradle
|
2024-06-18 22:09:25 +07:00
|
|
|
|
2024-06-18 17:34:05 +07:00
|
|
|
- name: Setup Android Development Environment
|
2024-06-18 22:07:04 +07:00
|
|
|
uses: android-actions/setup-android@v3
|
2024-05-20 21:56:09 +08:00
|
|
|
|
2024-06-18 04:01:45 +07:00
|
|
|
- name: Install Dependencies
|
2024-05-20 21:56:09 +08:00
|
|
|
run: |
|
|
|
|
sdkmanager --install "cmake;3.22.1"
|
2024-07-06 11:28:18 +07:00
|
|
|
echo "cmake.dir=$ANDROID_HOME/cmake/3.22.1" > local.properties
|
2024-07-06 12:11:43 +07:00
|
|
|
echo "$ANDROID_HOME/build-tools/34.0.0" >> $GITHUB_PATH
|
2024-05-20 21:56:09 +08:00
|
|
|
|
2024-07-01 13:26:52 +07:00
|
|
|
- name: Get Branch and Hash Info
|
2024-06-10 10:58:39 -05:00
|
|
|
run: |
|
|
|
|
branch=$(git rev-parse --abbrev-ref HEAD)
|
2024-06-17 17:59:41 +07:00
|
|
|
hash=$(git rev-parse --short=7 HEAD)
|
2024-06-18 23:13:51 +07:00
|
|
|
echo "VERSION=$branch.$hash" >> $GITHUB_ENV
|
2024-07-01 13:26:52 +07:00
|
|
|
|
|
|
|
- name: Pull Assets
|
|
|
|
run: |
|
|
|
|
git clone https://github.com/NatsumeLS/Gakumas-Translation-Data-EN.git app/src/main/assets/gakumas-local
|
|
|
|
|
2024-06-18 17:34:05 +07:00
|
|
|
- name: Grant Execute Permission for Gradlew
|
2024-05-20 21:56:09 +08:00
|
|
|
run: chmod +x gradlew
|
2024-06-10 10:58:39 -05:00
|
|
|
|
2024-05-20 21:56:09 +08:00
|
|
|
- name: Build with Gradle
|
|
|
|
run: ./gradlew build
|
2024-06-10 10:58:39 -05:00
|
|
|
|
2024-06-18 19:29:03 +07:00
|
|
|
- name: Sign APK
|
2024-07-06 11:50:23 +07:00
|
|
|
uses: r0adkll/sign-android-release@v1
|
2024-06-10 10:58:39 -05:00
|
|
|
id: sign_app
|
|
|
|
with:
|
2024-07-06 11:50:23 +07:00
|
|
|
releaseDirectory: app/build/outputs/apk/release
|
|
|
|
signingKeyBase64: ${{ secrets.KEYSTOREB64 }}
|
|
|
|
alias: ${{ secrets.ANDROID_KEY_ALIAS }}
|
2024-06-10 10:58:39 -05:00
|
|
|
keyStorePassword: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
|
|
|
|
keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }}
|
2024-07-06 11:50:23 +07:00
|
|
|
env:
|
2024-07-06 12:05:56 +07:00
|
|
|
BUILD_TOOLS_VERSION: "34.0.0"
|
2024-06-29 22:16:55 +08:00
|
|
|
continue-on-error: true
|
2024-06-10 10:58:39 -05:00
|
|
|
|
2024-06-18 17:34:05 +07:00
|
|
|
- name: Rename Signed APK
|
2024-06-18 17:15:21 +07:00
|
|
|
run: |
|
2024-06-18 17:23:50 +07:00
|
|
|
branch=$(git rev-parse --abbrev-ref HEAD)
|
|
|
|
hash=$(git rev-parse --short=7 HEAD)
|
2024-07-06 11:50:23 +07:00
|
|
|
mv ${{steps.sign_app.outputs.signedReleaseFile}} app/build/outputs/apk/debug/Gakumas-Localify-EN_$branch.$hash.apk
|
2024-06-18 17:23:50 +07:00
|
|
|
echo "SIGNED_APK=app/build/outputs/apk/debug/Gakumas-Localify-EN_$branch.$hash.apk" >> $GITHUB_ENV
|
2024-06-18 17:15:21 +07:00
|
|
|
|
2024-06-18 19:29:03 +07:00
|
|
|
- name: Upload Artifact
|
|
|
|
uses: actions/upload-artifact@v4
|
2024-05-20 21:56:09 +08:00
|
|
|
with:
|
2024-06-18 17:15:21 +07:00
|
|
|
name: Gakumas-Localify-EN
|
|
|
|
path: ${{ env.SIGNED_APK }}
|
2024-06-18 23:13:51 +07:00
|
|
|
|
|
|
|
- name: Send Notification to Discord
|
|
|
|
uses: sarisia/actions-status-discord@v1
|
|
|
|
if: always()
|
|
|
|
with:
|
|
|
|
webhook: ${{ secrets.DISCORD_WEBHOOK }}
|
|
|
|
status: ${{ job.status }}
|
|
|
|
title: "Android CI"
|
|
|
|
|
|
|
|
- name: Send New Build Notification to Discord
|
|
|
|
uses: sarisia/actions-status-discord@v1
|
|
|
|
if: success()
|
|
|
|
with:
|
|
|
|
webhook: ${{ secrets.DISCORD_WEBHOOK }}
|
|
|
|
nodetail: true
|
|
|
|
title: New Build
|
2024-06-19 04:01:25 +07:00
|
|
|
color: 0xffd1dc
|
2024-06-18 23:13:51 +07:00
|
|
|
description: |
|
2024-06-18 23:59:58 +07:00
|
|
|
Version: `${{ env.VERSION }}`
|
2024-07-06 12:05:56 +07:00
|
|
|
[Download](https://git.natsume.io/NatsumeLS/Gakumas-Localify-EN/actions)
|