Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/build-installer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and Release Installer

on:
push:
branches: ["main"]
workflow_dispatch:

permissions:
contents: write

jobs:
build:
name: Build Installer (x64 Release)
runs-on: windows-2022

env:
BUILD_CONFIGURATION: Release
SOLUTION_PATH: 'src\vcxproj\salamand.sln'
REMOVE_PROJ_PATH: 'src\vcxproj\setup\remove.vcxproj'
OPENSAL_BUILD_DIR: 'D:\a\FileManager\FileManager\build_stage\'

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup MSBuild in PATH (VS2022)
uses: microsoft/setup-msbuild@v2

- name: Build Solution (Release | x64)
run: |
New-Item -ItemType Directory -Force -Path $env:OPENSAL_BUILD_DIR
msbuild $env:SOLUTION_PATH /m /t:Build /p:Configuration=$env:BUILD_CONFIGURATION /p:Platform=x64 /p:PreferredToolArchitecture=x64

- name: Build Uninstaller (Release | x64)
run: |
msbuild $env:REMOVE_PROJ_PATH /m /t:Build /p:Configuration=$env:BUILD_CONFIGURATION /p:Platform=x64 /p:PreferredToolArchitecture=x64

- name: Prepare and Create Installer
run: |
powershell.exe -File tools\prepare_installer.ps1 -BuildDir $env:OPENSAL_BUILD_DIR -OutputPath "OpenSalamander_5.0.${{ github.run_number }}.exe"

- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: 5.0.${{ github.run_number }}
name: Open Salamander 5.0.${{ github.run_number }}
files: OpenSalamander_5.0.${{ github.run_number }}.exe
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100 changes: 100 additions & 0 deletions tools/prepare_installer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@

param(
[string]$BuildDir = "build_stage",
[string]$StagingDir = "Installer_Staging",
[string]$OutputPath = "OpenSalamander_v5.exe"
)

if (Test-Path $StagingDir) { Remove-Item $StagingDir -Recurse -Force }
New-Item -ItemType Directory -Path $StagingDir
New-Item -ItemType Directory -Path "$StagingDir\plugins"
New-Item -ItemType Directory -Path "$StagingDir\lang"
New-Item -ItemType Directory -Path "$StagingDir\convert"
New-Item -ItemType Directory -Path "$StagingDir\toolbars"

# 1. Copy base installer files
Copy-Item "Installer\setup.exe" "$StagingDir\"
Copy-Item "Installer\LICENSE" "$StagingDir\"
Copy-Item "Installer\x64" "$StagingDir\"

# 2. Copy main executables (from Release_x64)
Copy-Item "src\vcxproj\salamander\Release_x64\salamand.exe" "$StagingDir\"
Copy-Item "src\vcxproj\salmon\salamander\Release_x64\utils\salmon.exe" "$StagingDir\"
Copy-Item "$BuildDir\remove\Release_x64\remove.exe" "$StagingDir\"

# 3. Copy lang (main app)
Copy-Item "Installer\lang\*" "$StagingDir\lang\" -Recurse

# 4. Copy convert
Copy-Item "convert\*" "$StagingDir\convert\" -Recurse

# 5. Copy toolbars
Copy-Item "src\res\toolbars\*" "$StagingDir\toolbars\" -Recurse

# 6. Copy plugins
# Find all .spl files in Release_x64 directories
$splFiles = Get-ChildItem -Path "src\plugins" -Recurse -Filter "*.spl" | Where-Object { $_.FullName -match "Release_x64" }
foreach ($file in $splFiles) {
# Extract plugin name from path (usually ...\plugins\<name>\<name>.spl)
$pluginName = $file.Directory.Name
$pluginDestDir = New-Item -ItemType Directory -Path "$StagingDir\plugins\$pluginName" -Force
Copy-Item $file.FullName "$pluginDestDir\"

# Copy plugin's lang files (only .slg, exclude Intermediate)
$pluginLangDir = Join-Path $file.DirectoryName "lang"
if (Test-Path $pluginLangDir) {
$stagedLangDir = New-Item -ItemType Directory -Path "$pluginDestDir\lang" -Force
Get-ChildItem -Path $pluginLangDir -Filter "*.slg" | Copy-Item -Destination "$stagedLangDir\"
}
}

# 7. Generate setup.inf
$setupInf = @"
[Private]
ApplicationName=Open Salamander 5.0
ApplicationNameVer=Open Salamander 5.0
DefaultDirectory=%4%\Open Salamander 5.0
LicenseFile=LICENSE
SkipChooseDirectory=0
SaveRemoveLog=%1%\uninstall.log
UninstallRunProgramQuietPath=%1%\remove.exe

[CopyFiles]
salamand.exe,%1\salamand.exe,0
salmon.exe,%1\salmon.exe,0
remove.exe,%1\remove.exe,0
"@

# Function to add files to setup.inf
function Add-ToSetupInf($path) {
$files = Get-ChildItem -Path "$StagingDir\$path" -File -Recurse
foreach ($f in $files) {
$relPath = $f.FullName.Substring((Get-Item $StagingDir).FullName.Length + 1)
# Check if the file is in an Intermediate directory (shouldn't be there, but just in case)
if ($relPath -notmatch "\\Intermediate\\") {
$script:setupInf += "`n$relPath,%1\$relPath,0"
}
}
}

Add-ToSetupInf "lang"
Add-ToSetupInf "convert"
Add-ToSetupInf "toolbars"
Add-ToSetupInf "plugins"

$setupInf += @"

[CreateShortcuts]
0,Open Salamander 5.0,%1\salamand.exe,
1,Open Salamander 5.0,%1\salamand.exe,
"@

$setupInf | Out-File -FilePath "$StagingDir\setup.inf" -Encoding utf8

# 8. Create SFX using the existing tool
$ScriptRoot = Split-Path $MyInvocation.MyCommand.Path
$SfxTool = Join-Path $ScriptRoot "Create-Sfx.ps1"

powershell.exe -File "$SfxTool" -SourceDir "$StagingDir" -OutputPath "$OutputPath"

Write-Host "Installer created: $OutputPath"
Loading