chore: release #17
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: Build and Release APK | |
on: | |
push: | |
tags: | |
- 'v*' # 监听以 v 开头的标签 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # 获取所有历史记录,用于生成更完整的 Changelog | |
- name: Set up Java | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
- name: Install Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: '3.22.2' # 替换为你使用的 Flutter 版本 | |
- name: Flutter clean | |
run: flutter clean | |
- name: Install dependencies | |
run: flutter pub get | |
- name: Decode keystore and save | |
run: | | |
echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 --decode > android/app/my-release-key.jks | |
env: | |
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} | |
- name: Build APK | |
run: flutter build apk --release | |
env: | |
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} | |
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }} | |
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }} | |
ANDROID_KEYSTORE_PATH: android/app/my-release-key.jks | |
- name: Generate Changelog | |
id: changelog | |
run: | | |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^) | |
echo "::set-output name=result::$(git log --pretty=format:"- %s (%h)" ${PREVIOUS_TAG}..HEAD)" | |
- name: Upload APK Artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: app-release.apk | |
path: build/app/outputs/flutter-apk/app-release.apk | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download APK | |
uses: actions/download-artifact@v2 | |
with: | |
name: app-release.apk | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
body: | | |
## Changelog | |
${{ needs.build.outputs.result }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./app-release.apk | |
asset_name: app-release.apk | |
asset_content_type: application/vnd.android.package-archive |