-
Notifications
You must be signed in to change notification settings - Fork 0
322 lines (266 loc) · 11.2 KB
/
build-cross-platform.yml
File metadata and controls
322 lines (266 loc) · 11.2 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
name: Build Cross-Platform Packages
on:
workflow_dispatch:
release:
types: [created, edited]
push:
tags:
- 'v*'
# Security: Restrict permissions
permissions:
contents: write
actions: read
security-events: write
env:
PYTHON_VERSION: '3.10'
jobs:
get-version:
name: Get Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Get version
id: version
run: |
VERSION=$(python scripts/version.py)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
build-windows:
name: Build Windows Executable
runs-on: windows-latest
needs: get-version
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'requirements_windows_build.txt'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_windows_build.txt
- name: Build executable
shell: pwsh
run: |
echo "Building Windows executable for Route Planner v${{ needs.get-version.outputs.version }}"
pyinstaller scripts/windows_build.spec
- name: Verify executable
run: |
if (Test-Path "dist\RoutePlanner.exe") {
$size = (Get-Item "dist\RoutePlanner.exe").Length / 1MB
Write-Output "✅ Executable created successfully: $([math]::Round($size, 1)) MB"
} else {
Write-Error "❌ Executable not found!"
exit 1
}
- name: Create bundled package
run: |
# Download Visual C++ Redistributable
$vcredistUrl = "https://aka.ms/vs/17/release/vc_redist.x64.exe"
$vcredistPath = "dist\RoutePlanner_Bundled\vc_redist.x64.exe"
# Create directory structure
New-Item -ItemType Directory -Path "dist\RoutePlanner_Bundled" -Force
# Copy files
Copy-Item "dist\RoutePlanner.exe" "dist\RoutePlanner_Bundled\"
Copy-Item "README.md" "dist\RoutePlanner_Bundled\"
Copy-Item "LICENSE" "dist\RoutePlanner_Bundled\" -ErrorAction SilentlyContinue
# Download VC++ Redistributable
try {
Invoke-WebRequest -Uri $vcredistUrl -OutFile $vcredistPath -TimeoutSec 60
} catch {
Write-Warning "Failed to download VC++ Redistributable: $_"
}
# Create setup script content
$setupContent = "echo Installing Route Planner...`r`necho.`r`necho Step 1: Installing Visual C++ Redistributable...`r`nstart /wait vc_redist.x64.exe /quiet /norestart`r`nif %ERRORLEVEL% NEQ 0 (`r`n echo Warning: VC++ Redistributable installation may have failed.`r`n echo If the app doesn't work, run vc_redist.x64.exe manually.`r`n)`r`necho.`r`necho Step 2: Starting Route Planner...`r`nstart RoutePlanner.exe`r`necho.`r`necho Setup complete! Route Planner should now be running.`r`npause"
$setupContent | Out-File -FilePath "dist\RoutePlanner_Bundled\setup.bat" -Encoding ASCII
# Create zip file
Compress-Archive -Path "dist\RoutePlanner_Bundled\*" -DestinationPath "dist\RoutePlanner-${{ needs.get-version.outputs.version }}-Bundled.zip" -Force
Write-Output "✅ Bundled package created successfully"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: windows-executable
path: |
dist/RoutePlanner.exe
dist/RoutePlanner-*.zip
retention-days: 30
build-python-package:
name: Build Python Package
runs-on: ubuntu-latest
needs: get-version
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'requirements.txt'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build wheel setuptools
- name: Build package
run: |
python -m build
- name: Verify package
run: |
ls -la dist/
pip install dist/*.whl
python -c "import route_planner; print(f'Package version: {route_planner.__version__}')"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: python-package
path: dist/*
retention-days: 30
build-appimage:
name: Build Linux AppImage
runs-on: ubuntu-22.04 # Updated from 20.04 due to retirement
needs: get-version
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'requirements.txt'
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y wget fuse libfuse2 desktop-file-utils
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pillow PyInstaller
- name: Install AppImage tools
run: |
wget -q https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool
chmod +x appimagetool
sudo mv appimagetool /usr/local/bin/
- name: Build AppImage
run: |
python scripts/build_appimage.py
- name: Verify AppImage
run: |
if [ -f build/appimage/RoutePlanner-*.AppImage ]; then
ls -la build/appimage/RoutePlanner-*.AppImage
echo "✅ AppImage created successfully"
else
echo "❌ AppImage build failed"
exit 1
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: linux-appimage
path: build/appimage/RoutePlanner-*.AppImage
retention-days: 30
build-flatpak:
name: Build Linux Flatpak
runs-on: ubuntu-latest
needs: get-version
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'requirements.txt'
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install Flatpak tools
run: |
sudo apt-get update
sudo apt-get install -y flatpak flatpak-builder
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
sudo flatpak install -y flathub org.freedesktop.Platform//23.08 org.freedesktop.Sdk//23.08
- name: Build Flatpak
run: |
python scripts/build_flatpak.py
- name: Verify Flatpak
run: |
if [ -f RoutePlanner-*.flatpak ]; then
ls -la RoutePlanner-*.flatpak
echo "✅ Flatpak created successfully"
else
echo "❌ Flatpak build failed"
exit 1
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: linux-flatpak
path: RoutePlanner-*.flatpak
retention-days: 30
upload-to-release:
name: Upload to Release
needs: [get-version, build-windows, build-python-package, build-appimage, build-flatpak]
runs-on: ubuntu-latest
if: github.event_name == 'release' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display structure of artifacts
run: ls -R artifacts/
- name: Prepare release assets
run: |
mkdir -p release-assets
# Find and copy Windows executable
find artifacts/windows-executable -name "RoutePlanner.exe" -exec cp {} release-assets/ \;
# Find and copy Windows bundled package
find artifacts/windows-executable -name "RoutePlanner-*.zip" -exec cp {} release-assets/RoutePlanner-${{ needs.get-version.outputs.version }}-Bundled.zip \;
# Find and copy Python wheel
find artifacts/python-package -name "*.whl" -exec cp {} release-assets/route_planner-${{ needs.get-version.outputs.version }}-py3-none-any.whl \;
# Find and copy AppImage
find artifacts/linux-appimage -name "RoutePlanner-*.AppImage" -exec cp {} release-assets/RoutePlanner-${{ needs.get-version.outputs.version }}-x86_64.AppImage \;
# Find and copy Flatpak
find artifacts/linux-flatpak -name "RoutePlanner-*.flatpak" -exec cp {} release-assets/RoutePlanner-${{ needs.get-version.outputs.version }}.flatpak \;
# List final assets
ls -la release-assets/
- name: Upload release assets
uses: softprops/action-gh-release@v1
with:
files: release-assets/*
tag_name: ${{ github.ref_name }}
name: "Route Planner ${{ needs.get-version.outputs.version }}"
body: |
## 🚀 Route Planner ${{ needs.get-version.outputs.version }}
### Download Options:
**Windows Users:**
- `RoutePlanner.exe` - Standalone executable
- `RoutePlanner-${{ needs.get-version.outputs.version }}-Bundled.zip` - Includes VC++ Redistributable
**Linux Users:**
- `RoutePlanner-${{ needs.get-version.outputs.version }}-x86_64.AppImage` - Universal Linux package
- `RoutePlanner-${{ needs.get-version.outputs.version }}.flatpak` - Flatpak package
**Python Users (All Platforms):**
- `route_planner-${{ needs.get-version.outputs.version }}-py3-none-any.whl` - Python wheel package
### Installation:
- **Windows**: Download and run `RoutePlanner.exe`
- **Linux AppImage**: Download, make executable (`chmod +x`), and run
- **Linux Flatpak**: Install with `flatpak install RoutePlanner-*.flatpak`
- **Python**: Install with `pip install route_planner-*.whl`
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}