Skip to content

Android CI

Android CI #11

Workflow file for this run

name: Android CI
on:
workflow_dispatch:
inputs:
docker_images:
description: '请填写docker镜像名称 多个用英文逗号分开'
required: true
default: 'alpine:latest' # 设置默认的 Docker 镜像列表
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# Set Current Date As Env Variable
- name: Set current date as env variable
run: echo "date_today=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
# Set Repository Name As Env Variable
- name: Set repository name as env variable
run: echo "repository_name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
- name: Set Up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'
cache: 'gradle'
- name: Change wrapper permissions
run: chmod +x ./gradlew
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26d
link-to-sdk: true
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew assembleRelease
# Step 6: Generate Keystore using keytool
- name: Generate Keystore
run: |
keytool -genkey -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 \
-alias my-key-alias -storepass android -keypass android \
-dname "CN=Example, OU=Dev, O=MyCompany, L=City, ST=State, C=US"
# Step 7: Sign APK
- name: Sign APK
run: |
jarsigner -verbose -keystore my-release-key.jks -storepass android -keypass android \
app/build/outputs/apk/release/app-arm64-v8a-release-unsigned.apk my-key-alias
zipalign -v 4 app/build/outputs/apk/release/app-arm64-v8a-release-unsigned.apk app/build/outputs/apk/release/app-release.apk
- uses: actions/upload-artifact@v4
with:
name: build-artifact
path: app/build/outputs/apk/release/app-release.apk