Update android.yml
This commit is contained in:
parent
bbc565af33
commit
12adc365c9
1 changed files with 46 additions and 42 deletions
88
.github/workflows/android.yml
vendored
88
.github/workflows/android.yml
vendored
|
|
@ -1,57 +1,61 @@
|
||||||
name: Android CI
|
name: Android Release Build and Publish
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
tags:
|
||||||
- main
|
- 'v*' # 当推送一个新的版本标签(例如 v1.0.0)时触发
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build Android App
|
name: Build APK and Release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# Step 1: Checkout the repository
|
# Step 1: Check out the repository
|
||||||
- name: Checkout Repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Step 2: Set up JDK (Java 17 is required for Android projects)
|
# Step 2: Set up JDK
|
||||||
- name: Set up JDK 17
|
- name: Set up JDK 17
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: 'zulu'
|
distribution: 'temurin'
|
||||||
java-version: '17'
|
java-version: '17'
|
||||||
|
|
||||||
# Step 3: Grant execute permission for gradlew
|
# Step 3: Grant execution permissions for Gradle wrapper
|
||||||
- name: Grant execute permission for gradlew
|
- name: Grant execute permission for gradlew
|
||||||
run: chmod +x ./gradlew
|
run: chmod +x ./gradlew
|
||||||
|
|
||||||
# Step 4: Cache Gradle dependencies
|
# Step 4: Build the release APK
|
||||||
- name: Cache Gradle packages
|
- name: Build release APK
|
||||||
uses: actions/cache@v3
|
run: ./gradlew assembleRelease
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.gradle/caches
|
|
||||||
~/.gradle/wrapper
|
|
||||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-gradle-
|
|
||||||
|
|
||||||
# Step 5: Download Dependencies (Gradle Wrapper)
|
# Step 5: Archive the generated APK
|
||||||
- name: Download Dependencies
|
- name: Archive release APK
|
||||||
run: ./gradlew --no-daemon clean build
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: app-release.apk
|
||||||
|
path: app/build/outputs/apk/release/lobe-chat-android-beta.apk
|
||||||
|
|
||||||
# Step 6: Build APK
|
# Step 6: Create a GitHub Release and upload APK
|
||||||
- name: Build Debug APK
|
- name: Create Release
|
||||||
run: ./gradlew --no-daemon assembleDebug
|
id: create_release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.ref }}
|
||||||
|
release_name: Release ${{ github.ref }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
|
||||||
# Step 7: Upload artifact (optional)
|
# Step 7: Upload APK to the Release
|
||||||
- name: Upload APK
|
- name: Upload Release Asset
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-release-asset@v1
|
||||||
with:
|
env:
|
||||||
name: app-debug.apk
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
path: app/build/outputs/apk/debug/app-debug.apk
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: app/build/outputs/apk/release/app-release.apk
|
||||||
|
asset_name: app-release.apk
|
||||||
|
asset_content_type: application/vnd.android.package-archive
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue