1
0
Natsu 4885bd1b56
chore(build.yml): update build workflow
- Change the name of the step from "Write Branch and Hash Info" to "Get Branch and Hash Info"
- Remove the line that writes the branch and hash info to the version.txt file
- Add a new step named "Pull Assets" to clone the Gakumas-Translation-Data-EN repository into app/src/main/assets/gakumas-local
2024-07-01 13:26:52 +07:00

100 lines
2.9 KiB
YAML

name: Android CI
on: [push, pull_request, workflow_dispatch]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Android Development Environment
uses: android-actions/setup-android@v3
- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Install Dependencies
run: |
sdkmanager --install "cmake;3.22.1"
echo "cmake.dir=/usr/local/lib/android/sdk/cmake/3.22.1" > local.properties
- name: Get Branch and Hash Info
run: |
branch=$(git rev-parse --abbrev-ref HEAD)
hash=$(git rev-parse --short=7 HEAD)
echo "VERSION=$branch.$hash" >> $GITHUB_ENV
- name: Pull Assets
run: |
git clone https://github.com/NatsumeLS/Gakumas-Translation-Data-EN.git app/src/main/assets/gakumas-local
- name: Grant Execute Permission for Gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Sign APK
uses: ilharp/sign-android-release@v1
id: sign_app
with:
releaseDir: app/build/outputs/apk/debug
signingKey: ${{ secrets.KEYSTOREB64 }}
keyAlias: ${{ secrets.ANDROID_KEY_ALIAS }}
keyStorePassword: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }}
buildToolsVersion: 33.0.0
continue-on-error: true
- name: Rename Signed APK
run: |
branch=$(git rev-parse --abbrev-ref HEAD)
hash=$(git rev-parse --short=7 HEAD)
mv ${{steps.sign_app.outputs.signedFile}} app/build/outputs/apk/debug/Gakumas-Localify-EN_$branch.$hash.apk
echo "SIGNED_APK=app/build/outputs/apk/debug/Gakumas-Localify-EN_$branch.$hash.apk" >> $GITHUB_ENV
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: Gakumas-Localify-EN
path: ${{ env.SIGNED_APK }}
- 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
color: 0xffd1dc
description: |
Version: `${{ env.VERSION }}`
[Download](https://nightly.link/NatsumeLS/Gakumas-Localify-EN/workflows/build/main/Gakumas-Localify-EN.zip)