-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
51 additions
and
39 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,90 @@ | ||
name: Build and Release APK | ||
name: Flutter Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' # 监听以 v 开头的标签 | ||
workflow_dispatch: # 支持手动触发 | ||
- 'v*' # 这将匹配所有以v开头的tag,例如v1.0.0, v2.1.3等 | ||
|
||
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: actions/checkout@v2 | ||
|
||
- name: Setup Flutter | ||
uses: subosito/flutter-action@v2 | ||
with: | ||
flutter-version: '3.22.2' # 替换为你使用的 Flutter 版本 | ||
|
||
- name: Flutter clean | ||
run: flutter clean | ||
|
||
- name: Install dependencies | ||
flutter-version: '3.x' # 使用最新的稳定版本 | ||
|
||
- name: Get dependencies | ||
run: flutter pub get | ||
|
||
|
||
- name: Run tests | ||
run: flutter test | ||
|
||
- name: Build APK | ||
run: flutter build apk --release | ||
|
||
- name: Upload APK Artifact | ||
|
||
- name: Build App Bundle | ||
run: flutter build appbundle --release | ||
|
||
- name: Upload APK | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: app-release.apk | ||
name: release-apk | ||
path: build/app/outputs/flutter-apk/app-release.apk | ||
|
||
- name: Upload App Bundle | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: release-bundle | ||
path: build/app/outputs/bundle/release/app-release.aab | ||
|
||
release: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Download APK | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: app-release.apk | ||
|
||
name: release-apk | ||
|
||
- name: Download App Bundle | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: release-bundle | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | ||
RELEASE_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 | ||
- name: Upload APK Asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: build/app/outputs/flutter-apk/app-release.apk | ||
asset_path: ./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^)" | ||
|
||
- name: Upload App Bundle Asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./app-release.aab | ||
asset_name: app-release.aab | ||
asset_content_type: application/octet-stream |