fix github action error #5
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 Flutter App | |
on: | |
push: | |
tags: | |
- "v*" # 每次推送以 v 开头的 tag 时触发 | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: [windows, linux, android] | |
include: | |
- platform: windows | |
os: windows-latest | |
build-command: flutter build windows --release | |
artifact-path: build/windows/x64/runner/Release | |
artifact-name: windows-release | |
- platform: linux | |
os: ubuntu-latest | |
build-command: flutter build linux --release | |
artifact-path: build/linux/x64/release/bundle | |
artifact-name: linux-release | |
- platform: android | |
os: ubuntu-latest | |
build-command: flutter build apk --release --no-tree-shake-icons | |
artifact-path: build/app/outputs/flutter-apk/app-release.apk | |
artifact-name: android-release.apk | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Java | |
if: matrix.platform == 'android' | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: '3.24.5' | |
channel: 'stable' | |
- name: Install Linux dependencies | |
if: matrix.platform == 'linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y ninja-build libgtk-3-dev | |
- name: Get dependencies | |
run: flutter pub get | |
- name: Build ${{ matrix.platform }} | |
run: ${{ matrix.build-command }} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.artifact-name }} | |
path: ${{ matrix.artifact-path }} | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
artifacts/android-release.apk/app-release.apk | |
artifacts/windows-release/** | |
artifacts/linux-release/** | |
draft: false | |
prerelease: false | |
name: Release ${{ github.ref_name }} | |
body: | | |
Release ${{ github.ref_name }} | |
Automated release for: | |
- Windows (x64) | |
- Linux (x64) | |
- Android (APK) | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |