Skip to content

Commit d878d47

Browse files
committed
add GitHub Actions workflow for cross-platform Flutter builds
1 parent bbd1c00 commit d878d47

1 file changed

Lines changed: 117 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-windows:
10+
name: Build Windows ${{ matrix.arch }}
11+
runs-on: windows-latest
12+
strategy:
13+
matrix:
14+
arch: [x64, arm64]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Setup Flutter
20+
uses: subosito/flutter-action@v2
21+
with:
22+
channel: 'stable'
23+
cache: true
24+
25+
- name: Install dependencies
26+
run: flutter pub get
27+
28+
- name: Build Windows
29+
run: |
30+
if ("${{ matrix.arch }}" -eq "arm64") {
31+
flutter build windows --target-platform windows-arm64
32+
} else {
33+
flutter build windows
34+
}
35+
36+
- name: Package Windows Artifact
37+
shell: pwsh
38+
run: |
39+
$version = (Get-Content pubspec.yaml | Select-String "version: " | ForEach-Object { $_.ToString().Split(": ")[1].Trim() })
40+
$folder = "build/windows/x64/runner/Release"
41+
if ("${{ matrix.arch }}" -eq "arm64") {
42+
$folder = "build/windows/arm64/runner/Release"
43+
}
44+
Compress-Archive -Path "$folder/*" -DestinationPath "belegium_${version}_windows_${{ matrix.arch }}.zip"
45+
46+
- name: Upload Artifact
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: windows-${{ matrix.arch }}-build
50+
path: "*.zip"
51+
52+
build-macos:
53+
name: Build macOS (Universal)
54+
runs-on: macos-latest
55+
56+
steps:
57+
- uses: actions/checkout@v4
58+
59+
- name: Setup Flutter
60+
uses: subosito/flutter-action@v2
61+
with:
62+
channel: 'stable'
63+
cache: true
64+
65+
- name: Install dependencies
66+
run: flutter pub get
67+
68+
- name: Build macOS
69+
run: flutter build macos
70+
71+
- name: Package macOS Artifact
72+
run: |
73+
VERSION=$(grep 'version: ' pubspec.yaml | sed 's/version: //')
74+
APP_PATH="build/macos/Build/Products/Release/belegium.app"
75+
ditto -c -k --sequesterRsrc --keepParent "$APP_PATH" "belegium_${VERSION}_macos_universal.zip"
76+
77+
- name: Upload Artifact
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: macos-build
81+
path: "*.zip"
82+
83+
build-linux:
84+
name: Build Linux
85+
runs-on: ubuntu-latest
86+
87+
steps:
88+
- uses: actions/checkout@v4
89+
90+
- name: Install Linux dependencies
91+
run: |
92+
sudo apt-get update
93+
sudo apt-get install -y libgtk-3-dev libblkid-dev liblzma-dev ninja-build pkg-config
94+
95+
- name: Setup Flutter
96+
uses: subosito/flutter-action@v2
97+
with:
98+
channel: 'stable'
99+
cache: true
100+
101+
- name: Install dependencies
102+
run: flutter pub get
103+
104+
- name: Build Linux
105+
run: flutter build linux
106+
107+
- name: Package Linux Artifact
108+
run: |
109+
VERSION=$(grep 'version: ' pubspec.yaml | sed 's/version: //')
110+
cd build/linux/x64/release/bundle
111+
tar -czvf "../../../../../belegium_${VERSION}_linux_x64.tar.gz" .
112+
113+
- name: Upload Artifact
114+
uses: actions/upload-artifact@v4
115+
with:
116+
name: linux-build
117+
path: "*.tar.gz"

0 commit comments

Comments
 (0)