mirror-chatterino2/.CI/build-installer.ps1
nerix accf91a48f
Build Windows Installer in CI (#4408)
* feat: build installer in CI

Co-authored-by: 8thony <114905842+8thony@users.noreply.github.com>

* fix: use inno-setup from PATH

* fix: only match `v*` tags

* fix: don't add to release

* fix: only run on master

---------

Co-authored-by: 8thony <114905842+8thony@users.noreply.github.com>
2023-08-05 12:27:09 +00:00

47 lines
1.4 KiB
PowerShell

if (-not (Test-Path -PathType Container Chatterino2)) {
Write-Error "Couldn't find a folder called 'Chatterino2' in the current directory.";
exit 1
}
# Check if we're on a tag
$OldErrorActionPref = $ErrorActionPreference;
$ErrorActionPreference = 'Continue';
git describe --exact-match --match 'v*' *> $null;
$isTagged = $?;
$ErrorActionPreference = $OldErrorActionPref;
$defines = $null;
if ($isTagged) {
# This is a release.
# Make sure, any existing `modes` file is overwritten for the user,
# for example when updating from nightly to stable.
Write-Output "" > Chatterino2/modes;
$installerBaseName = "Chatterino.Installer";
}
else {
Write-Output nightly > Chatterino2/modes;
$defines = "/DIS_NIGHTLY=1";
$installerBaseName = "Chatterino.Nightly.Installer";
}
if ($Env:GITHUB_OUTPUT) {
# This is used in CI when creating the artifact
"C2_INSTALLER_BASE_NAME=$installerBaseName" >> "$Env:GITHUB_OUTPUT"
}
# Copy vc_redist.x64.exe
if ($null -eq $Env:VCToolsRedistDir) {
Write-Error "VCToolsRedistDir is not set. Forgot to set Visual Studio environment variables?";
exit 1
}
Copy-Item "$Env:VCToolsRedistDir\vc_redist.x64.exe" .;
# Build the installer
ISCC `
/DWORKING_DIR="$($pwd.Path)\" `
/DINSTALLER_BASE_NAME="$installerBaseName" `
$defines `
/O. `
"$PSScriptRoot\chatterino-installer.iss";
Move-Item "$installerBaseName.exe" "$installerBaseName$($Env:VARIANT_SUFFIX).exe"