-
Notifications
You must be signed in to change notification settings - Fork 1
325 lines (288 loc) · 9.5 KB
/
build.yml
File metadata and controls
325 lines (288 loc) · 9.5 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
313
314
315
316
317
318
319
320
321
322
323
324
325
name: Build and Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
build_windows:
description: Build Windows x64 executable
required: true
default: true
type: boolean
build_linux:
description: Build Linux x64 deb package
required: true
default: true
type: boolean
create_release:
description: Create GitHub Release
required: true
default: false
type: boolean
release_tag:
description: "Release tag for manual run (example: v1.3.1)"
required: false
default: ''
type: string
permissions:
contents: write
concurrency:
group: build-release-${{ github.ref }}
cancel-in-progress: false
env:
APP_NAME: assignsticker
jobs:
build-windows:
runs-on: windows-latest
if: github.event_name != 'workflow_dispatch' || inputs.build_windows
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Install dependencies
run: |
uv sync --frozen
- name: Build Windows executable
run: uv run python build.py
- name: Upload Windows artifact
uses: actions/upload-artifact@v4
with:
name: AssignSticker-windows-x64
path: dist/AssignSticker.exe
if-no-files-found: error
build-linux:
runs-on: ubuntu-latest
if: github.event_name != 'workflow_dispatch' || inputs.build_linux
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Resolve app version
id: version
shell: bash
run: |
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
VERSION="${GITHUB_REF#refs/tags/v}"
elif [[ -n "${{ inputs.release_tag }}" ]]; then
VERSION="${{ inputs.release_tag }}"
VERSION="${VERSION#v}"
else
VERSION="0.0.0-dev"
fi
echo "app_version=${VERSION}" >> "$GITHUB_OUTPUT"
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
python3-dev \
pkg-config \
libcairo2-dev \
libgirepository-2.0-dev \
gir1.2-gtk-3.0 \
gir1.2-webkit2-4.1 \
python3-gi \
python3-gi-cairo \
libwebkit2gtk-4.1-0 \
libayatana-appindicator3-1 \
dpkg-dev \
libegl1 \
libgl1-mesa-glx \
libxkbcommon0 \
libxcb-cursor0
- name: Install Python dependencies
run: |
uv sync --frozen --all-extras
- name: Build with PyInstaller
shell: bash
run: |
uv pip install pyinstaller
cat > assignsticker.spec << 'SPECEOF'
# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.building.build_main import Analysis, PYZ, EXE
block_cipher = None
datas = [
('htmls', 'htmls'),
('icons', 'icons'),
('saying', 'saying'),
('desktop_widgets', 'desktop_widgets'),
('homeworktemple', 'homeworktemple'),
('font.ttf', '.'),
('icon.ico', '.'),
('introduce', '.'),
('banner.png', '.'),
('作业模板YML格式标准.txt', '.'),
]
hiddenimports = [
'gi',
'gi.repository',
'gi.repository.Gtk',
'gi.repository.Gdk',
'gi.repository.GObject',
'gi.repository.GLib',
'gi.repository.Gio',
'gi.repository.AyatanaAppIndicator3',
'cairo',
'webview',
'webview.platforms.gtk',
'pystray',
'pystray._appindicator',
'PIL',
'PIL._imagingtk',
'PIL._tkinter_finder',
'PySide6',
'PySide6.QtCore',
'PySide6.QtGui',
'PySide6.QtWidgets',
]
a = Analysis(
['main.py'],
pathex=[],
binaries=[],
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='assignsticker',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon='icon.ico',
)
SPECEOF
uv run pyinstaller assignsticker.spec
- name: Build DEB package
shell: bash
env:
APP_VERSION: ${{ steps.version.outputs.app_version }}
run: |
set -euo pipefail
PKG="build/deb/${APP_NAME}"
mkdir -p "${PKG}/opt/${APP_NAME}"
mkdir -p "${PKG}/usr/bin"
mkdir -p "${PKG}/usr/share/applications"
mkdir -p "${PKG}/DEBIAN"
cp -r dist/assignsticker/* "${PKG}/opt/${APP_NAME}/"
cat > "${PKG}/usr/bin/${APP_NAME}" <<'LAUNCHEOF'
#!/bin/bash
export GI_TYPELIB_PATH=/usr/lib/x86_64-linux-gnu/girepository-1.0
exec /opt/assignsticker/assignsticker "$@"
LAUNCHEOF
chmod +x "${PKG}/usr/bin/${APP_NAME}"
cat > "${PKG}/usr/share/applications/${APP_NAME}.desktop" <<DESKTOPEOF
[Desktop Entry]
Name=AssignSticker
Comment=Homework Kanban Application
Exec=${APP_NAME}
Icon=/opt/${APP_NAME}/icon.ico
Type=Application
Categories=Education;Office;
Terminal=false
StartupWMClass=assignsticker
DESKTOPEOF
SIZE=$(du -sk "${PKG}" | cut -f1)
cat > "${PKG}/DEBIAN/control" <<CONTROLEOF
Package: ${APP_NAME}
Version: ${APP_VERSION}
Section: education
Priority: optional
Architecture: amd64
Installed-Size: ${SIZE}
Depends: gir1.2-gtk-3.0, gir1.2-webkit2-4.1, libayatana-appindicator3-1, libcairo2, libgtk-3-0, libwebkit2gtk-4.1-0, libgirepository-2.0-0, libegl1, libgl1-mesa-gl, libxkbcommon0, libxcb-cursor0, python3-pyside6
Maintainer: SECTL <sectl@example.com>
Homepage: https://github.com/SECTL/AssignSticker
Description: Homework Showboard Application
AssignSticker is a homework management and display application for classroom use.
CONTROLEOF
dpkg-deb --root-owner-group --build "${PKG}"
mv "build/deb/${APP_NAME}.deb" "AssignSticker-${APP_VERSION}-amd64.deb"
- name: Upload Linux artifact
uses: actions/upload-artifact@v4
with:
name: AssignSticker-linux-amd64
path: AssignSticker-*-amd64.deb
if-no-files-found: error
release:
needs: [build-windows, build-linux]
runs-on: ubuntu-latest
if: |
always() &&
(startsWith(github.ref, 'refs/tags/v') ||
(github.event_name == 'workflow_dispatch' && inputs.create_release)) &&
(needs.build-windows.result == 'success' || needs.build-linux.result == 'success') &&
(needs.build-windows.result != 'failure' && needs.build-linux.result != 'failure')
steps:
- name: Resolve release tag
id: rel
shell: bash
run: |
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
TAG="${GITHUB_REF#refs/tags/}"
elif [[ -n "${{ inputs.release_tag }}" ]]; then
TAG="${{ inputs.release_tag }}"
else
echo "Manual release must provide release_tag (example: v1.3.1)" >&2
exit 1
fi
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
- name: Download Windows artifact
if: needs.build-windows.result == 'success'
uses: actions/download-artifact@v4
with:
name: AssignSticker-windows-x64
path: artifacts/windows
- name: Download Linux artifact
if: needs.build-linux.result == 'success'
uses: actions/download-artifact@v4
with:
name: AssignSticker-linux-amd64
path: artifacts/linux
- name: List release files
run: find artifacts -type f || true
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.rel.outputs.tag }}
files: |
artifacts/windows/*
artifacts/linux/*
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}