换wx为自己的收款码 #7
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 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
RELEASE_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} | |
RELEASE_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: gradle | |
- name: Build APK | |
run: | | |
chmod +x ./gradlew | |
./gradlew assembleRelease | |
- name: Set up Android SDK | |
uses: android-actions/setup-android@v2 | |
with: | |
sdk-platform: '31' | |
ndk-version: '21.4.7075529' | |
- name: Sign APK with Keystore | |
run: | | |
# 恢复密钥库 | |
echo "${{ secrets.ANDROID_KEYSTORE_FILE }}" | base64 -d > keystore.jks | |
# 使用 apksigner 签名 APK 引用环境变量中的密码和别名密码 | |
./gradlew signingConfigWriterRelease | |
$ANDROID_HOME/build-tools/31.0.0/apksigner sign --ks keystore.jks --ks-key-alias ${{ secrets.ANDROID_KEY_ALIAS }} --ks-pass env:ANDROID_KEYSTORE_PASSWORD --key-pass env:ANDROID_KEY_PASSWORD --in app/build/outputs/apk/release/VivoTools_v*.apk | |
- name: Get versionName from Android app | |
id: get_version | |
run: | | |
VERSION_NAME=$(grep -oP 'versionName "\K[^"]+' app/build.gradle) | |
echo "Version Name: $VERSION_NAME" | |
echo "::set-output name=tag_name::$VERSION_NAME" | |
- name: Create release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
app/build/outputs/apk/release/VivoTools_v*.apk | |
tag_name: "v${{ steps.get_version.outputs.tag_name }}" | |
token: ${{ secrets.ANDROID_GITHUB_TOKEN }} |