Skip to content

Commit 595454a

Browse files
committed
Version fixes
1 parent 324f12e commit 595454a

File tree

4 files changed

+45
-21
lines changed

4 files changed

+45
-21
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ jobs:
8888
# Extract numeric version only (remove .dev0, +build, etc.) for VersionInfoVersion
8989
BASE_VERSION=$(echo "$VERSION" | sed -E 's/([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
9090
# VersionInfoVersion requires 4 numeric components (Major.Minor.Patch.Build)
91-
VERSION_INFO="${BASE_VERSION}.0"
91+
# Use GitHub Run Number as the Build component to ensure unique, increasing versions for upgrades
92+
VERSION_INFO="${BASE_VERSION}.${{ github.run_number }}"
9293
# For MyAppVersion: use full version for dev (with commit ID), but remove commit ID for beta/stable
9394
if [[ "${{ github.event.inputs.release_type }}" == "development" ]]; then
9495
# Dev release: keep full version with commit ID (e.g., "2026.1.2.dev0+9d07a00")
@@ -208,7 +209,8 @@ jobs:
208209
# Extract numeric version only (remove .dev0, +build, etc.) for VersionInfoVersion
209210
BASE_VERSION=$(echo "$DEV_VERSION" | sed -E 's/([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
210211
# VersionInfoVersion requires 4 numeric components (Major.Minor.Patch.Build)
211-
VERSION_INFO="${BASE_VERSION}.0"
212+
# Use GitHub Run Number as the Build component to ensure unique, increasing versions for upgrades
213+
VERSION_INFO="${BASE_VERSION}.${{ github.run_number }}"
212214
# For dev releases: MyAppVersion should include commit ID (full DEV_VERSION)
213215
# MyAppVersionNumeric should be numeric only (BASE_VERSION)
214216
sed -i "s/^\([[:space:]]*\)#define MyAppVersion \".*\"/\1#define MyAppVersion \"$DEV_VERSION\"/" switchcraft.iss
@@ -417,7 +419,7 @@ jobs:
417419
418420
cleanup_releases:
419421
name: Cleanup Old Releases
420-
needs: [create_release]
422+
needs: [prepare_release]
421423
runs-on: ubuntu-latest
422424
permissions:
423425
contents: write

scripts/build_release.ps1

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ param (
5252
[switch]$Addons,
5353
[switch]$Installer,
5454
[switch]$All,
55-
[switch]$LocalDev
55+
[switch]$LocalDev,
56+
[int]$BuildNumber = 0
5657
)
5758

5859
$ErrorActionPreference = "Stop"
@@ -66,6 +67,7 @@ $IsWinBuild = $env:OS -match 'Windows_NT' -or $PSVersionTable.Platform -eq 'Win3
6667
$IsLinBuild = $PSVersionTable.Platform -eq 'Unix' -and -not ($IsMacBuild = (uname) -eq 'Darwin')
6768
$IsMacBuild = $IsMacBuild -or ($PSVersionTable.Platform -eq 'Unix' -and (uname) -eq 'Darwin')
6869

70+
6971
Write-Host "==========================================" -ForegroundColor Cyan
7072
Write-Host " SwitchCraft Release Builder " -ForegroundColor Cyan
7173
Write-Host "==========================================" -ForegroundColor Cyan
@@ -153,13 +155,14 @@ Write-Host "Project Root: $RepoRoot" -ForegroundColor Gray
153155
# --- Version Extraction ---
154156
function Extract-VersionInfo {
155157
param(
156-
[string]$VersionString
158+
[string]$VersionString,
159+
[int]$BuildNum = 0
157160
)
158161
# Extract numeric version only (remove .dev0, +build, -dev, etc.) for VersionInfoVersion
159162
# Pattern: extract MAJOR.MINOR.PATCH from any version format
160163
$Numeric = if ($VersionString -match '^(\d+\.\d+\.\d+)') { $Matches[1] } else { $VersionString -replace '[^0-9.].*', '' }
161164
# VersionInfoVersion requires 4 numeric components (Major.Minor.Patch.Build)
162-
$Info = "$Numeric.0"
165+
$Info = "$Numeric.$BuildNum"
163166
return @{
164167
Full = $VersionString
165168
Numeric = $Numeric
@@ -174,21 +177,21 @@ $RawFallbackVersion = if ($env:SWITCHCRAFT_VERSION) { $env:SWITCHCRAFT_VERSION }
174177
# Strip common prefixes like "v" and whitespace
175178
$CleanedFallbackVersion = $RawFallbackVersion.Trim() -replace '^v', ''
176179
# Extract version info from cleaned value
177-
$FallbackVersionInfo = Extract-VersionInfo -VersionString $CleanedFallbackVersion
180+
$FallbackVersionInfo = Extract-VersionInfo -VersionString $CleanedFallbackVersion -BuildNum $BuildNumber
178181
# Validate that the numeric component is non-empty and matches MAJOR.MINOR.PATCH pattern
179182
$IsValidFallback = -not [string]::IsNullOrWhiteSpace($FallbackVersionInfo.Numeric) -and
180183
$FallbackVersionInfo.Numeric -match '^\d+\.\d+\.\d+$'
181184
if (-not $IsValidFallback) {
182185
Write-Warning "Fallback version from SWITCHCRAFT_VERSION is malformed (got: '$($FallbackVersionInfo.Numeric)'), expected MAJOR.MINOR.PATCH format. Using hardcoded default: 2026.1.5"
183186
$FallbackVersion = "2026.1.5"
184-
$VersionInfo = Extract-VersionInfo -VersionString $FallbackVersion
187+
$VersionInfo = Extract-VersionInfo -VersionString $FallbackVersion -BuildNum $BuildNumber
185188
} else {
186189
$FallbackVersion = $CleanedFallbackVersion
187190
$VersionInfo = $FallbackVersionInfo
188191
}
189192
# Ensure Info still appends a fourth component (Build number)
190193
if (-not $VersionInfo.Info -match '\.\d+$') {
191-
$VersionInfo.Info = "$($VersionInfo.Numeric).0"
194+
$VersionInfo.Info = "$($VersionInfo.Numeric).$BuildNumber"
192195
}
193196
$AppVersion = $VersionInfo.Full
194197
$AppVersionNumeric = $VersionInfo.Numeric
@@ -198,13 +201,13 @@ if (Test-Path $PyProjectFile) {
198201
try {
199202
$VersionLine = Get-Content -Path $PyProjectFile | Select-String "version = " | Select-Object -First 1
200203
if ($VersionLine -match 'version = "(.*)"') {
201-
$VersionInfo = Extract-VersionInfo -VersionString $Matches[1]
204+
$VersionInfo = Extract-VersionInfo -VersionString $Matches[1] -BuildNum $BuildNumber
202205
# Validate that the parsed version is non-empty and well-formed (MAJOR.MINOR.PATCH format)
203206
$IsValidVersion = -not [string]::IsNullOrWhiteSpace($VersionInfo.Numeric) -and
204207
$VersionInfo.Numeric -match '^\d+\.\d+\.\d+$'
205208
if (-not $IsValidVersion) {
206209
Write-Warning "Parsed version from pyproject.toml is malformed (got: '$($VersionInfo.Numeric)'), expected MAJOR.MINOR.PATCH format. Using fallback: $FallbackVersion"
207-
$VersionInfo = Extract-VersionInfo -VersionString $FallbackVersion
210+
$VersionInfo = Extract-VersionInfo -VersionString $FallbackVersion -BuildNum $BuildNumber
208211
}
209212
$AppVersion = $VersionInfo.Full
210213
$AppVersionNumeric = $VersionInfo.Numeric

scripts/generate_splash.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ def generate_splash(version=None, output_path=None):
2020
# Fonts (Windows standard)
2121
font_dir = Path("C:/Windows/Fonts")
2222
try:
23-
# Reduced font sizes by 20%
24-
font_main = ImageFont.truetype(str(font_dir / "segoeuib.ttf"), 48) # Reduced from 60
25-
font_sub = ImageFont.truetype(str(font_dir / "segoeui.ttf"), 18) # Reduced from 22
26-
font_hint = ImageFont.truetype(str(font_dir / "segoeui.ttf"), 13) # Reduced from 16
27-
font_ver = ImageFont.truetype(str(font_dir / "consola.ttf"), 11) # Reduced from 14
23+
# Reduced font sizes by another 15% (approx)
24+
font_main = ImageFont.truetype(str(font_dir / "segoeuib.ttf"), 40) # Reduced from 48
25+
font_sub = ImageFont.truetype(str(font_dir / "segoeui.ttf"), 15) # Reduced from 18
26+
font_hint = ImageFont.truetype(str(font_dir / "segoeui.ttf"), 11) # Reduced from 13
27+
font_ver = ImageFont.truetype(str(font_dir / "consola.ttf"), 10) # Reduced from 11
2828
except Exception:
2929
# Fallback to default if fonts not found
3030
font_main = ImageFont.load_default()
@@ -33,22 +33,22 @@ def generate_splash(version=None, output_path=None):
3333
font_ver = ImageFont.load_default()
3434

3535
# Create background (Modern Dark Gray/Blue)
36-
# Reduced image dimensions by 20%
37-
width, height = 640, 400 # Reduced from 800, 500
36+
# Reduced image dimensions by another 15% (Target: ~15% smaller area/dims)
37+
width, height = 544, 340 # Reduced from 640, 400
3838
background_color = (30, 30, 40) # Dark Navy Gray
3939
img = Image.new('RGB', (width, height), color=background_color)
4040
draw = ImageDraw.Draw(img)
4141

4242
# Load and scale logo
4343
if logo_path.exists():
4444
logo = Image.open(logo_path).convert("RGBA")
45-
# Resize logo to fit well (Reduced from 200 to 160)
46-
logo_size = 160
45+
# Resize logo to fit well (Reduced from 160 to 136)
46+
logo_size = 136
4747
logo.thumbnail((logo_size, logo_size), Image.Resampling.LANCZOS)
4848

4949
# Center logo horizontally, slightly above middle
5050
logo_x = (width - logo.width) // 2
51-
logo_y = height // 2 - logo.height - 40 # Reduced offset
51+
logo_y = height // 2 - logo.height - 35 # Reduced offset
5252
img.paste(logo, (logo_x, logo_y), logo)
5353

5454
# Add Text

src/switchcraft/main.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,26 @@ def legacy_show_snack(snack):
586586
elif hasattr(page, "window_prevent_close"):
587587
page.window_prevent_close = False
588588
except Exception:
589+
except Exception:
590+
pass
591+
592+
# CRITICAL: Close Splash Screen on Error if it's still running
593+
try:
594+
import pyi_splash
595+
if pyi_splash.is_alive():
596+
pyi_splash.close()
597+
print("Closed PyInstaller splash screen (Error Handler)")
598+
except ImportError:
589599
pass
600+
except Exception:
601+
pass
602+
603+
if splash_proc:
604+
try:
605+
splash_proc.terminate()
606+
print("Terminated external splash process (Error Handler)")
607+
except Exception:
608+
pass
590609

591610
dump_file = write_crash_dump(sys.exc_info())
592611
dump_folder = str(dump_file.parent)

0 commit comments

Comments
 (0)