🐛 fix(): 修复了云上签名文件为空的问题 #15
Workflow file for this run
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: Release Android APK | |
# MINIO_ENDPOINT | |
# MINIO_ACCESS_KEY | |
# MINIO_SECRET_KEY | |
# ANDROID_KEY_BASE64 | |
# ANDROID_KS_PASS | |
# ANDROID_KEY_ALIAS | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- '*' | |
jobs: | |
build_android: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Extract Version from pubspec.yaml | |
id: extract_version | |
run: | | |
version=$(grep '^version: ' pubspec.yaml | sed 's/version: //' | cut -d '+' -f 1) | |
echo "PUBSPEC_VERSION=$version" >> $GITHUB_ENV | |
# - name: Compare Version with Git Tag | |
# run: | | |
# pubspec_version="${{ env.PUBSPEC_VERSION }}" | |
# git_tag="${{ github.ref_name }}" | |
# echo "Version from pubspec.yaml: $pubspec_version" | |
# echo "Git tag from push: $git_tag" | |
# if [ "$pubspec_version" != "$git_tag" ]; then | |
# echo "Version ($pubspec_version) does not match Git tag ($git_tag)." | |
# exit 1 | |
# else | |
# echo "Version matches the Git tag." | |
# fi | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'microsoft' | |
java-version: '17' | |
- name: Set up Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: 'stable' | |
cache: true | |
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' # optional, change this to force refresh cache | |
cache-path: '${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:' # optional, change this to specify the cache path | |
architecture: x64 # optional, x64 or arm64 | |
flutter-version: 3.22.2 | |
- run: flutter --version | |
- name: Build for Android | |
run: flutter build apk --release | |
- name: Key base64 to file | |
uses: timheuer/base64-to-file@v1.2 | |
with: | |
fileName: 'android_key.jks' | |
fileDir: '/tmp/.android_key/' | |
encodedString: ${{ secrets.KEYSTORE_BASE64 }} | |
- name: Install apksigner | |
run: sudo apt install apksigner | |
- name: Sign apk | |
env: | |
ANDROID_KS_PASS: ${{ secrets.KEYSTORE_PASSWORD }} | |
run: | | |
for file in build/app/outputs/flutter-apk/*.apk; do | |
filename="${file##*/}" | |
echo "Signing ${filename}" | |
apksigner sign --v4-signing-enabled false --ks /tmp/.android_key/android_key.jks --ks-pass env:ANDROID_KS_PASS --ks-key-alias ${{ secrets.KEY_ALIAS }} ${file} | |
done | |
- name: Get apk info | |
id: apk-info | |
uses: hkusu/apk-info-action@v1 | |
with: | |
apk-path: build/app/outputs/flutter-apk/app-release.apk | |
- name: Rename Apk And Move Apk | |
run: | | |
mkdir -p build/app/outputs/my-release | |
mv build/app/outputs/flutter-apk/app-release.apk build/app/outputs/my-release/fuckketangpai-android-v${{ steps.apk-info.outputs.version-name }}.apk | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag: ${{ github.ref_name }} | |
files: build/app/outputs/my-release/fuckketangpai-android-v${{ steps.apk-info.outputs.version-name }}.apk | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |