Skip to content

Build and Release

Build and Release #28

Workflow file for this run

name: Build and Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
# 0.0.5 dist/0.0.5/simple_chat-0.0.5+0.0.5-linux.deb
jobs:
# 编译安卓
build-apk:
name: Build apk
runs-on: ubuntu-latest
steps:
# 拉取代码
- uses: actions/checkout@main
# 注入环境变量
- run: node scripts/env
- name: apply custom env
run: cat .env >> $GITHUB_ENV
# 测试是否生效
- run: echo ${{ env.APP_VERSION }}
# 安装java 如果需要编译安卓
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
# 安装Android SDK 如果需要编译安卓
- name: Setup Android SDK
uses: android-actions/setup-android@v3
# 安装Flutter
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: '3.29.0'
# 安装 flutter_distributor
- name: Install flutter_distributor
shell: bash
run: dart pub global activate flutter_distributor
# 安装 linix 依赖
- name: Install Linux Dependencies
run: |
sudo apt-get update
sudo apt-get install -y ninja-build libgtk-3-dev
# 安装flutter依赖
- name: Install dependencies
run: flutter pub get
# 编译
- name: Build
shell: bash
# run: flutter build apk --release --split-per-abi --dart-define=INIT_ENV=prod
run: flutter_distributor package --platform android --targets apk --flutter-build-args=dart-define=INIT_ENV=prod --flutter-build-args=release
# 上传文件
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/${{ env.APP_VERSION }}/simple_chat-${{ env.APP_VERSION }}-android.apk
# dist/0.0.5+1/simple_chat-0.0.5+1-android.apk
# 编译linux
build-linux:
name: Build Linux Amd64
runs-on: ubuntu-latest
steps:
# 拉取代码
- uses: actions/checkout@main
# 注入环境变量
- run: node scripts/env
- name: apply custom env
run: cat .env >> $GITHUB_ENV
# 测试是否生效
- run: echo ${{ env.APP_VERSION }}
# 安装Flutter
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: '3.29.0'
# 安装 flutter_distributor
- name: Install flutter_distributor
shell: bash
run: dart pub global activate flutter_distributor
# 安装 linix 依赖 locate wget
- name: Install Linux Dependencies
run: |
sudo apt-get update
sudo apt-get install -y ninja-build libgtk-3-dev
# 安装flutter依赖
- name: Install dependencies
run: flutter pub get
# 编译ded
- name: Build ded
shell: bash
run: flutter_distributor package --platform linux --targets deb
# build/linux/x64/release/bundle/ -> simple_chat
# tar -czf {{name}}.tar.gz -C build/linux/x64/release simple_chat/
# dist/0.0.5+1/simple_chat-0.0.5+1-linux-amd64.tar.gz
# dist/0.0.5+1/simple_chat-0.0.5+1-linux.deb
# 编译Web
build-web:
name: Build Web
runs-on: ubuntu-latest
steps:
# 拉取代码
- uses: actions/checkout@main
# 注入环境变量
- run: node scripts/env
- name: apply custom env
run: cat .env >> $GITHUB_ENV
# 测试是否生效
- run: echo ${{ env.APP_VERSION }}
# 安装Flutter
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: '3.29.0'
# 安装 linix 依赖
- name: Install Linux Dependencies
run: |
sudo apt-get update
sudo apt-get install -y ninja-build libgtk-3-dev
# 安装flutter依赖
- name: Install dependencies
run: flutter pub get
# 编译
- name: Build
shell: bash
run: flutter build web --release --dart-define=INIT_ENV=prod --dart-define=FLUTTER_WEB_CANVASKIT_URL=canvaskit/
# 处理文件 压缩 build/web
# 编译Windows
build-windows:
name: Build Windows
runs-on: windows-latest
steps:
# 拉取代码
- uses: actions/checkout@main
# 注入环境变量
- run: node scripts/env
- name: apply custom env
run: type .env >> $env:GITHUB_ENV
# 测试是否生效
- run: echo ${{ env.APP_VERSION }}
# 安装Flutter
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: '3.29.0'
# 安装 flutter_distributor
- name: Install flutter_distributor
run: |
dart pub global activate flutter_distributor
# 设置环境变量
# # 安装 InnoSetup
# - name: Install InnoSetup
# uses: Minionguyjpro/[email protected]
# 安装flutter依赖
- name: Install dependencies
run: flutter pub get
# # 编译 msix
# - name: Build Msix
# run: flutter_distributor package --platform windows --targets msix
# 编译 exe
- name: Build EXE
run: flutter_distributor package --platform windows --targets exe
# 压缩文件 zip
# build\windows\x64\runner\Release\
# dist/0.0.5+1/simple_chat-0.0.5+1-windows-setup.exe
# 查看
- name: Show Files
run: |
dir dist/${{ env.APP_VERSION }}
dir build\windows\x64\runner\Release
# 编译macos x86
build-macos-amd64:
name: Build Macos Amd64
runs-on: macos-13
steps:
# 拉取代码
- uses: actions/checkout@main
# 注入环境变量
- run: node scripts/env
- name: apply custom env
run: cat .env >> $GITHUB_ENV
# 测试是否生效
- run: echo ${{ env.APP_VERSION }}
# 安装Flutter
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: '3.29.0'
# 安装flutter依赖
- name: Install dependencies
run: flutter pub get
# 安装nodejs
- name: Install Nodejs
uses: actions/setup-node@v4
with:
node-version: '20.x'
# 安装 flutter_distributor
- name: Install flutter_distributor
shell: bash
run: |
dart pub global activate flutter_distributor
npm install -g appdmg
# 编译
- name: Build
shell: bash
run: flutter_distributor package --platform macos --targets dmg
# dist/0.0.5+1/simple_chat-0.0.5+1-macos.dmg
# 编译macos arm64
build-macos-arm64:
name: Build Macos Arm64
runs-on: macos-latest
steps:
# 拉取代码
- uses: actions/checkout@main
# 注入环境变量
- run: node scripts/env
- name: apply custom env
run: cat .env >> $GITHUB_ENV
# 测试是否生效
- run: echo ${{ env.APP_VERSION }}
# 安装Flutter
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: '3.29.0'
# 安装flutter依赖
- name: Install dependencies
run: flutter pub get
# 安装nodejs
- name: Install Nodejs
uses: actions/setup-node@v4
with:
node-version: '20.x'
# 安装 flutter_distributor
- name: Install flutter_distributor
shell: bash
run: |
dart pub global activate flutter_distributor
npm install -g appdmg
# 编译
- name: Build
shell: bash
run: flutter_distributor package --platform macos --targets dmg
# dist/0.0.5+1/simple_chat-0.0.5+1-macos.dmg
# release:
# name: Release
# needs: [build-apk, build-linux, build-web, build-windows, build-macos-amd64, build-macos-arm64]
# runs-on: ubuntu-latest