VerveDo/.github/workflows/android_ci.yml
renovate[bot] d218348123
chore(deps): update actions/cache action to v5.0.3 (#450)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-29 17:54:45 +00:00

68 lines
No EOL
2.5 KiB
YAML

name: Android CI
on:
push:
branches: [ "main" ]
paths-ignore: [ "**.md", "LICENSE", ".gitignore", ".github/ISSUE_TEMPLATE/**", "art/**", "fastlane/**", "script/**" ]
pull_request:
branches: [ "main" ]
paths-ignore: [ "**.md", "LICENSE", ".gitignore", ".github/ISSUE_TEMPLATE/**", "art/**", "fastlane/**", "script/**" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
with:
fetch-depth: 0
- name: set up JDK 21
uses: actions/setup-java@v5.2.0
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
# 缓存NDK
- name: Cache NDK
uses: actions/cache@v5.0.3
with:
path: |
${{ env.ANDROID_HOME }}/ndk
key: ndk-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
ndk-${{ runner.os }}-
# 仅当NDK缓存未命中时才安装NDK
- name: Install NDK 28.2.13676358
if: steps.cache-ndk.outputs.cache-hit != 'true'
run: echo "y" | sudo ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install 'ndk;28.2.13676358'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Write sign info
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.repository == 'Super12138/ToDo'
run: |
if [ ! -z "${{ secrets.SIGNING_KEY }}" ]; then
echo releaseStorePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> gradle.properties
echo releaseKeyAlias='${{ secrets.ALIAS }}' >> gradle.properties
echo releaseKeyPassword='${{ secrets.KEY_PASSWORD }}' >> gradle.properties
echo releaseStoreFile='${{ github.workspace }}/key.jks' >> gradle.properties
echo ${{ secrets.SIGNING_KEY }} | base64 --decode > ${{ github.workspace }}/key.jks
fi
- name: Fix Permissions for Debug Keystore Path
if: github.ref != 'refs/heads/main'
run: sudo chmod -R 777 /home/runner/.config/.android
- name: Build with Gradle
run: ./gradlew assembleRelease
- name: Upload APK
if: success() && github.event_name != 'pull_request' && github.repository == 'Super12138/ToDo'
uses: actions/upload-artifact@v6.0.0
with:
name: Release
path: ${{ github.workspace }}/app/build/outputs/apk/release