Skip to content

Commit bd1a690

Browse files
MikolajSkaziakMikołaj Skaziak
andauthored
Add automated installer build and GitHub Action release
Co-authored-by: Mikołaj Skaziak <mikolaj.skaziak@gmail.com>
1 parent bb4bfaf commit bd1a690

File tree

2 files changed

+151
-0
lines changed

2 files changed

+151
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build and Release Installer
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
name: Build Installer (x64 Release)
14+
runs-on: windows-2022
15+
16+
env:
17+
BUILD_CONFIGURATION: Release
18+
SOLUTION_PATH: 'src\vcxproj\salamand.sln'
19+
REMOVE_PROJ_PATH: 'src\vcxproj\setup\remove.vcxproj'
20+
OPENSAL_BUILD_DIR: 'D:\a\FileManager\FileManager\build_stage\'
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Setup MSBuild in PATH (VS2022)
27+
uses: microsoft/setup-msbuild@v2
28+
29+
- name: Build Solution (Release | x64)
30+
run: |
31+
New-Item -ItemType Directory -Force -Path $env:OPENSAL_BUILD_DIR
32+
msbuild $env:SOLUTION_PATH /m /t:Build /p:Configuration=$env:BUILD_CONFIGURATION /p:Platform=x64 /p:PreferredToolArchitecture=x64
33+
34+
- name: Build Uninstaller (Release | x64)
35+
run: |
36+
msbuild $env:REMOVE_PROJ_PATH /m /t:Build /p:Configuration=$env:BUILD_CONFIGURATION /p:Platform=x64 /p:PreferredToolArchitecture=x64
37+
38+
- name: Prepare and Create Installer
39+
run: |
40+
powershell.exe -File tools\prepare_installer.ps1 -BuildDir $env:OPENSAL_BUILD_DIR -OutputPath "OpenSalamander_5.0.${{ github.run_number }}.exe"
41+
42+
- name: Create Release
43+
uses: softprops/action-gh-release@v2
44+
with:
45+
tag_name: 5.0.${{ github.run_number }}
46+
name: Open Salamander 5.0.${{ github.run_number }}
47+
files: OpenSalamander_5.0.${{ github.run_number }}.exe
48+
draft: false
49+
prerelease: false
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

tools/prepare_installer.ps1

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
2+
param(
3+
[string]$BuildDir = "build_stage",
4+
[string]$StagingDir = "Installer_Staging",
5+
[string]$OutputPath = "OpenSalamander_v5.exe"
6+
)
7+
8+
if (Test-Path $StagingDir) { Remove-Item $StagingDir -Recurse -Force }
9+
New-Item -ItemType Directory -Path $StagingDir
10+
New-Item -ItemType Directory -Path "$StagingDir\plugins"
11+
New-Item -ItemType Directory -Path "$StagingDir\lang"
12+
New-Item -ItemType Directory -Path "$StagingDir\convert"
13+
New-Item -ItemType Directory -Path "$StagingDir\toolbars"
14+
15+
# 1. Copy base installer files
16+
Copy-Item "Installer\setup.exe" "$StagingDir\"
17+
Copy-Item "Installer\LICENSE" "$StagingDir\"
18+
Copy-Item "Installer\x64" "$StagingDir\"
19+
20+
# 2. Copy main executables (from Release_x64)
21+
Copy-Item "src\vcxproj\salamander\Release_x64\salamand.exe" "$StagingDir\"
22+
Copy-Item "src\vcxproj\salmon\salamander\Release_x64\utils\salmon.exe" "$StagingDir\"
23+
Copy-Item "$BuildDir\remove\Release_x64\remove.exe" "$StagingDir\"
24+
25+
# 3. Copy lang (main app)
26+
Copy-Item "Installer\lang\*" "$StagingDir\lang\" -Recurse
27+
28+
# 4. Copy convert
29+
Copy-Item "convert\*" "$StagingDir\convert\" -Recurse
30+
31+
# 5. Copy toolbars
32+
Copy-Item "src\res\toolbars\*" "$StagingDir\toolbars\" -Recurse
33+
34+
# 6. Copy plugins
35+
# Find all .spl files in Release_x64 directories
36+
$splFiles = Get-ChildItem -Path "src\plugins" -Recurse -Filter "*.spl" | Where-Object { $_.FullName -match "Release_x64" }
37+
foreach ($file in $splFiles) {
38+
# Extract plugin name from path (usually ...\plugins\<name>\<name>.spl)
39+
$pluginName = $file.Directory.Name
40+
$pluginDestDir = New-Item -ItemType Directory -Path "$StagingDir\plugins\$pluginName" -Force
41+
Copy-Item $file.FullName "$pluginDestDir\"
42+
43+
# Copy plugin's lang files (only .slg, exclude Intermediate)
44+
$pluginLangDir = Join-Path $file.DirectoryName "lang"
45+
if (Test-Path $pluginLangDir) {
46+
$stagedLangDir = New-Item -ItemType Directory -Path "$pluginDestDir\lang" -Force
47+
Get-ChildItem -Path $pluginLangDir -Filter "*.slg" | Copy-Item -Destination "$stagedLangDir\"
48+
}
49+
}
50+
51+
# 7. Generate setup.inf
52+
$setupInf = @"
53+
[Private]
54+
ApplicationName=Open Salamander 5.0
55+
ApplicationNameVer=Open Salamander 5.0
56+
DefaultDirectory=%4%\Open Salamander 5.0
57+
LicenseFile=LICENSE
58+
SkipChooseDirectory=0
59+
SaveRemoveLog=%1%\uninstall.log
60+
UninstallRunProgramQuietPath=%1%\remove.exe
61+
62+
[CopyFiles]
63+
salamand.exe,%1\salamand.exe,0
64+
salmon.exe,%1\salmon.exe,0
65+
remove.exe,%1\remove.exe,0
66+
"@
67+
68+
# Function to add files to setup.inf
69+
function Add-ToSetupInf($path) {
70+
$files = Get-ChildItem -Path "$StagingDir\$path" -File -Recurse
71+
foreach ($f in $files) {
72+
$relPath = $f.FullName.Substring((Get-Item $StagingDir).FullName.Length + 1)
73+
# Check if the file is in an Intermediate directory (shouldn't be there, but just in case)
74+
if ($relPath -notmatch "\\Intermediate\\") {
75+
$script:setupInf += "`n$relPath,%1\$relPath,0"
76+
}
77+
}
78+
}
79+
80+
Add-ToSetupInf "lang"
81+
Add-ToSetupInf "convert"
82+
Add-ToSetupInf "toolbars"
83+
Add-ToSetupInf "plugins"
84+
85+
$setupInf += @"
86+
87+
[CreateShortcuts]
88+
0,Open Salamander 5.0,%1\salamand.exe,
89+
1,Open Salamander 5.0,%1\salamand.exe,
90+
"@
91+
92+
$setupInf | Out-File -FilePath "$StagingDir\setup.inf" -Encoding utf8
93+
94+
# 8. Create SFX using the existing tool
95+
$ScriptRoot = Split-Path $MyInvocation.MyCommand.Path
96+
$SfxTool = Join-Path $ScriptRoot "Create-Sfx.ps1"
97+
98+
powershell.exe -File "$SfxTool" -SourceDir "$StagingDir" -OutputPath "$OutputPath"
99+
100+
Write-Host "Installer created: $OutputPath"

0 commit comments

Comments
 (0)