2020-10-07 17:15:18 +01:00
|
|
|
[CmdletBinding()] # Fail on unknown args
|
|
|
|
param (
|
2020-10-13 10:13:17 +01:00
|
|
|
# Explicit version to release
|
2020-10-07 17:15:18 +01:00
|
|
|
[string]$version,
|
2020-10-13 10:13:17 +01:00
|
|
|
# Latest version option instead of explicit version
|
|
|
|
[switch]$latest,
|
2020-10-08 14:59:25 +01:00
|
|
|
# Variant name(s) to release; if not specified release all DefaultVariants with ReleaseTo options
|
|
|
|
[array]$variants,
|
2020-10-07 17:15:18 +01:00
|
|
|
# Source folder, current dir if omitted
|
|
|
|
[string]$src,
|
|
|
|
# Which service(s) to release on e.g. "steam": defaults to "ReleaseTo" services in packageconfig.json for variant
|
|
|
|
[array]$services,
|
|
|
|
# Dry-run; does nothing but report what *would* have happened
|
|
|
|
[switch]$dryrun = $false,
|
|
|
|
[switch]$help = $false
|
|
|
|
)
|
|
|
|
|
|
|
|
. $PSScriptRoot\inc\platform.ps1
|
|
|
|
. $PSScriptRoot\inc\packageconfig.ps1
|
2020-10-13 10:13:17 +01:00
|
|
|
. $PSScriptRoot\inc\projectversion.ps1
|
2020-10-07 17:15:18 +01:00
|
|
|
. $PSScriptRoot\inc\filetools.ps1
|
|
|
|
. $PSScriptRoot\inc\steam.ps1
|
|
|
|
. $PSScriptRoot\inc\itch.ps1
|
|
|
|
|
|
|
|
|
|
|
|
function Write-Usage {
|
2022-04-19 12:07:09 +01:00
|
|
|
Write-Output "Steve's Unreal release tool"
|
2020-10-07 17:15:18 +01:00
|
|
|
Write-Output "Usage:"
|
2020-10-13 10:13:17 +01:00
|
|
|
Write-Output " ue4-release.ps1 [-version:ver|-latest] -variant:var -services:steam,itch [-src:sourcefolder] [-dryrun]"
|
2020-10-07 17:15:18 +01:00
|
|
|
Write-Output " "
|
2020-10-08 14:59:25 +01:00
|
|
|
Write-Output " -version:ver : Version to release; must have been packaged already"
|
2020-10-13 10:13:17 +01:00
|
|
|
Write-Output " -latest : Instead of an explicit version, release one identified in project settings"
|
2020-10-08 14:59:25 +01:00
|
|
|
Write-Output " -variants:var1,var2 : Name of variants to release. Omit to use DefaultVariants"
|
|
|
|
Write-Output " -services:s1,s2 : Name of services to release to. Can omit and rely on ReleaseTo"
|
|
|
|
Write-Output " setting of variant in packageconfig.json "
|
|
|
|
Write-Output " -src : Source folder (current folder if omitted), must contain packageconfig.json"
|
|
|
|
Write-Output " -dryrun : Don't perform any actual actions, just report what would happen"
|
|
|
|
Write-Output " -help : Print this help"
|
2020-10-07 17:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
|
|
|
|
if ($help) {
|
|
|
|
Write-Usage
|
|
|
|
Exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($src.Length -eq 0) {
|
|
|
|
$src = "."
|
|
|
|
Write-Verbose "-src not specified, assuming current directory"
|
|
|
|
}
|
|
|
|
|
2020-10-13 10:13:17 +01:00
|
|
|
if (-not $version -and -not $latest) {
|
|
|
|
Write-Usage
|
|
|
|
Write-Output ""
|
|
|
|
Write-Output "ERROR: You must specify a version"
|
|
|
|
Exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($version -and $latest) {
|
|
|
|
Write-Usage
|
|
|
|
Write-Output ""
|
|
|
|
Write-Output "ERROR: You cannot specify a -version and -latest at the same time"
|
2020-10-08 14:59:25 +01:00
|
|
|
Exit 1
|
|
|
|
}
|
|
|
|
|
2022-04-19 12:07:09 +01:00
|
|
|
Write-Output "~-~-~ Unreal Release Helper Start ~-~-~"
|
2020-10-07 17:15:18 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
# Import config
|
|
|
|
$config = Read-Package-Config -srcfolder:$src
|
|
|
|
|
2020-10-13 10:13:17 +01:00
|
|
|
if ($latest) {
|
|
|
|
$version = Get-Project-Version $src
|
|
|
|
}
|
|
|
|
|
2020-10-08 14:59:25 +01:00
|
|
|
if ($variants) {
|
|
|
|
$variantConfigs = $config.Variants | Where-Object { $_.Name -in $variants }
|
|
|
|
if ($variantConfigs.Count -ne $variants.Count) {
|
|
|
|
$unmatchedVariants = $variants | Where-Object { $_ -notin $variantConfigs.Name }
|
|
|
|
Write-Warning "Variant(s) not found, ignoring: $($unmatchedVariants -join ", ")"
|
2020-10-07 17:15:18 +01:00
|
|
|
}
|
2020-10-08 14:59:25 +01:00
|
|
|
} else {
|
|
|
|
# Use default variants
|
|
|
|
$variantConfigs = $config.Variants | Where-Object { $_.Name -in $config.DefaultVariants }
|
2020-10-07 17:15:18 +01:00
|
|
|
}
|
|
|
|
|
2020-10-08 14:59:25 +01:00
|
|
|
$hasErrors = $false
|
|
|
|
foreach ($variantConfig in $variantConfigs) {
|
2020-10-07 17:15:18 +01:00
|
|
|
|
2020-10-08 14:59:25 +01:00
|
|
|
# Get source dir
|
|
|
|
$sourcedir = Get-Package-Client-Dir -config:$config -versionNumber:$version -variantName:$variantConfig.Name
|
2020-10-07 17:15:18 +01:00
|
|
|
|
2020-10-08 14:59:25 +01:00
|
|
|
if (-not (Test-Path $sourcedir -PathType Container)) {
|
|
|
|
Write-Error "Release folder $sourcedir does not exist, skipping"
|
|
|
|
$hasErrors = $true
|
|
|
|
continue
|
2020-10-07 17:15:18 +01:00
|
|
|
}
|
|
|
|
|
2020-10-08 14:59:25 +01:00
|
|
|
# Find service(s)
|
|
|
|
if ($services) {
|
|
|
|
# Release to a subset of allowed services
|
|
|
|
$servicesFound = $services | Where-Object {$variantConfig.ReleaseTo -contains $_ }
|
|
|
|
if ($servicesFound.Count -ne $services.Count) {
|
|
|
|
$unmatchedServices = $services | Where-Object { $servicesFound -notcontains $_ }
|
|
|
|
Write-Warning "Services(s) not supported by $($variantConfig.Name): $($unmatchedServices -join ", ")"
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$servicesFound = $variantConfig.ReleaseTo
|
|
|
|
}
|
2020-10-07 17:15:18 +01:00
|
|
|
|
2020-10-08 14:59:25 +01:00
|
|
|
if (-not $servicesFound) {
|
|
|
|
Write-Verbose "Skipping $($variantConfig.Name), no matching release services"
|
|
|
|
continue
|
|
|
|
}
|
2020-10-07 17:15:18 +01:00
|
|
|
|
2020-10-08 14:59:25 +01:00
|
|
|
Write-Output ""
|
|
|
|
Write-Output "Variant : $($variantConfig.Name)"
|
2020-10-13 10:13:17 +01:00
|
|
|
Write-Output "Version : $version"
|
2020-10-08 14:59:25 +01:00
|
|
|
Write-Output "Source Folder : $sourcedir"
|
|
|
|
Write-Output "Service(s) : $($servicesFound -join ", ")"
|
|
|
|
Write-Output ""
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($service in $servicesFound) {
|
|
|
|
if ($service -eq "steam") {
|
|
|
|
Release-Steam -config:$config -variant:$variantConfig -sourcefolder:$sourcedir -version:$version -dryrun:$dryrun
|
|
|
|
} elseif ($service -eq "itch") {
|
|
|
|
Release-Itch -config:$config -variant:$variantConfig -sourcefolder:$sourcedir -version:$version -dryrun:$dryrun
|
|
|
|
} else {
|
|
|
|
throw "Unknown release service: $service"
|
|
|
|
}
|
2020-10-07 17:15:18 +01:00
|
|
|
}
|
2020-10-08 14:59:25 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($hasErrors) {
|
|
|
|
throw "Errors occurred, see above"
|
2020-10-07 17:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} catch {
|
|
|
|
Write-Output $_.Exception.Message
|
2022-04-19 12:07:09 +01:00
|
|
|
Write-Output "~-~-~ Unreal Release Helper FAILED ~-~-~"
|
2020-10-07 17:15:18 +01:00
|
|
|
Exit 9
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-19 12:07:09 +01:00
|
|
|
Write-Output "~-~-~ Unreal Release Helper Completed OK ~-~-~"
|