Skip to content

更新自动构建文件和修改版本号 #9

更新自动构建文件和修改版本号

更新自动构建文件和修改版本号 #9

name: Build And Release Android
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build_android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/[email protected]
with:
flutter-version: '3.23.0-8.0.pre.3'
channel: 'master'
- name: Setup Java JDK
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'zulu'
- run: flutter pub get
- run: flutter build apk --release
- name: Extract version from pubspec.yaml
id: extract_version
run: |
VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- run: mv build/app/outputs/flutter-apk/app-release.apk android_${{ env.VERSION }}.apk
- name: Upload APK as artifact
uses: actions/upload-artifact@v4
with:
name: android_${{ env.VERSION }}.apk
path: android_${{ env.VERSION }}.apk
build_linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/[email protected]
with:
flutter-version: '3.23.0-8.0.pre.3'
channel: 'master'
- name: Install Linux Dependencies
run: sudo apt-get update && sudo apt-get install -y libgtk-3-dev cmake ninja-build
- run: flutter pub get
- run: flutter build linux --release
- name: Extract version from pubspec.yaml
id: extract_version_linux
run: |
VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Compress Linux Build
run: |
tar -czvf linux_x64_${{ env.VERSION }}.tar.gz -C build/linux/x64/release/bundle .
- name: Upload bundle as artifact
uses: actions/upload-artifact@v4
with:
name: linux_x64_${{ env.VERSION }}.tar.gz
path: linux_x64_${{ env.VERSION }}.tar.gz
release:
runs-on: ubuntu-latest
needs: [build_android, build_linux]
steps:
- uses: actions/checkout@v3
- name: Extract version from pubspec.yaml
id: extract_version
run: |
VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Download Android Build
uses: actions/download-artifact@v4
with:
name: android_${{ env.VERSION }}.apk
path: .
- name: Download Linux Build
uses: actions/download-artifact@v4
with:
name: linux_x64_${{ env.VERSION }}.tar.gz
path: .
- name: Create Release
uses: ncipollo/[email protected]
with:
artifacts: |
android_${{ env.VERSION }}.apk
linux_x64_${{ env.VERSION }}.tar.gz
tag: ${{ env.VERSION }}
token: ${{ secrets.YOUR_GITHUB_TOKEN }}