Skip to content

Commit 96582fd

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 49fc4a1 commit 96582fd

7 files changed

Lines changed: 250 additions & 26 deletions

File tree

.github/workflows/release.yml

Lines changed: 138 additions & 24 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,165 @@ 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+
update: 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-imagemagick
107+
108+
- name: Convert icon to .ico
109+
run: |
110+
magick -background none data/icons/hicolor/scalable/apps/co.logonoff.awakeonlan.svg \
111+
-define icon:auto-resize=256,128,64,48,32,16 \
112+
awakeonlan.ico
113+
114+
- name: Prepare entry point
115+
run: |
116+
VERSION=${{ needs.release.outputs.version }}
117+
sed -i "s|@PYTHON@|/usr/bin/python3|" src/awakeonlan.in
118+
sed -i "s|@VERSION@|$VERSION|" src/awakeonlan.in
119+
sed -i "s|@pkgdatadir@|.|" src/awakeonlan.in
120+
sed -i "s|@localedir@|./locale|" src/awakeonlan.in
121+
122+
- name: Compile GResources
123+
run: |
124+
cp data/co.logonoff.awakeonlan.metainfo.xml.in data/co.logonoff.awakeonlan.metainfo.xml
125+
cd src
126+
glib-compile-resources --sourcedir=. --sourcedir=.. awakeonlan.gresource.xml --target=awakeonlan.gresource
127+
128+
- name: Compile GSettings schemas
129+
run: glib-compile-schemas data/
130+
131+
- name: Build with PyInstaller
132+
run: pyinstaller awakeonlan.spec
133+
134+
- name: Bundle additional resources
135+
run: |
136+
MSYS_ROOT="/$MSYSTEM"
137+
mkdir -p dist/awakeonlan/share/glib-2.0/schemas
138+
cp $MSYS_ROOT/share/glib-2.0/schemas/gschemas.compiled dist/awakeonlan/share/glib-2.0/schemas/ || true
139+
cp data/gschemas.compiled dist/awakeonlan/share/glib-2.0/schemas/ 2>/dev/null || true
140+
mkdir -p dist/awakeonlan/share/icons
141+
cp -r $MSYS_ROOT/share/icons/Adwaita dist/awakeonlan/share/icons/ || true
142+
cp -r $MSYS_ROOT/share/icons/hicolor dist/awakeonlan/share/icons/ || true
143+
144+
- name: Create ZIP archive
145+
shell: pwsh
146+
run: |
147+
Compress-Archive -Path dist/awakeonlan -DestinationPath awakeonlan-${{ needs.release.outputs.version }}-windows-x86_64.zip
148+
149+
- name: Calculate SHA256
150+
id: sha256
151+
shell: pwsh
152+
run: |
153+
$hash = (Get-FileHash awakeonlan-${{ needs.release.outputs.version }}-windows-x86_64.zip -Algorithm SHA256).Hash.ToLower()
154+
echo "hash=$hash" >> $env:GITHUB_OUTPUT
155+
156+
- name: Upload to release
157+
shell: pwsh
158+
env:
159+
GH_TOKEN: ${{ github.token }}
160+
run: |
161+
gh release upload ${{ needs.release.outputs.version }} awakeonlan-${{ needs.release.outputs.version }}-windows-x86_64.zip
162+
163+
update-manifests:
164+
runs-on: ubuntu-latest
165+
needs: [release, windows-build]
166+
permissions:
167+
contents: write
168+
169+
steps:
170+
- name: Checkout repository
171+
uses: actions/checkout@v6
172+
173+
- name: Update manifests
174+
env:
175+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77176
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)
177+
VERSION=${{ needs.release.outputs.version }}
178+
TARBALL_HASH=${{ needs.release.outputs.tarball-hash }}
179+
WINDOWS_HASH=${{ needs.windows-build.outputs.hash }}
180+
181+
# Update Homebrew formula
182+
sed -i "s/version \".*\"/version \"$VERSION\"/" Formula/awakeonlan.rb
183+
sed -i "s/sha256 \".*\"/sha256 \"$TARBALL_HASH\"/" Formula/awakeonlan.rb
184+
185+
# Update Scoop manifest
186+
sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" bucket/awakeonlan.json
187+
sed -i "s|download/.*/awakeonlan-.*-windows-x86_64.zip|download/${VERSION}/awakeonlan-${VERSION}-windows-x86_64.zip|" bucket/awakeonlan.json
188+
sed -i "s/\"hash\": \".*\"/\"hash\": \"$WINDOWS_HASH\"/" bucket/awakeonlan.json
189+
190+
FORMULA_CONTENT=$(base64 -w 0 < Formula/awakeonlan.rb)
191+
SCOOP_CONTENT=$(base64 -w 0 < bucket/awakeonlan.json)
81192
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')
193+
82194
jq -n \
83195
--arg oid "$MAIN_OID" \
84-
--arg content "$CONTENT" \
85-
--arg version "${{ steps.version.outputs.version }}" \
196+
--arg formula "$FORMULA_CONTENT" \
197+
--arg scoop "$SCOOP_CONTENT" \
198+
--arg version "$VERSION" \
86199
'{
87200
query: "mutation($input: CreateCommitOnBranchInput!) { createCommitOnBranch(input: $input) { commit { oid } } }",
88201
variables: {
89202
input: {
90203
branch: { repositoryNameWithOwner: "logonoff/awake-on-lan", branchName: "main" },
91204
expectedHeadOid: $oid,
92-
message: { headline: ("chore: update formula to " + $version) },
93-
fileChanges: { additions: [{ path: "Formula/awakeonlan.rb", contents: $content }] }
205+
message: { headline: ("chore: update manifests to " + $version) },
206+
fileChanges: { additions: [
207+
{ path: "Formula/awakeonlan.rb", contents: $formula },
208+
{ path: "bucket/awakeonlan.json", contents: $scoop }
209+
] }
94210
}
95211
}
96212
}' | 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 }}
101213
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 }}
214+
# - name: Sync homebrew-bucket
215+
# run: |
216+
# gh api repos/logonoff/homebrew-bucket/dispatches \
217+
# -f event_type=sync
218+
# env:
219+
# GH_TOKEN: ${{ secrets.BUCKET_PAT }}
108220

109221
- name: Check if next branch can be fast-forwarded
110222
id: check-next
223+
env:
224+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111225
run: |
112226
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
227+
git fetch origin next main
228+
if git merge-base --is-ancestor origin/next origin/main; then
115229
echo "can_ff=true" >> "$GITHUB_OUTPUT"
116230
fi
117231
fi
118232
119233
- name: Fast-forward next branch
120234
if: steps.check-next.outputs.can_ff == 'true'
121-
run: git push origin HEAD:next
235+
run: git push origin origin/main:next
122236
env:
123237
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import os
2+
import sys
3+
4+
if getattr(sys, 'frozen', False):
5+
base = sys._MEIPASS
6+
os.environ['GSETTINGS_SCHEMA_DIR'] = os.path.join(base, 'share', 'glib-2.0', 'schemas')
7+
os.environ['GDK_PIXBUF_MODULE_FILE'] = os.path.join(base, 'lib', 'gdk-pixbuf-2.0', '2.10.0', 'loaders.cache')
8+
os.environ['GDK_PIXBUF_MODULEDIR'] = os.path.join(base, 'lib', 'gdk-pixbuf-2.0', '2.10.0', 'loaders')
9+
os.environ['XDG_DATA_DIRS'] = os.path.join(base, 'share')
10+
os.environ['GTK_DATA_PREFIX'] = base

awakeonlan.spec

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
},
39+
},
40+
runtime_hooks=['_packaging/runtime_hook.py'],
41+
)
42+
43+
pyz = PYZ(a.pure)
44+
45+
exe = EXE(
46+
pyz,
47+
a.scripts,
48+
[],
49+
exclude_binaries=True,
50+
name='awakeonlan',
51+
console=False,
52+
icon='awakeonlan.ico',
53+
)
54+
55+
coll = COLLECT(
56+
exe,
57+
a.binaries,
58+
a.datas,
59+
name='awakeonlan',
60+
)

bucket/awakeonlan.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
"bin": "awakeonlan\\awakeonlan.exe"
12+
}
13+
},
14+
"shortcuts": [
15+
[
16+
"awakeonlan\\awakeonlan.exe",
17+
"Awake on LAN"
18+
]
19+
],
20+
"bin": "awakeonlan.exe",
21+
"checkver": {
22+
"github": "https://github.com/logonoff/awake-on-lan"
23+
},
24+
"autoupdate": {
25+
"architecture": {
26+
"64bit": {
27+
"url": "https://github.com/logonoff/awake-on-lan/releases/download/$version/awakeonlan-$version-windows-x86_64.zip"
28+
}
29+
}
30+
}
31+
}

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/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)