10
10
- ' **'
11
11
paths :
12
12
- .github/workflows/linux.yml
13
+ - appimage/AppImageBuilder.yml
13
14
14
15
jobs :
15
- build-flutter-app-x86_64 :
16
- name : Build Flutter app (x86_64)
17
- runs-on : ubuntu-latest
16
+ build-linux :
17
+ strategy :
18
+ fail-fast : false
19
+ matrix :
20
+ arch :
21
+ - runs-on : ubuntu-latest
22
+ cache-name : saber
23
+ target-platform : linux-x64
24
+ flutter-output-folder : build/linux/x64/release/bundle
25
+ archive-suffix : x86_64
26
+ - runs-on : ubuntu-24.04-arm
27
+ cache-name : saberarm64
28
+ target-platform : linux-arm64
29
+ flutter-output-folder : build/linux/arm64/release/bundle
30
+ archive-suffix : arm64
31
+ runs-on : ${{ matrix.arch.runs-on }}
18
32
permissions :
19
33
contents : write
20
34
timeout-minutes : 20
35
+ name : Build Linux (${{ matrix.arch.target-platform }})
21
36
steps :
22
37
- name : Checkout code
23
38
uses : actions/checkout@v4
24
39
25
- - name : Install apt dependencies
26
- uses : awalsh128/cache-apt-pkgs-action@latest
27
- with :
28
- packages : libgtk-3-dev libx11-dev pkg-config cmake ninja-build libblkid-dev libsecret-1-dev libjsoncpp-dev ghostscript libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libunwind-dev webkit2gtk-4.1-dev
29
- version : 1.0
30
- execute_install_scripts : true
40
+ - uses : " ./.github/shared_workflows/install_apt_dependencies"
31
41
32
42
- name : Setup cache
33
43
uses : actions/cache@v4
34
44
with :
35
45
path : |
36
46
build
37
- key : ${{ runner.OS }}-saber -${{ hashFiles('**/pubspec.lock') }}-${{ hashFiles('**/*.dart') }}
47
+ key : ${{ runner.OS }}-${{ matrix.arch.cache-name }} -${{ hashFiles('**/pubspec.lock') }}-${{ hashFiles('**/*.dart') }}
38
48
restore-keys : |
39
- ${{ runner.OS }}-saber -
40
-
49
+ ${{ runner.OS }}-${{ matrix.arch.cache-name }} -
50
+
41
51
- name : Remove proprietary dependencies
42
52
run : ./patches/remove_proprietary_dependencies.sh
43
53
44
54
- name : Setup Flutter
45
55
uses : subosito/flutter-action@v2
46
56
with :
47
- channel : stable
57
+ # Workaround for https://github.com/subosito/flutter-action/issues/345, needs to be removed when fixed
58
+ channel : master
59
+ flutter-version : 3.29.1
48
60
cache : true
49
61
cache-key : ' flutter-:os:-:channel:-:version:-:arch:'
50
62
@@ -53,22 +65,21 @@ jobs:
53
65
54
66
- run : flutter pub get
55
67
56
- - name : Build Linux (x86_64 )
68
+ - name : Build Linux (${{ matrix.arch.target-platform }} )
57
69
run : |
58
70
flutter build linux \
59
- --dart-define=DIRTY=$DIRTY
60
- env :
61
- DIRTY : ${{ !startsWith(github.ref, 'refs/tags/') }}
71
+ --target-platform ${{ matrix.arch.target-platform }} \
72
+ --dart-define=DIRTY=${{ !startsWith(github.ref, 'refs/tags/') }}
62
73
63
74
- name : Compress Flutter build
64
75
id : compress
65
76
run : |
66
77
buildName=$(grep -oP "(?<=buildName = ').*(?=')" lib/data/version.dart)
67
- archiveName="Saber_v${buildName}_Linux_x86_64 .tar.gz"
78
+ archiveName="Saber_v${buildName}_Linux_${{ matrix.arch.archive-suffix }} .tar.gz"
68
79
echo "archiveName=$archiveName" >> $GITHUB_OUTPUT
69
80
70
81
mkdir -p AppDir
71
- mv build/linux/x64/release/bundle /* AppDir
82
+ mv ${{ matrix.arch.flutter-output-folder }} /* AppDir
72
83
chmod +x AppDir/saber
73
84
74
85
install -Dm644 flatpak/com.adilhanney.saber.metainfo.xml -t AppDir/share/metainfo/
84
95
- name : Upload artifact
85
96
uses : actions/upload-artifact@v4
86
97
with :
87
- name : Saber-Archive-x86_64
98
+ name : Saber-Archive-${{ matrix.arch.archive-suffix }}
88
99
path : ${{ steps.compress.outputs.archiveName }}
89
100
90
101
- name : Upload to GitHub release
@@ -94,170 +105,9 @@ jobs:
94
105
repo_token : ${{ secrets.GITHUB_TOKEN }}
95
106
file : ${{ steps.compress.outputs.archiveName }}
96
107
97
- build-flutter-app-arm64 :
98
- name : Build Flutter app (arm64)
99
- runs-on : ubuntu-latest
100
- permissions :
101
- contents : write
102
- packages : write
103
- timeout-minutes : 120
104
- steps :
105
- - name : Checkout code
106
- uses : actions/checkout@v4
107
-
108
- - name : Setup cache
109
- uses : actions/cache@v4
110
- with :
111
- path : |
112
- build
113
- key : ${{ runner.OS }}-saberarm64-${{ hashFiles('**/pubspec.lock') }}-${{ hashFiles('**/*.dart') }}
114
- restore-keys : |
115
- ${{ runner.OS }}-saberarm64-
116
-
117
- - name : Build Linux (arm64)
118
- uses : uraimo/run-on-arch-action@v2
119
- with :
120
- arch : aarch64
121
- distro : ubuntu_latest
122
- githubToken : ${{ github.token }}
123
-
124
- setup : |
125
- mkdir -p "${PWD}/AppDir"
126
- mkdir -p "${PWD}/build/pub_cache"
127
- dockerRunArgs : |
128
- --volume "${PWD}/AppDir:/AppDir"
129
-
130
- install : |
131
- quiet () {
132
- output=`"$@" 2>&1` || echo $output
133
- }
134
- unsudo () {
135
- sudo -u nonroot env "PATH=$PATH" "CARGO_HOME=$CARGO_HOME" "RUSTUP_HOME=$RUSTUP_HOME" PUB_CACHE="$PUB_CACHE" "$@"
136
- }
137
-
138
- echo Installing dependencies
139
- quiet apt-get update -qq -y
140
- quiet apt-get install -qq -y \
141
- sudo \
142
- bash curl file git unzip xz-utils zip \
143
- clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev \
144
- libsecret-1-dev libjsoncpp-dev webkit2gtk-4.1-dev \
145
- libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libunwind-dev
146
-
147
- echo Creating nonroot user
148
- useradd -m -d /home/nonroot -s /bin/bash nonroot
149
- echo 'export PATH="$PATH:/opt/flutter/bin"' >> /home/nonroot/.bashrc
150
- echo 'export PATH="$PATH:/opt/cargo/bin"' >> /home/nonroot/.bashrc
151
- echo 'export CARGO_HOME=/opt/cargo' >> /home/nonroot/.bashrc
152
- echo 'export RUSTUP_HOME=/opt/rustup' >> /home/nonroot/.bashrc
153
- echo 'export PUB_CACHE=build/pub_cache' >> /home/nonroot/.bashrc
154
- export PATH="$PATH:/opt/flutter/bin"
155
- export PATH="$PATH:/opt/cargo/bin"
156
- export CARGO_HOME=/opt/cargo
157
- export RUSTUP_HOME=/opt/rustup
158
- export PUB_CACHE=build/pub_cache
159
-
160
- echo Installing Flutter
161
- if [ -z "$(which flutter)" ]; then
162
- echo Flutter not installed, installing...
163
- mkdir -p /opt/flutter
164
- chown -R nonroot /opt/flutter
165
- unsudo git clone https://github.com/flutter/flutter.git -b stable --depth 1 /opt/flutter
166
- else
167
- echo Flutter already installed, updating...
168
- chown -R nonroot /opt/flutter
169
- unsudo flutter upgrade
170
- fi
171
-
172
- echo flutter doctor
173
- unsudo flutter doctor -v
174
-
175
- echo Precaching Flutter
176
- unsudo flutter precache --no-universal --linux
177
-
178
- echo Installing Rust
179
- mkdir -p $CARGO_HOME
180
- mkdir -p $RUSTUP_HOME
181
- mkdir -p "$RUSTUP_HOME/tmp"
182
- chown -R nonroot $CARGO_HOME
183
- chown -R nonroot $RUSTUP_HOME
184
- unsudo curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y
185
- chmod -R a+rw $CARGO_HOME
186
- chmod -R a+rw $RUSTUP_HOME
187
- unsudo ls -l $CARGO_HOME/bin
188
- unsudo which rustup
189
-
190
- run : |
191
- unsudo () {
192
- sudo -u nonroot env "PATH=$PATH" "CARGO_HOME=$CARGO_HOME" "RUSTUP_HOME=$RUSTUP_HOME" PUB_CACHE="$PUB_CACHE" "$@"
193
- }
194
-
195
- echo Setting up environment
196
- chown -R nonroot .
197
- chown -R nonroot /opt/flutter
198
- chown -R nonroot /opt/cargo
199
- export PATH="$PATH:/opt/flutter/bin"
200
- export PATH="$PATH:/opt/cargo/bin"
201
- export CARGO_HOME=/opt/cargo
202
- export RUSTUP_HOME=/opt/rustup
203
- export PUB_CACHE=build/pub_cache
204
-
205
- echo Removing proprietary dependencies
206
- ./patches/remove_proprietary_dependencies.sh
207
-
208
- echo Disabling Flutter CLI animations
209
- unsudo flutter config --no-cli-animations
210
-
211
- echo flutter pub get
212
- unsudo flutter pub get
213
-
214
- echo Verifying that rustup is installed
215
- unsudo which rustup
216
-
217
- echo Building
218
- unsudo flutter build linux \
219
- --target-platform linux-arm64 \
220
- --dart-define=DIRTY=${{ !startsWith(github.ref, 'refs/tags/') }}
221
- mv build/linux/arm64/release/bundle/* /AppDir/
222
- chown -R nonroot /AppDir/
223
- chmod -R a+rw /AppDir/
224
- chmod a+x /AppDir/saber
225
-
226
- - name : Compress Flutter build
227
- id : compress
228
- run : |
229
- buildName=$(grep -oP "(?<=buildName = ').*(?=')" lib/data/version.dart)
230
- archiveName="Saber_v${buildName}_Linux_arm64.tar.gz"
231
- echo "archiveName=$archiveName" >> $GITHUB_OUTPUT
232
-
233
- sudo chown -R $USER:$USER .
234
-
235
- install -Dm644 flatpak/com.adilhanney.saber.metainfo.xml -t AppDir/share/metainfo/
236
- install -Dm644 flatpak/com.adilhanney.saber.metainfo.xml -t AppDir/usr/share/metainfo/
237
-
238
- install -Dm644 assets/icon/icon.svg AppDir/share/icons/hicolor/scalable/apps/com.adilhanney.saber.svg
239
- install -Dm644 assets/icon/icon.svg AppDir/usr/share/icons/hicolor/scalable/apps/com.adilhanney.saber.svg
240
-
241
- install -Dm644 flatpak/com.adilhanney.saber.desktop -t AppDir/share/applications/
242
-
243
- tar -C AppDir -cvf $archiveName .
244
-
245
- - name : Upload artifact
246
- uses : actions/upload-artifact@v4
247
- with :
248
- name : Saber-Archive-arm64
249
- path : ${{ steps.compress.outputs.archiveName }}
250
-
251
- - name : Upload to GitHub release
252
- uses : svenstaro/upload-release-action@v2
253
- if : ${{ startsWith(github.ref, 'refs/tags/') }}
254
- with :
255
- repo_token : ${{ secrets.GITHUB_TOKEN }}
256
- file : ${{ steps.compress.outputs.archiveName }}
257
-
258
108
build-appimage :
259
109
name : Build AppImage
260
- needs : build-flutter-app-x86_64
110
+ needs : build-linux
261
111
runs-on : ubuntu-latest
262
112
permissions :
263
113
contents : write
0 commit comments