Skip to content

Commit 8b23e62

Browse files
committed
Refactor build scripts and version management; update to version 1.0.6. Enhanced build.bat to support versioned executable names and improved error handling. Updated GitHub Actions workflow to reflect changes in executable naming conventions and added checks for non-ASCII characters in paths to prevent build failures.
1 parent 4c4f810 commit 8b23e62

File tree

10 files changed

+510
-195
lines changed

10 files changed

+510
-195
lines changed

.github/workflows/build-and-release.yml

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,31 @@ jobs:
4545
}
4646
4747
- name: Build executable
48+
id: build_executable
4849
run: |
49-
Write-Host "Building UE-Git-Plugin-Manager.exe..."
50-
go build -o dist/UE-Git-Plugin-Manager.exe .
50+
$version = ${{ steps.get_version.outputs.version }}
51+
$exeName = "UE-Git-Plugin-Manager-v$version.exe"
52+
$exePath = "dist/$exeName"
53+
Write-Host "Building $exeName..."
54+
go build -o $exePath .
5155
if ($LASTEXITCODE -ne 0) {
5256
Write-Error "Build failed!"
5357
exit 1
5458
}
5559
Write-Host "Build successful!"
60+
echo "exe_name=$exeName" >> $env:GITHUB_OUTPUT
61+
echo "exe_path=$exePath" >> $env:GITHUB_OUTPUT
5662
5763
- name: Verify executable
5864
run: |
59-
if (Test-Path "dist/UE-Git-Plugin-Manager.exe") {
60-
$fileSize = (Get-Item "dist/UE-Git-Plugin-Manager.exe").Length
61-
Write-Host "Executable created successfully. Size: $fileSize bytes"
65+
$exeName = "${{ steps.build_executable.outputs.exe_name }}"
66+
$exePath = "${{ steps.build_executable.outputs.exe_path }}"
67+
if (Test-Path $exePath) {
68+
$fileSize = (Get-Item $exePath).Length
69+
Write-Host "Executable created successfully: $exeName"
70+
Write-Host "Size: $fileSize bytes"
6271
} else {
63-
Write-Error "Executable not found!"
72+
Write-Error "Executable not found: $exePath"
6473
exit 1
6574
}
6675
@@ -71,19 +80,22 @@ jobs:
7180
7281
- name: Create Release
7382
run: |
74-
gh release create "v${{ steps.get_version.outputs.version }}" `
75-
--title "Release v${{ steps.get_version.outputs.version }}" `
76-
--notes "## Changes in v${{ steps.get_version.outputs.version }}
77-
78-
This release includes the latest changes from the main branch.
79-
80-
### Download
81-
Download the \`UE-Git-Plugin-Manager.exe\` file below and run it to use the latest version.
82-
83-
### Installation
84-
1. Download \`UE-Git-Plugin-Manager.exe\`
85-
2. Run the executable
86-
3. Follow the setup wizard" `
87-
./dist/UE-Git-Plugin-Manager.exe
83+
$version = "${{ steps.get_version.outputs.version }}"
84+
$exeName = "${{ steps.build_executable.outputs.exe_name }}"
85+
$exePath = "${{ steps.build_executable.outputs.exe_path }}"
86+
$notes = @"
87+
## Changes in v$version
88+
89+
This release includes the latest changes from the main branch.
90+
91+
### Download
92+
Download the ``$exeName`` file below and run it to use the latest version.
93+
94+
### Installation
95+
1. Download ``$exeName``
96+
2. Run the executable
97+
3. Follow the setup wizard
98+
"@
99+
gh release create "v$version" --title "Release v$version" --notes $notes $exePath
88100
env:
89101
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}

VERSION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
1.0.5
1+
1.0.6
2+
23

assets/demo.mp4

16 MB
Binary file not shown.

build.bat

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@echo off
2+
setlocal enabledelayedexpansion
23
echo Building UE Git Plugin Manager...
34

45
REM Check if Go is installed
@@ -34,33 +35,45 @@ go mod tidy
3435
REM Create dist directory if it doesn't exist
3536
if not exist "dist" mkdir dist
3637

37-
REM Check if UE-Git-Plugin-Manager.exe is running and stop it
38-
tasklist /FI "IMAGENAME eq UE-Git-Plugin-Manager.exe" 2>NUL | find /I /N "UE-Git-Plugin-Manager.exe">NUL
38+
REM Read version from VERSION file
39+
set VERSION=1.0.0
40+
if exist "VERSION" (
41+
for /f "usebackq tokens=*" %%v in ("VERSION") do set VERSION=%%v
42+
set VERSION=!VERSION: =!
43+
)
44+
echo Building version: !VERSION!
45+
46+
REM Build executable name with version
47+
set EXE_NAME=UE-Git-Plugin-Manager-v!VERSION!.exe
48+
set EXE_PATH=dist\!EXE_NAME!
49+
50+
REM Check if the versioned executable is running and stop it
51+
tasklist /FI "IMAGENAME eq !EXE_NAME!" 2>NUL | find /I /N "!EXE_NAME!">NUL
3952
if "%ERRORLEVEL%"=="0" (
40-
echo UE-Git-Plugin-Manager.exe is currently running. Stopping it...
41-
taskkill /F /IM UE-Git-Plugin-Manager.exe >NUL 2>&1
53+
echo !EXE_NAME! is currently running. Stopping it...
54+
taskkill /F /IM !EXE_NAME! >NUL 2>&1
4255
timeout /t 2 >NUL
4356
)
4457

4558
REM Remove any existing executable and temporary files
46-
if exist "dist\UE-Git-Plugin-Manager.exe" del /F /Q "dist\UE-Git-Plugin-Manager.exe" >NUL 2>&1
47-
if exist "dist\UE-Git-Plugin-Manager.exe~" del /F /Q "dist\UE-Git-Plugin-Manager.exe~" >NUL 2>&1
59+
if exist "!EXE_PATH!" del /F /Q "!EXE_PATH!" >NUL 2>&1
60+
if exist "!EXE_PATH!~" del /F /Q "!EXE_PATH!~" >NUL 2>&1
4861

4962
REM Build the executable
5063
echo Building executable...
51-
go build -o dist/UE-Git-Plugin-Manager.exe .
64+
go build -o "!EXE_PATH!" .
5265

5366
if %ERRORLEVEL% EQU 0 (
5467
echo.
5568
echo Build successful!
56-
echo UE-Git-Plugin-Manager.exe created in dist/ folder.
69+
echo !EXE_NAME! created in dist/ folder.
5770
echo.
58-
echo You can now run the application by double-clicking dist/UE-Git-Plugin-Manager.exe
71+
echo You can now run the application by double-clicking dist\!EXE_NAME!
5972

6073
REM Clean up any temporary files that might have been created
61-
if exist "dist\UE-Git-Plugin-Manager.exe~" (
74+
if exist "!EXE_PATH!~" (
6275
echo Cleaning up temporary files...
63-
del /F /Q "dist\UE-Git-Plugin-Manager.exe~" >NUL 2>&1
76+
del /F /Q "!EXE_PATH!~" >NUL 2>&1
6477
)
6578
) else (
6679
echo.

internal/config/config.go

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ package config
22

33
import (
44
"encoding/json"
5+
"fmt"
56
"os"
67
"os/user"
78
"path/filepath"
89
"time"
10+
11+
"ue-git-plugin-manager/internal/utils"
912
)
1013

1114
// Config represents the application configuration
@@ -48,6 +51,8 @@ func New(exeDir string) *Manager {
4851
}
4952

5053
// getUserConfigDir returns the user's config directory for the application
54+
// If the default path contains non-ASCII characters, uses a fallback location
55+
// to prevent UBT/MSVC build failures
5156
func getUserConfigDir() string {
5257
// Get the current user
5358
usr, err := user.Current()
@@ -60,12 +65,28 @@ func getUserConfigDir() string {
6065
// Use the user's config directory
6166
// On Windows: %APPDATA%\ue-git-plugin-manager
6267
// On Linux/macOS: ~/.config/ue-git-plugin-manager
63-
configDir := filepath.Join(usr.HomeDir, "AppData", "Roaming", "ue-git-plugin-manager")
68+
defaultConfigDir := filepath.Join(usr.HomeDir, "AppData", "Roaming", "ue-git-plugin-manager")
69+
70+
// Check if the default path contains non-ASCII characters
71+
// Unreal Build Tool and MSVC compiler fail when paths contain non-ASCII characters
72+
if utils.HasNonASCIICharacters(defaultConfigDir) {
73+
// Use fallback location: C:\ProgramData\ue-git-plugin-manager
74+
// Use filepath.Join with "C:\\" to ensure absolute path on Windows
75+
fallbackConfigDir := filepath.Join("C:\\", "ProgramData", "ue-git-plugin-manager")
76+
fmt.Printf("⚠️ Warning: Username contains non-ASCII characters.\n")
77+
fmt.Printf(" Default path: %s\n", defaultConfigDir)
78+
fmt.Printf(" Using fallback path: %s\n", fallbackConfigDir)
79+
fmt.Printf(" (This is required to prevent build failures with UBT/MSVC)\n\n")
80+
81+
// Create the directory if it doesn't exist
82+
os.MkdirAll(fallbackConfigDir, 0755)
83+
return fallbackConfigDir
84+
}
6485

6586
// Create the directory if it doesn't exist
66-
os.MkdirAll(configDir, 0755)
87+
os.MkdirAll(defaultConfigDir, 0755)
6788

68-
return configDir
89+
return defaultConfigDir
6990
}
7091

7192
// GetExeDir returns the executable directory
@@ -78,6 +99,24 @@ func (m *Manager) GetBaseDir() string {
7899
return m.baseDir
79100
}
80101

102+
// GetPossibleBaseDirs returns both the default and fallback base directories
103+
// This is used for detection code to check both locations
104+
func GetPossibleBaseDirs() []string {
105+
usr, err := user.Current()
106+
if err != nil {
107+
return []string{}
108+
}
109+
110+
// Default path: %APPDATA%\ue-git-plugin-manager
111+
defaultPath := filepath.Join(usr.HomeDir, "AppData", "Roaming", "ue-git-plugin-manager")
112+
113+
// Fallback path: C:\ProgramData\ue-git-plugin-manager
114+
// Use filepath.Join with "C:\\" to ensure absolute path on Windows
115+
fallbackPath := filepath.Join("C:\\", "ProgramData", "ue-git-plugin-manager")
116+
117+
return []string{defaultPath, fallbackPath}
118+
}
119+
81120
// Exists checks if the configuration file exists
82121
func (m *Manager) Exists() bool {
83122
_, err := os.Stat(m.configPath)

internal/engine/engine.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,20 @@ func (m *Manager) DiscoverEngines(customRoots []string) ([]EngineInfo, error) {
3939
// Custom engine roots
4040
for _, root := range customRoots {
4141
if _, err := os.Stat(root); err == nil {
42-
engines = append(engines, m.scanDirectory(root)...)
42+
// Check if the root path is itself a valid engine directory
43+
// A valid engine has Engine\Binaries\Win64\UnrealEditor.exe
44+
if m.validateEngine(root) {
45+
// This is a specific engine path, add it directly
46+
version := m.extractVersion(root)
47+
engines = append(engines, EngineInfo{
48+
Path: root,
49+
Version: version,
50+
Valid: true,
51+
})
52+
} else {
53+
// This is a parent directory, scan it recursively for engines
54+
engines = append(engines, m.scanDirectory(root)...)
55+
}
4356
}
4457
}
4558

0 commit comments

Comments
 (0)