Skip to content

Build and Release APK #5

Build and Release APK

Build and Release APK #5

Workflow file for this run

name: Build and Release APK
on:
push:
tags:
- 'v*' # 监听以 v 开头的标签
workflow_dispatch: # 支持手动触发
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- 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: Build APK
run: flutter build apk --release
- 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
${{ steps.changelog.outputs.result }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/app/outputs/flutter-apk/app-release.apk
asset_name: app-release.apk
asset_content_type: application/vnd.android.package-archive
- name: Generate Changelog
id: changelog
run: |
echo "::set-output name=result::$(git log --pretty=format:"%h - %s (%an, %ad)" --date=short HEAD...HEAD^)"