Skip to content

Commit b345b03

Browse files
committed
Refactor Windows CI workflow to prepare self-contained runtime with Python and GTK, and update launcher to use VBS instead of MSYS2 batch file
1 parent 98e0280 commit b345b03

File tree

2 files changed

+58
-20
lines changed

2 files changed

+58
-20
lines changed

.github/workflows/windows.yml

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,26 +89,64 @@ jobs:
8989
rm -rf "$STAGE" && mkdir -p "$STAGE"
9090
# Copy installed prefix
9191
cp -r /opt/ssh-studio/* "$STAGE"/
92-
# Create a simple Windows launcher that runs via MSYS2 bash
93-
cat > "$STAGE/SSH-Studio (MSYS2).bat" << 'BAT'
94-
@echo off
95-
setlocal
96-
set "MSYSBASH=C:\\msys64\\ucrt64\\bin\\bash.exe"
97-
if exist "%MSYSBASH%" (
98-
for %%I in ("%~dp0.") do set "APPDIR_WIN=%%~fI"
99-
"%MSYSBASH%" -lc "APPDIR=\$(cygpath -u '$APPDIR_WIN'); APPDIR=\${APPDIR%/}; \"$APPDIR/bin/ssh-studio\" $*"
100-
) else (
101-
echo MSYS2 UCRT64 not found at C:\\msys64. Please install MSYS2 and required GTK/PyGObject runtime.
102-
pause
103-
)
104-
endlocal
105-
BAT
10692
# Produce a portable zip as well
10793
cd /c/_stage
10894
7z a SSH-Studio-portable.zip ssh-studio > /dev/null
109-
cp SSH-Studio-portable.zip /D/a/SSH-Studio/SSH-Studio/
95+
cp SSH-Studio-portable.zip /d/a/SSH-Studio/SSH-Studio/
11096
echo STAGE_WIN_PATH=C:\\_stage\\ssh-studio >> $GITHUB_OUTPUT
11197
98+
- name: Prepare self-contained runtime (Python embeddable + GTK runtime)
99+
shell: pwsh
100+
env:
101+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102+
run: |
103+
$ErrorActionPreference = 'Stop'
104+
$stage = 'C:\_stage\ssh-studio'
105+
New-Item -ItemType Directory -Force -Path $stage | Out-Null
106+
107+
# Download Python embeddable 3.12
108+
$pyUrl = 'https://www.python.org/ftp/python/3.12.11/python-3.12.11-embed-amd64.zip'
109+
$pyZip = "$env:RUNNER_TEMP\python-embed.zip"
110+
Invoke-WebRequest -Uri $pyUrl -OutFile $pyZip
111+
Expand-Archive -LiteralPath $pyZip -DestinationPath "$stage\python" -Force
112+
$pth = Join-Path "$stage\python" 'python312._pth'
113+
if (Test-Path $pth) {
114+
$content = Get-Content -Raw -Path $pth
115+
if ($content -notmatch 'import site') {
116+
Add-Content -Path $pth -Value "`r`nimport site`r`n"
117+
}
118+
}
119+
120+
# Download GTK runtime (gvsbuild release)
121+
$api = 'https://api.github.com/repos/wingtk/gvsbuild/releases/latest'
122+
$headers = @{ 'User-Agent' = 'github-actions'; 'Authorization' = "Bearer $env:GITHUB_TOKEN" }
123+
$rel = Invoke-RestMethod -Headers $headers -Uri $api -Method GET
124+
$asset = $rel.assets | Where-Object { $_.name -match 'gtk.*runtime.*(64|x86_64).*\.zip' } | Select-Object -First 1
125+
if (-not $asset) { throw 'Could not find GTK runtime asset in gvsbuild latest release.' }
126+
$gtkZip = "$env:RUNNER_TEMP\gtk-runtime.zip"
127+
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $gtkZip
128+
Expand-Archive -LiteralPath $gtkZip -DestinationPath "$stage\gtk_tmp" -Force
129+
$gtkOut = "$stage\gtk"
130+
New-Item -ItemType Directory -Force -Path $gtkOut | Out-Null
131+
$candidate = Get-ChildItem -Path "$stage\gtk_tmp" -Directory | Select-Object -First 1
132+
if ($candidate) { Copy-Item -Recurse -Force "$($candidate.FullName)\*" $gtkOut } else { Copy-Item -Recurse -Force "$stage\gtk_tmp\*" $gtkOut }
133+
Remove-Item -Recurse -Force "$stage\gtk_tmp"
134+
135+
# Create launcher.vbs (no console)
136+
$vbs = @'
137+
Set oShell = CreateObject("WScript.Shell")
138+
Set env = oShell.Environment("PROCESS")
139+
Set fso = CreateObject("Scripting.FileSystemObject")
140+
appDir = fso.GetAbsolutePathName(".")
141+
env("PATH") = appDir & "\\gtk\\bin;" & appDir & "\\python;" & env("PATH")
142+
env("PYTHONHOME") = appDir & "\\python"
143+
env("PYTHONPATH") = appDir & "\\lib\\python3.12\\site-packages"
144+
env("GI_TYPELIB_PATH") = appDir & "\\gtk\\lib\\girepository-1.0"
145+
env("XDG_DATA_DIRS") = appDir & "\\share;" & appDir & "\\gtk\\share"
146+
oShell.Run '"' & appDir & "\\python\\pythonw.exe" & '" -m ssh_studio.main', 0
147+
'@
148+
Set-Content -Encoding ASCII -Path "$stage\launcher.vbs" -Value $vbs
149+
112150
- name: Download Inno Setup
113151
run: |
114152
$url = "https://files.jrsoftware.org/is/6/innosetup-6.2.2.exe"
@@ -119,7 +157,7 @@ jobs:
119157
- name: Build Inno Setup installer
120158
run: |
121159
$version = if ($env:GITHUB_REF_NAME) { $env:GITHUB_REF_NAME } else { "dev" }
122-
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" /DAppName="SSH Studio" /DVersion="$version" /DSourceDir="C:\_stage\ssh-studio" "installer\ssh-studio.iss"
160+
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" /DAppName="SSH-Studio" /DVersion="$version" /DSourceDir="C:\_stage\ssh-studio" "installer\ssh-studio.iss"
123161
124162
- name: Upload artifacts
125163
uses: actions/upload-artifact@v4

installer/ssh-studio.iss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescrip
2828
Source: "{#SourceDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
2929

3030
[Icons]
31-
Name: "{group}\{#AppName}"; Filename: "{app}\SSH-Studio (MSYS2).bat"
31+
Name: "{group}\{#AppName}"; Filename: "{app}\launcher.vbs"
3232
Name: "{group}\{cm:UninstallProgram,{#AppName}}"; Filename: "{uninstallexe}"
33-
Name: "{autodesktop}\{#AppName}"; Filename: "{app}\SSH-Studio (MSYS2).bat"; Tasks: desktopicon
34-
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#AppName}"; Filename: "{app}\SSH-Studio (MSYS2).bat"; Tasks: quicklaunchicon
33+
Name: "{autodesktop}\{#AppName}"; Filename: "{app}\launcher.vbs"; Tasks: desktopicon
34+
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#AppName}"; Filename: "{app}\launcher.vbs"; Tasks: quicklaunchicon
3535

3636
[Run]
37-
Filename: "{app}\SSH-Studio (MSYS2).bat"; Description: "{cm:LaunchProgram,{#AppName}}"; Flags: nowait postinstall skipifsilent
37+
Filename: "{app}\launcher.vbs"; Description: "{cm:LaunchProgram,{#AppName}}"; Flags: nowait postinstall skipifsilent

0 commit comments

Comments
 (0)