Skip to content

Commit c734c3f

Browse files
committed
ci: enhance CI workflows for icon generation on Windows and macOS; update frontend deployment process with Vercel integration
1 parent 29bd127 commit c734c3f

File tree

4 files changed

+115
-28
lines changed

4 files changed

+115
-28
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,44 @@ jobs:
110110
echo "Version will be: $VERSION"
111111
echo "version=$VERSION" >> $GITHUB_OUTPUT
112112
113+
- name: Generate platform icons (Windows)
114+
if: runner.os == 'Windows'
115+
shell: pwsh
116+
run: |
117+
# Install ImageMagick if needed
118+
if (!(Get-Command magick -ErrorAction SilentlyContinue)) {
119+
choco install imagemagick.app -y
120+
}
121+
122+
# Convert SVG to ICO
123+
magick convert -background none assets/icon.svg -define icon:auto-resize=256,128,64,48,32,16 assets/icon.ico
124+
125+
- name: Generate platform icons (macOS)
126+
if: runner.os == 'macOS'
127+
run: |
128+
brew install imagemagick
129+
130+
# Create iconset directory
131+
mkdir icon.iconset
132+
133+
# Convert SVG to PNG in different sizes
134+
convert -background none -resize 16x16 assets/icon.svg icon.iconset/icon_16x16.png
135+
convert -background none -resize 32x32 assets/icon.svg icon.iconset/[email protected]
136+
convert -background none -resize 32x32 assets/icon.svg icon.iconset/icon_32x32.png
137+
convert -background none -resize 64x64 assets/icon.svg icon.iconset/[email protected]
138+
convert -background none -resize 128x128 assets/icon.svg icon.iconset/icon_128x128.png
139+
convert -background none -resize 256x256 assets/icon.svg icon.iconset/[email protected]
140+
convert -background none -resize 256x256 assets/icon.svg icon.iconset/icon_256x256.png
141+
convert -background none -resize 512x512 assets/icon.svg icon.iconset/[email protected]
142+
convert -background none -resize 512x512 assets/icon.svg icon.iconset/icon_512x512.png
143+
convert -background none -resize 1024x1024 assets/icon.svg icon.iconset/[email protected]
144+
145+
# Convert iconset to icns
146+
iconutil -c icns icon.iconset
147+
148+
# Move to assets directory
149+
mv icon.icns assets/icon.icns
150+
113151
- name: Install system dependencies (Windows)
114152
if: runner.os == 'Windows'
115153
run: |

.github/workflows/frontend.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,31 @@ jobs:
3030
- name: Install dependencies
3131
run: npm ci
3232

33+
- name: Run tests
34+
run: npm test
3335

3436
deploy:
3537
needs: test
3638
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
3739
runs-on: ubuntu-latest
40+
env:
41+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
42+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
3843

3944
steps:
40-
- name: Deploy to Vercel
41-
run: |
42-
echo "Frontend deployment is handled by Vercel's GitHub integration"
43-
echo "Ensure Vercel GitHub integration is enabled and points to networkmonitor/web directory"
45+
- uses: actions/checkout@v4
46+
47+
- name: Install Vercel CLI
48+
run: npm install --global vercel@latest
49+
50+
- name: Pull Vercel Environment Information
51+
working-directory: networkmonitor/web
52+
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
53+
54+
- name: Build Project Artifacts
55+
working-directory: networkmonitor/web
56+
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
57+
58+
- name: Deploy Project Artifacts to Vercel
59+
working-directory: networkmonitor/web
60+
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}

assets/icon.svg

Lines changed: 27 additions & 18 deletions
Loading

build.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,43 @@ def create_spec_file():
3434
is_windows = platform.system() == "Windows"
3535
is_macos = platform.system() == "Darwin"
3636

37+
# Get absolute paths
38+
root_dir = os.path.dirname(os.path.abspath(__file__))
39+
assets_dir = os.path.join(root_dir, 'assets')
40+
3741
# Common options for all platforms - removed web/build from datas
3842
datas = [
39-
('assets', 'assets')
43+
(os.path.join(root_dir, 'assets'), 'assets')
4044
]
4145

42-
icon_path = 'assets/icon.ico' if is_windows else 'assets/icon.icns' if is_macos else None
46+
# Use absolute paths for icons
47+
icon_path = None
48+
if is_windows:
49+
icon_file = os.path.join(assets_dir, 'icon.ico')
50+
if os.path.exists(icon_file):
51+
icon_path = icon_file
52+
elif is_macos:
53+
icon_file = os.path.join(assets_dir, 'icon.icns')
54+
if os.path.exists(icon_file):
55+
icon_path = icon_file
56+
57+
if icon_path:
58+
print(f"Using icon from: {icon_path}")
59+
else:
60+
print("Warning: No platform-specific icon found")
4361

4462
spec_content = f"""# -*- mode: python ; coding: utf-8 -*-
63+
import os
4564
4665
block_cipher = None
4766
67+
# Get absolute paths
68+
root_dir = os.path.dirname(os.path.abspath(SPECPATH))
69+
assets_dir = os.path.join(root_dir, 'assets')
70+
4871
a = Analysis(
49-
['networkmonitor/cli.py'],
50-
pathex=[],
72+
[os.path.join(root_dir, 'networkmonitor', 'cli.py')],
73+
pathex=[root_dir],
5174
binaries=[],
5275
datas={datas},
5376
hiddenimports=['scapy.layers.all', 'engineio.async_drivers.threading'],
@@ -78,7 +101,7 @@ def create_spec_file():
78101

79102
if icon_path:
80103
spec_content += f"""
81-
icon=['{icon_path}'],"""
104+
icon=[r'{icon_path}'],"""
82105

83106
if is_macos:
84107
spec_content += """
@@ -125,7 +148,7 @@ def create_spec_file():
125148
app = BUNDLE(
126149
exe,
127150
name='NetworkMonitor.app',
128-
icon='assets/icon.icns',
151+
icon=os.path.join(assets_dir, 'icon.icns'),
129152
bundle_identifier='com.networkmonitor.app',
130153
info_plist={
131154
'CFBundleShortVersionString': '1.0.0',

0 commit comments

Comments
 (0)