Skip to content

Commit e2b1e71

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 e2b1e71

6 files changed

Lines changed: 230 additions & 26 deletions

File tree

.github/workflows/release.yml

Lines changed: 131 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,158 @@ 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+
107+
- name: Prepare entry point
108+
run: |
109+
VERSION=${{ needs.release.outputs.version }}
110+
sed -i "s|@PYTHON@|/usr/bin/python3|" src/awakeonlan.in
111+
sed -i "s|@VERSION@|$VERSION|" src/awakeonlan.in
112+
sed -i "s|@pkgdatadir@|.|" src/awakeonlan.in
113+
sed -i "s|@localedir@|./locale|" src/awakeonlan.in
114+
115+
- name: Compile GResources
116+
run: |
117+
cp data/co.logonoff.awakeonlan.metainfo.xml.in data/co.logonoff.awakeonlan.metainfo.xml
118+
cd src
119+
glib-compile-resources --sourcedir=. --sourcedir=.. awakeonlan.gresource.xml --target=awakeonlan.gresource
120+
121+
- name: Compile GSettings schemas
122+
run: glib-compile-schemas data/
123+
124+
- name: Build with PyInstaller
125+
run: pyinstaller awakeonlan.spec
126+
127+
- name: Bundle additional resources
128+
run: |
129+
MSYS_ROOT="/$MSYSTEM"
130+
mkdir -p dist/awakeonlan/share/glib-2.0/schemas
131+
cp $MSYS_ROOT/share/glib-2.0/schemas/gschemas.compiled dist/awakeonlan/share/glib-2.0/schemas/ || true
132+
cp data/gschemas.compiled dist/awakeonlan/share/glib-2.0/schemas/ 2>/dev/null || true
133+
mkdir -p dist/awakeonlan/share/icons
134+
cp -r $MSYS_ROOT/share/icons/Adwaita dist/awakeonlan/share/icons/ || true
135+
cp -r $MSYS_ROOT/share/icons/hicolor dist/awakeonlan/share/icons/ || true
136+
137+
- name: Create ZIP archive
138+
shell: pwsh
139+
run: |
140+
Compress-Archive -Path dist/awakeonlan -DestinationPath awakeonlan-${{ needs.release.outputs.version }}-windows-x86_64.zip
141+
142+
- name: Calculate SHA256
143+
id: sha256
144+
shell: pwsh
145+
run: |
146+
$hash = (Get-FileHash awakeonlan-${{ needs.release.outputs.version }}-windows-x86_64.zip -Algorithm SHA256).Hash.ToLower()
147+
echo "hash=$hash" >> $env:GITHUB_OUTPUT
148+
149+
- name: Upload to release
150+
shell: pwsh
151+
env:
152+
GH_TOKEN: ${{ github.token }}
153+
run: |
154+
gh release upload ${{ needs.release.outputs.version }} awakeonlan-${{ needs.release.outputs.version }}-windows-x86_64.zip
155+
156+
update-manifests:
157+
runs-on: ubuntu-latest
158+
needs: [release, windows-build]
159+
permissions:
160+
contents: write
161+
162+
steps:
163+
- name: Checkout repository
164+
uses: actions/checkout@v6
165+
166+
- name: Update manifests
167+
env:
168+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77169
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)
170+
VERSION=${{ needs.release.outputs.version }}
171+
TARBALL_HASH=${{ needs.release.outputs.tarball-hash }}
172+
WINDOWS_HASH=${{ needs.windows-build.outputs.hash }}
173+
174+
# Update Homebrew formula
175+
sed -i "s/version \".*\"/version \"$VERSION\"/" Formula/awakeonlan.rb
176+
sed -i "s/sha256 \".*\"/sha256 \"$TARBALL_HASH\"/" Formula/awakeonlan.rb
177+
178+
# Update Scoop manifest
179+
sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" bucket/awakeonlan.json
180+
sed -i "s|download/.*/awakeonlan-.*-windows-x86_64.zip|download/${VERSION}/awakeonlan-${VERSION}-windows-x86_64.zip|" bucket/awakeonlan.json
181+
sed -i "s/\"hash\": \".*\"/\"hash\": \"$WINDOWS_HASH\"/" bucket/awakeonlan.json
182+
183+
FORMULA_CONTENT=$(base64 -w 0 < Formula/awakeonlan.rb)
184+
SCOOP_CONTENT=$(base64 -w 0 < bucket/awakeonlan.json)
81185
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')
186+
82187
jq -n \
83188
--arg oid "$MAIN_OID" \
84-
--arg content "$CONTENT" \
85-
--arg version "${{ steps.version.outputs.version }}" \
189+
--arg formula "$FORMULA_CONTENT" \
190+
--arg scoop "$SCOOP_CONTENT" \
191+
--arg version "$VERSION" \
86192
'{
87193
query: "mutation($input: CreateCommitOnBranchInput!) { createCommitOnBranch(input: $input) { commit { oid } } }",
88194
variables: {
89195
input: {
90196
branch: { repositoryNameWithOwner: "logonoff/awake-on-lan", branchName: "main" },
91197
expectedHeadOid: $oid,
92-
message: { headline: ("chore: update formula to " + $version) },
93-
fileChanges: { additions: [{ path: "Formula/awakeonlan.rb", contents: $content }] }
198+
message: { headline: ("chore: update manifests to " + $version) },
199+
fileChanges: { additions: [
200+
{ path: "Formula/awakeonlan.rb", contents: $formula },
201+
{ path: "bucket/awakeonlan.json", contents: $scoop }
202+
] }
94203
}
95204
}
96205
}' | 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 }}
101206
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 }}
207+
# - name: Sync homebrew-bucket
208+
# run: |
209+
# gh api repos/logonoff/homebrew-bucket/dispatches \
210+
# -f event_type=sync
211+
# env:
212+
# GH_TOKEN: ${{ secrets.BUCKET_PAT }}
108213

109214
- name: Check if next branch can be fast-forwarded
110215
id: check-next
216+
env:
217+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111218
run: |
112219
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
220+
git fetch origin next main
221+
if git merge-base --is-ancestor origin/next origin/main; then
115222
echo "can_ff=true" >> "$GITHUB_OUTPUT"
116223
fi
117224
fi
118225
119226
- name: Fast-forward next branch
120227
if: steps.check-next.outputs.can_ff == 'true'
121-
run: git push origin HEAD:next
228+
run: git push origin origin/main:next
122229
env:
123230
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

awakeonlan.spec

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

bucket/awakeonlan.json

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

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)