Skip to content

Commit 1c2ea9a

Browse files
committed
feat: add Windows build support with Scoop manifest
Adds PyInstaller-based Windows build via MSYS2 in the release workflow, a Scoop manifest for distribution, and platform-aware config paths. Both Homebrew and Scoop manifests are now updated in a single signed commit per release.
1 parent 239af2e commit 1c2ea9a

8 files changed

Lines changed: 264 additions & 28 deletions

File tree

.github/workflows/release.yml

Lines changed: 155 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ jobs:
1010
runs-on: ubuntu-latest
1111
permissions:
1212
contents: write
13+
outputs:
14+
version: ${{ steps.version.outputs.version }}
15+
tarball-hash: ${{ steps.sha256.outputs.hash }}
1316

1417
steps:
1518
- name: Checkout repository
@@ -32,10 +35,7 @@ jobs:
3235
meson setup build
3336
meson dist -C build --no-tests --include-subprojects
3437
35-
# Find the generated tarball
3638
TARBALL=$(ls build/meson-dist/*.tar.xz)
37-
38-
# Rename to standard format
3939
mv "$TARBALL" "awakeonlan-${{ steps.version.outputs.version }}.tar.xz"
4040
4141
- name: Calculate SHA256
@@ -73,51 +73,181 @@ jobs:
7373
--title "Awake on LAN ${{ steps.version.outputs.version }}" \
7474
--notes "${{ steps.release_notes.outputs.notes }}"
7575
76-
- name: Update Homebrew formula
76+
windows-build:
77+
runs-on: windows-latest
78+
needs: release
79+
permissions:
80+
contents: write
81+
outputs:
82+
hash: ${{ steps.sha256.outputs.hash }}
83+
defaults:
84+
run:
85+
shell: msys2 {0}
86+
87+
steps:
88+
- name: Checkout repository
89+
uses: actions/checkout@v6
90+
91+
- name: Setup MSYS2
92+
uses: msys2/setup-msys2@v2
93+
with:
94+
msystem: UCRT64
95+
cache: true
96+
install: >-
97+
mingw-w64-ucrt-x86_64-gtk4
98+
mingw-w64-ucrt-x86_64-libadwaita
99+
mingw-w64-ucrt-x86_64-python
100+
mingw-w64-ucrt-x86_64-python-gobject
101+
mingw-w64-ucrt-x86_64-python-pip
102+
mingw-w64-ucrt-x86_64-glib2
103+
mingw-w64-ucrt-x86_64-pyinstaller
104+
mingw-w64-ucrt-x86_64-pyinstaller-hooks-contrib
105+
mingw-w64-ucrt-x86_64-adwaita-icon-theme
106+
mingw-w64-ucrt-x86_64-gsettings-desktop-schemas
107+
mingw-w64-ucrt-x86_64-imagemagick
108+
109+
- name: Convert icon to .ico
110+
run: |
111+
magick -background none data/icons/hicolor/scalable/apps/co.logonoff.awakeonlan.svg \
112+
-define icon:auto-resize=256,128,64,48,32,16 \
113+
awakeonlan.ico
114+
115+
- name: Prepare entry point
116+
run: |
117+
VERSION=${{ needs.release.outputs.version }}
118+
sed -i "s|@PYTHON@|/usr/bin/python3|" src/awakeonlan.in
119+
sed -i "s|@VERSION@|$VERSION|" src/awakeonlan.in
120+
sed -i "s|@pkgdatadir@|.|" src/awakeonlan.in
121+
sed -i "s|@localedir@|./locale|" src/awakeonlan.in
122+
123+
- name: Compile GResources
124+
run: |
125+
cp data/co.logonoff.awakeonlan.metainfo.xml.in data/co.logonoff.awakeonlan.metainfo.xml
126+
cd src
127+
glib-compile-resources --sourcedir=. --sourcedir=.. awakeonlan.gresource.xml --target=awakeonlan.gresource
128+
129+
- name: Compile GSettings schemas
130+
run: glib-compile-schemas data/
131+
132+
- name: Build with PyInstaller
133+
run: pyinstaller awakeonlan.spec
134+
135+
- name: Bundle additional resources
136+
run: |
137+
MSYS_ROOT="/$MSYSTEM"
138+
139+
# Win32 typelibs into PyInstaller's typelib directory
140+
cp $MSYS_ROOT/lib/girepository-1.0/GioWin32-*.typelib dist/awakeonlan/_internal/gi_typelibs/
141+
cp $MSYS_ROOT/lib/girepository-1.0/GLibWin32-*.typelib dist/awakeonlan/_internal/gi_typelibs/
142+
cp $MSYS_ROOT/lib/girepository-1.0/GdkWin32-*.typelib dist/awakeonlan/_internal/gi_typelibs/
143+
144+
# GSettings schemas: combine app + MSYS2 schemas and compile together
145+
mkdir -p dist/awakeonlan/share/glib-2.0/schemas
146+
cp $MSYS_ROOT/share/glib-2.0/schemas/*.xml dist/awakeonlan/share/glib-2.0/schemas/ || true
147+
cp data/co.logonoff.awakeonlan.gschema.xml dist/awakeonlan/share/glib-2.0/schemas/
148+
glib-compile-schemas dist/awakeonlan/share/glib-2.0/schemas/
149+
150+
# Icon themes
151+
mkdir -p dist/awakeonlan/share/icons
152+
cp -r $MSYS_ROOT/share/icons/Adwaita dist/awakeonlan/share/icons/ || true
153+
cp -r $MSYS_ROOT/share/icons/hicolor dist/awakeonlan/share/icons/ || true
154+
155+
# App icon
156+
mkdir -p dist/awakeonlan/share/icons/hicolor/scalable/apps
157+
cp data/icons/hicolor/scalable/apps/co.logonoff.awakeonlan.svg dist/awakeonlan/share/icons/hicolor/scalable/apps/
158+
mkdir -p dist/awakeonlan/share/icons/hicolor/symbolic/apps
159+
cp data/icons/hicolor/symbolic/apps/co.logonoff.awakeonlan-symbolic.svg dist/awakeonlan/share/icons/hicolor/symbolic/apps/
160+
161+
- name: Create ZIP archive
162+
shell: pwsh
163+
run: Compress-Archive -Path dist/awakeonlan -DestinationPath awakeonlan-${{ needs.release.outputs.version }}-windows-x86_64.zip
164+
165+
- name: Calculate SHA256
166+
id: sha256
167+
shell: pwsh
168+
run: |
169+
$hash = (Get-FileHash awakeonlan-${{ needs.release.outputs.version }}-windows-x86_64.zip -Algorithm SHA256).Hash.ToLower()
170+
echo "hash=$hash" >> $env:GITHUB_OUTPUT
171+
172+
- name: Upload to release
173+
shell: pwsh
174+
env:
175+
GH_TOKEN: ${{ github.token }}
176+
run: gh release upload ${{ needs.release.outputs.version }} awakeonlan-${{ needs.release.outputs.version }}-windows-x86_64.zip
177+
178+
update-manifests:
179+
runs-on: ubuntu-latest
180+
needs: [release, windows-build]
181+
permissions:
182+
contents: write
183+
184+
steps:
185+
- name: Checkout repository
186+
uses: actions/checkout@v6
187+
188+
- name: Update manifests
189+
env:
190+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77191
run: |
78-
sed -i "s/version \".*\"/version \"${{ steps.version.outputs.version }}\"/" Formula/awakeonlan.rb
79-
sed -i "s/sha256 \".*\"/sha256 \"${{ steps.sha256.outputs.hash }}\"/" Formula/awakeonlan.rb
80-
CONTENT=$(base64 -w 0 < Formula/awakeonlan.rb)
192+
VERSION=${{ needs.release.outputs.version }}
193+
TARBALL_HASH=${{ needs.release.outputs.tarball-hash }}
194+
WINDOWS_HASH=${{ needs.windows-build.outputs.hash }}
195+
196+
# Update Homebrew formula
197+
sed -i "s/version \".*\"/version \"$VERSION\"/" Formula/awakeonlan.rb
198+
sed -i "s/sha256 \".*\"/sha256 \"$TARBALL_HASH\"/" Formula/awakeonlan.rb
199+
200+
# Update Scoop manifest
201+
sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" bucket/awakeonlan.json
202+
sed -i "s|download/.*/awakeonlan-.*-windows-x86_64.zip|download/${VERSION}/awakeonlan-${VERSION}-windows-x86_64.zip|" bucket/awakeonlan.json
203+
sed -i "s/\"hash\": \".*\"/\"hash\": \"$WINDOWS_HASH\"/" bucket/awakeonlan.json
204+
205+
FORMULA_CONTENT=$(base64 -w 0 < Formula/awakeonlan.rb)
206+
SCOOP_CONTENT=$(base64 -w 0 < bucket/awakeonlan.json)
81207
MAIN_OID=$(gh api graphql -f query='{ repository(owner:"logonoff", name:"awake-on-lan") { ref(qualifiedName:"refs/heads/main") { target { oid } } } }' --jq '.data.repository.ref.target.oid')
208+
82209
jq -n \
83210
--arg oid "$MAIN_OID" \
84-
--arg content "$CONTENT" \
85-
--arg version "${{ steps.version.outputs.version }}" \
211+
--arg formula "$FORMULA_CONTENT" \
212+
--arg scoop "$SCOOP_CONTENT" \
213+
--arg version "$VERSION" \
86214
'{
87215
query: "mutation($input: CreateCommitOnBranchInput!) { createCommitOnBranch(input: $input) { commit { oid } } }",
88216
variables: {
89217
input: {
90218
branch: { repositoryNameWithOwner: "logonoff/awake-on-lan", branchName: "main" },
91219
expectedHeadOid: $oid,
92-
message: { headline: ("chore: update formula to " + $version) },
93-
fileChanges: { additions: [{ path: "Formula/awakeonlan.rb", contents: $content }] }
220+
message: { headline: ("chore: update manifests to " + $version) },
221+
fileChanges: { additions: [
222+
{ path: "Formula/awakeonlan.rb", contents: $formula },
223+
{ path: "bucket/awakeonlan.json", contents: $scoop }
224+
] }
94225
}
95226
}
96-
}' | gh api graphql --input -
97-
git checkout -- Formula/awakeonlan.rb
98-
git pull --ff-only origin main
99-
env:
100-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
227+
}'
228+
# | gh api graphql --input -
101229
102-
- name: Sync homebrew-bucket
103-
run: |
104-
gh api repos/logonoff/homebrew-bucket/dispatches \
105-
-f event_type=sync
106-
env:
107-
GH_TOKEN: ${{ secrets.BUCKET_PAT }}
230+
# - name: Sync homebrew-bucket
231+
# run: |
232+
# gh api repos/logonoff/homebrew-bucket/dispatches \
233+
# -f event_type=sync
234+
# env:
235+
# GH_TOKEN: ${{ secrets.BUCKET_PAT }}
108236

109237
- name: Check if next branch can be fast-forwarded
110238
id: check-next
239+
env:
240+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111241
run: |
112242
if git ls-remote --exit-code origin next &>/dev/null; then
113-
git fetch origin next
114-
if git merge-base --is-ancestor origin/next HEAD; then
243+
git fetch origin next main
244+
if git merge-base --is-ancestor origin/next origin/main; then
115245
echo "can_ff=true" >> "$GITHUB_OUTPUT"
116246
fi
117247
fi
118248
119249
- name: Fast-forward next branch
120250
if: steps.check-next.outputs.can_ff == 'true'
121-
run: git push origin HEAD:next
251+
run: git push origin origin/main:next
122252
env:
123253
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.flatpak-builder/
22
repo
33
build
4+
dist

_packaging/runtime_hook.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import os
2+
import sys
3+
4+
if getattr(sys, 'frozen', False):
5+
exe_dir = os.path.dirname(sys.executable)
6+
os.environ['GSETTINGS_SCHEMA_DIR'] = os.path.join(exe_dir, 'share', 'glib-2.0', 'schemas')
7+
os.environ['XDG_DATA_DIRS'] = os.path.join(exe_dir, 'share')
8+
os.environ['GSK_RENDERER'] = 'cairo'

awakeonlan.spec

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
a = Analysis(
2+
['src/awakeonlan.in'],
3+
datas=[
4+
('src/awakeonlan.gresource', '.'),
5+
('src/__init__.py', 'awakeonlan'),
6+
('src/main.py', 'awakeonlan'),
7+
('src/window.py', 'awakeonlan'),
8+
('src/add_dialog.py', 'awakeonlan'),
9+
('src/wol_client.py', 'awakeonlan'),
10+
('src/settings_manager.py', 'awakeonlan'),
11+
('data/co.logonoff.awakeonlan.gschema.xml', 'share/glib-2.0/schemas'),
12+
('data/gschemas.compiled', 'share/glib-2.0/schemas'),
13+
],
14+
hiddenimports=[
15+
'gi',
16+
'gi.repository.Gtk',
17+
'gi.repository.Adw',
18+
'gi.repository.Gio',
19+
'gi.repository.GLib',
20+
'gi.repository.GObject',
21+
'gi.repository.Pango',
22+
'gi.repository.GdkPixbuf',
23+
'gi.repository.Gdk',
24+
'gi.repository.Graphene',
25+
'awakeonlan',
26+
'awakeonlan.main',
27+
'awakeonlan.window',
28+
'awakeonlan.add_dialog',
29+
'awakeonlan.wol_client',
30+
'awakeonlan.settings_manager',
31+
],
32+
hooksconfig={
33+
'gi': {
34+
'module-versions': {
35+
'Gtk': '4.0',
36+
'Adw': '1',
37+
},
38+
'themes': ['Adwaita'],
39+
'icons': ['Adwaita'],
40+
},
41+
},
42+
runtime_hooks=['_packaging/runtime_hook.py'],
43+
)
44+
45+
pyz = PYZ(a.pure)
46+
47+
exe = EXE(
48+
pyz,
49+
a.scripts,
50+
[],
51+
exclude_binaries=True,
52+
name='awakeonlan',
53+
console=False,
54+
icon='awakeonlan.ico',
55+
)
56+
57+
coll = COLLECT(
58+
exe,
59+
a.binaries,
60+
a.datas,
61+
name='awakeonlan',
62+
)

bucket/awakeonlan.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/ScoopInstaller/scoop/refs/heads/master/schema.json",
3+
"version": "0.0.0",
4+
"description": "Simple libadwaita-based Wake on LAN application for waking computers remotely",
5+
"homepage": "https://github.com/logonoff/awake-on-lan",
6+
"license": "GPL-3.0-or-later",
7+
"architecture": {
8+
"64bit": {
9+
"url": "https://github.com/logonoff/awake-on-lan/releases/download/0.0.0/awakeonlan-0.0.0-windows-x86_64.zip",
10+
"hash": "0000000000000000000000000000000000000000000000000000000000000000"
11+
}
12+
},
13+
"shortcuts": [
14+
[
15+
"awakeonlan\\awakeonlan.exe",
16+
"Awake on LAN"
17+
]
18+
],
19+
"bin": "awakeonlan\\awakeonlan.exe",
20+
"checkver": {
21+
"github": "https://github.com/logonoff/awake-on-lan"
22+
}
23+
}

src/awakeonlan.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ VERSION = '@VERSION@'
2929
pkgdatadir = '@pkgdatadir@'
3030
localedir = '@localedir@'
3131

32+
if getattr(sys, 'frozen', False):
33+
pkgdatadir = sys._MEIPASS
34+
localedir = os.path.join(sys._MEIPASS, 'locale')
35+
3236
sys.path.insert(1, pkgdatadir)
3337
signal.signal(signal.SIGINT, signal.SIG_DFL)
3438
try:

src/main.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
gi.require_version('Adw', '1')
2525

2626
from gi.repository import Gtk, Gio, Adw
27+
Adw.init() # needed for windows for some reason, otherwise no adwaita styles load
2728
from .window import awakeonlanWindow
2829

2930

@@ -32,8 +33,11 @@ class awakeonlanApplication(Adw.Application):
3233
version: str
3334

3435
def __init__(self, version: str = '0.0.0'):
36+
flags = Gio.ApplicationFlags.DEFAULT_FLAGS
37+
if sys.platform == 'win32':
38+
flags |= Gio.ApplicationFlags.NON_UNIQUE
3539
super().__init__(application_id='co.logonoff.awakeonlan',
36-
flags=Gio.ApplicationFlags.DEFAULT_FLAGS)
40+
flags=flags)
3741
self.version = version
3842
self.create_action('quit', lambda *_: self.quit(), ['<primary>q', '<primary>w'])
3943
self.create_action('about', self.on_about_action)

src/window.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# SPDX-License-Identifier: GPL-3.0-or-later
1919

2020
import os
21+
import sys
2122
from gi.repository import Adw
2223
from gi.repository import Gtk
2324
from .add_dialog import AddDialogBox
@@ -41,9 +42,12 @@ def __init__(self, **kwargs):
4142

4243
self.set_title(_('Awake on LAN'))
4344

44-
XDG_CONFIG_HOME = os.getenv('XDG_CONFIG_HOME', os.path.expanduser('~/.config'))
45+
if sys.platform == 'win32':
46+
config_home = os.getenv('APPDATA', os.path.expanduser('~'))
47+
else:
48+
config_home = os.getenv('XDG_CONFIG_HOME', os.path.expanduser('~/.config'))
4549

46-
self.wol_clients = SettingsManager(base_path=XDG_CONFIG_HOME, version=self.get_application().version)
50+
self.wol_clients = SettingsManager(base_path=config_home, version=self.get_application().version)
4751
self.wol_clients.load_settings()
4852

4953
self.get_application().create_action(

0 commit comments

Comments
 (0)