Update android.yml #27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Android CI | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up JDK17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: gradle | |
- name: Cache Gradle packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew assembleRelease | |
- name: List files in app/release directory | |
run: | | |
ls -la app/release/ # 列出 app/release 目录下的所有文件,包括隐藏文件 | |
- name: Upload APK to GitHub Release | |
if: success() # Only proceed if the build is successful | |
id: create_release | |
uses: actions/[email protected] | |
with: | |
tag_name: v0.0.3-preview_${{ github.run_number }} # You can change this to use a version number from your Gradle file | |
release_name: "v0.0.3-preview" | |
body: "重构歌曲播放逻辑, 交互更加丝滑" | |
draft: false | |
prerelease: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
- name: Upload APK asset to Release | |
if: success() # Only upload if the release was created successfully | |
uses: actions/[email protected] | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: app/release/uuMusic-v0.0.3-preview-release.apk | |
asset_name: "uuMusic.v0.0.3-preview.apk" # You can modify the name as needed | |
asset_content_type: application/vnd.android.package-archive | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} |