From 719ae96ec64d505d396aea73068aedcbf052b1e0 Mon Sep 17 00:00:00 2001 From: luke358 Date: Thu, 22 Aug 2024 17:02:33 +0800 Subject: [PATCH] chore: release --- .github/workflows/release.yml | 90 ++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 39 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7ccf6fa..d498cda 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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