-
Notifications
You must be signed in to change notification settings - Fork 0
312 lines (289 loc) · 9.97 KB
/
build-snap.yml
File metadata and controls
312 lines (289 loc) · 9.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
name: Build Snap
env:
FLUTTER_VERSION: '3.41.9'
on:
workflow_dispatch:
inputs:
build_number:
description: 'Build number (optional)'
required: false
type: string
default: ''
jobs:
extract-version:
name: Extract App Version
runs-on: ubuntu-latest
outputs:
app_version: ${{ steps.extract.outputs.app_version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract app version
id: extract
run: |
APP_VERSION=$(grep "final appVersion" lib/main.dart | sed 's/.*= "\(.*\)".*/\1/')
echo "app_version=$APP_VERSION" >> $GITHUB_OUTPUT
echo "📋 App version: $APP_VERSION"
build-snap:
name: Build Snap Package
needs: extract-version
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Flutter dependencies
uses: actions/cache@v4
with:
path: |
~/.flutter-cache
~/.pub-cache
key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-flutter-
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
- name: Clean build
run: flutter clean
- name: Get flutter dependencies
run: flutter pub get
- name: Install Linux build dependencies & packaging tools
run: |
sudo apt-get update
sudo apt-get full-upgrade -y
sudo apt-get install -y \
clang \
cmake \
ninja-build \
pkg-config \
libgtk-3-dev \
libblkid-dev \
liblzma-dev \
ruby \
ruby-dev \
build-essential \
rpm \
flatpak \
flatpak-builder \
libfuse2 \
wget
sudo snap refresh
sudo gem install fpm
- name: Build Linux release
run: |
flutter build linux \
--release \
--target lib/main.dart \
--dart-define=BUILD_NUMBER=${{ github.run_number }}
- name: Create Debian package
run: |
APP_NAME="selah"
VERSION="${{ needs.extract-version.outputs.app_version }}"
BUILD_DIR="build/linux/x64/release/bundle"
OUTPUT_DIR="$(pwd)/build/packages"
mkdir -p "$OUTPUT_DIR"
echo "📦 Creating .deb package..."
TEMP_DIR=$(mktemp -d)
cp -r "$BUILD_DIR"/* "$TEMP_DIR/"
mkdir -p "$TEMP_DIR/usr/bin"
mkdir -p "$TEMP_DIR/usr/share/applications"
mkdir -p "$TEMP_DIR/usr/share/icons/hicolor/256x256/apps"
mkdir -p "$TEMP_DIR/opt/selah"
cp "$TEMP_DIR/data/flutter_assets/assets/icon.png" "$TEMP_DIR/usr/share/icons/hicolor/256x256/apps/io.github.toazd.selah.png"
mv "$TEMP_DIR/selah" "$TEMP_DIR/opt/selah/"
if [ -d "$TEMP_DIR/data" ]; then
mv "$TEMP_DIR/data" "$TEMP_DIR/opt/selah/"
fi
if [ -d "$TEMP_DIR/lib" ]; then
mv "$TEMP_DIR/lib" "$TEMP_DIR/opt/selah/"
fi
ln -sf "/opt/selah/selah" "$TEMP_DIR/usr/bin/selah"
printf '[Desktop Entry]\nName=Selah\nComment=A cross-platform Bible study app using Flutter and the 1769 King James Version\nExec=/usr/bin/selah\nIcon=io.github.toazd.selah.png\nType=Application\nCategories=Education\nKeywords=Bible;Study;KJV;\nStartupNotify=true\nStartupWMClass=io.github.toazd.selah\n' > "$TEMP_DIR/usr/share/applications/io.github.toazd.selah.desktop"
fpm -s dir -t deb \
-n "$APP_NAME" \
-v "$VERSION" \
--deb-priority optional \
--category utils \
--description "A cross-platform Bible study app using Flutter and the 1769 King James Version" \
--url "https://github.com/toazd/selah" \
--maintainer "Selah Team" \
--license "Unlicense" \
-p "$OUTPUT_DIR" \
-C "$TEMP_DIR" \
usr/bin/selah \
usr/share/applications/io.github.toazd.selah.desktop \
usr/share/icons/ \
opt/selah/
rm -rf "$TEMP_DIR"
ls -lah build/packages/
- name: Install snapcraft dependencies
run: |
sudo apt-get update
sudo apt-get install -y snapd squashfs-tools dpkg-dev
sudo snap install core22
sudo snap install snapcraft --classic
- name: Prepare Snap build directory and copy icon
run: |
mkdir -p build/snap-build
cp snapcraft/io.github.toazd.selah.svg build/snap-build/
- name: Extract Debian package for Snap build
run: |
set -e
mkdir -p build/snap-build/prime
mkdir -p build/snap-build/snap/gui
DEB_FILE=$(ls build/packages/selah_*.deb | head -n1)
if [ -z "$DEB_FILE" ]; then
echo "❌ Debian package not found"
ls -lah build/packages
exit 1
fi
dpkg-deb -x "$DEB_FILE" build/snap-build/prime
mkdir -p build/snap-build/prime/usr/share/applications
mkdir -p build/snap-build/prime/usr/share/icons/hicolor/256x256/apps
# Copy icon to snap/gui directory for snapcraft
cp build/snap-build/io.github.toazd.selah.svg build/snap-build/snap/gui/
printf '[Desktop Entry]\nName=Selah\nComment=A cross-platform Bible study app using Flutter and the 1769 King James Version\nExec=selah\nIcon=${SNAP}/meta/gui/io.github.toazd.selah.svg\nType=Application\nCategories=Education\nKeywords=Bible;Study;KJV;\nStartupNotify=true\nStartupWMClass=io.github.toazd.selah\n' > build/snap-build/snap/gui/io.github.toazd.selah.desktop
- name: Create Snapcraft manifest
run: |
VERSION="${{ needs.extract-version.outputs.app_version }}"
cat > build/snap-build/snapcraft.yaml <<EOF
name: selah
title: Selah Bible study app
version: $VERSION
summary: Cross platform Bible study app
license: Unlicense
contact: wmcdannell@gmail.com
issues: https://github.com/toazd/selah/issues
website: https://toazd.github.io/
icon: snap/gui/io.github.toazd.selah.svg
type: app
description: |
A cross-platform Bible study app using Flutter and the 1769 King James Version.
base: core22
confinement: strict
grade: stable
apps:
selah:
command: opt/selah/selah
desktop: snap/gui/io.github.toazd.selah.desktop
environment:
__EGL_VENDOR_LIBRARY_DIRS: \$SNAP/usr/share/glvnd/egl_vendor.d
LIBGL_DRIVERS_PATH: \$SNAP/usr/lib/x86_64-linux-gnu/dri
GTK_PATH: \$SNAP/usr/lib/x86_64-linux-gnu/gtk-3.0
plugs:
- personal-files
- home
- network
- network-bind
- network-manager-observe
- network-observe
- pulseaudio
- audio-playback
- removable-media
- x11
- wayland
- desktop
- desktop-legacy
- browser-support
- opengl
plugs:
personal-files:
read:
- \$HOME/.config/selah
write:
- \$HOME/.config/selah
parts:
selah:
plugin: dump
source: prime
organize:
snap/gui/io.github.toazd.selah.svg: snap/gui/io.github.toazd.selah.svg
stage-packages:
- ca-certificates
- libgtk-3-0
- libglib2.0-0
- libpango-1.0-0
- libpangocairo-1.0-0
- libgdk-pixbuf2.0-0
- libx11-6
- libx11-xcb1
- libxkbcommon0
- libdrm2
- libegl1
- libegl-mesa0
- libgbm1
- libgl1
- libgl1-mesa-dri
- libgles2
- libglvnd0
- libglx0
- libglx-mesa0
- libopengl0
- libfontconfig1
- libfreetype6
- libcanberra-gtk-module
- libcanberra-gtk3-module
- libsecret-1-0
- libsqlite3-0
- libopus0
- libjsoncpp25
- libasound2
- libatk1.0-0
- libc6
- libxcb1
- libxcb-dri2-0
- libxcb-dri3-0
- libxcb-glx0
- libxcb-present0
- libxcb-randr0
- libxcb-sync1
- libxcb-xfixes0
- libxrender1
- libxrandr2
- libxss1
- libxcursor1
- libxcomposite1
- libxdamage1
- libxfixes3
- libxext6
- libxinerama1
- libxshmfence1
- libxtst6
- libwayland-client0
- libwayland-cursor0
- libwayland-egl1
- libgdk-pixbuf2.0-0
- xdg-utils
EOF
- name: Build Snap package
run: |
cd build/snap-build
sudo snapcraft pack --destructive-mode --output ../packages
cd -
SNAP_FILE=""
for file in build/packages/*.snap; do
if [ -f "$file" ]; then
SNAP_FILE="$file"
break
fi
done
if [ -z "$SNAP_FILE" ]; then
echo "❌ Snap package not found"
ls -lah build/packages
exit 1
fi
SNAP_TARGET="build/packages/Selah-${{ needs.extract-version.outputs.app_version }}.snap"
if [ "$SNAP_FILE" != "$SNAP_TARGET" ]; then
mv "$SNAP_FILE" "$SNAP_TARGET"
fi
ls -lah build/packages
- name: Upload Snap artifact
uses: actions/upload-artifact@v4
with:
name: snap-package-${{ needs.extract-version.outputs.app_version }}-${{ github.run_number }}
path: build/packages/*.snap
if-no-files-found: error