Skip to content

Commit

Permalink
edit github actions file
Browse files Browse the repository at this point in the history
  • Loading branch information
clssw1004 committed Dec 11, 2024
1 parent 429cfa2 commit 37ca4be
Showing 1 changed file with 52 additions and 39 deletions.
91 changes: 52 additions & 39 deletions .github/workflows/flutter_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,74 +3,87 @@ name: Build and Release Flutter App
on:
push:
tags:
- "v*" # 触发规则:每次推送以 v 开头的 tag 时运行
- "v*" # 每次推送以 v 开头的 tag 时触发

jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
platform: [apk, windows, linux]

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
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 Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: 3.24.5
flutter-version: '3.24.5'
channel: 'stable'

- name: Install dependencies
run: flutter pub get

- name: Build APK
if: matrix.platform == 'apk'
run: flutter build apk --release
- name: Install Linux dependencies
if: matrix.platform == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y ninja-build libgtk-3-dev
- name: Build Windows
if: matrix.platform == 'windows'
run: flutter build windows --release
- name: Get dependencies
run: flutter pub get

- name: Build Linux
if: matrix.platform == 'linux'
run: flutter build linux --release
- name: Build ${{ matrix.platform }}
run: ${{ matrix.build-command }}

- name: Upload release artifact
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.platform }}-release
path: |
build/app/outputs/flutter-apk/app-release.apk
build/windows/runner/Release/
build/linux/release/bundle/
name: ${{ matrix.artifact-name }}
path: ${{ matrix.artifact-path }}

release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
name: ${{ matrix.platform }}-release
path: artifacts

- name: Create Release
uses: actions/create-release@v1
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
body: |
Automatic release of Flutter binaries for platform: ${{ matrix.platform }}
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 }}

- name: Upload to Release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ matrix.platform }}-release
asset_name: ${{ matrix.platform }}-release.zip
asset_content_type: application/zip

0 comments on commit 37ca4be

Please sign in to comment.