Merge pull request #2367 from BlueBlock/update_build_scripts

Update build scripts
This commit is contained in:
Dimitrij
2023-03-08 19:32:06 +00:00
committed by GitHub
8 changed files with 296 additions and 26 deletions

View File

@@ -1,17 +1,27 @@
#Requires -Version 4.0
param (
[string]
[Parameter(Mandatory=$true)]
$WebsiteTargetOwner,
[string]
[Parameter(Mandatory=$true)]
$WebsiteTargetRepository,
[string]
[Parameter(Mandatory=$false)]
$PreTagName = "",
[string]
[Parameter(Mandatory=$true)]
$TagName,
[string]
[Parameter(Mandatory=$true)]
[ValidateSet("Stable","Beta","Development")]
$UpdateChannel
$ProjectName
)
function New-MsiUpdateFileContent {
param (
[System.IO.FileInfo]
@@ -25,7 +35,7 @@ function New-MsiUpdateFileContent {
$version = $MsiFile.BaseName -replace "[a-zA-Z-]*"
$certThumbprint = (Get-AuthenticodeSignature -FilePath $MsiFile).SignerCertificate.Thumbprint
$hash = Get-FileHash -Algorithm SHA512 $MsiFile | % { $_.Hash }
$hash = Get-FileHash -Algorithm SHA512 $MsiFile | ForEach-Object { $_.Hash }
$fileContents = `
"Version: $version
@@ -49,7 +59,7 @@ function New-ZipUpdateFileContent {
)
$version = $ZipFile.BaseName -replace "[a-zA-Z-]*"
$hash = Get-FileHash -Algorithm SHA512 $ZipFile | % { $_.Hash }
$hash = Get-FileHash -Algorithm SHA512 $ZipFile | ForEach-Object { $_.Hash }
$fileContents = `
"Version: $version
@@ -64,7 +74,7 @@ function Resolve-UpdateCheckFileName {
param (
[string]
[Parameter(Mandatory=$true)]
[ValidateSet("Stable","Beta","Development")]
[ValidateSet("Stable","Preview","Nightly")]
$UpdateChannel,
[string]
@@ -75,8 +85,8 @@ function Resolve-UpdateCheckFileName {
$fileName = ""
if ($UpdateChannel -eq "Beta") { $fileName += "beta-" }
elseif ($UpdateChannel -eq "Development") { $fileName += "dev-" }
if ($UpdateChannel -eq "Preview") { $fileName += "preview-" }
elseif ($UpdateChannel -eq "Nightly") { $fileName += "nightly-" }
$fileName += "update"
@@ -88,22 +98,68 @@ function Resolve-UpdateCheckFileName {
}
Write-Output "Begin create_upg_chk_files.ps1"
# determine update channel
if ($env:APPVEYOR_PROJECT_NAME -match "(Nightly)") {
write-host "UpdateChannel = Nightly"
$UpdateChannel = "Nightly"
$ModifiedTagName = "$PreTagName-$TagName-NB"
} elseif ($env:APPVEYOR_PROJECT_NAME -match "(Preview)") {
write-host "UpdateChannel = Preview"
$UpdateChannel = "Preview"
$ModifiedTagName = "v$TagName-PB"
} elseif ($env:APPVEYOR_PROJECT_NAME -match "(Stable)") {
write-host "UpdateChannel = Stable"
$UpdateChannel = "Stable"
$ModifiedTagName = "v" + $TagName.Split("-")[0]
} else {
$UpdateChannel = ""
}
$buildFolder = Join-Path -Path $PSScriptRoot -ChildPath "..\mRemoteNG\bin\x64\Release" -Resolve -ErrorAction Ignore
$releaseFolder = Join-Path -Path $PSScriptRoot -ChildPath "..\Release" -Resolve
if ($UpdateChannel -ne "" -and $buildFolder -ne "") {
$releaseFolder = Join-Path -Path $PSScriptRoot -ChildPath "..\Release" -Resolve
$msiFile = Get-ChildItem -Path "$buildFolder\*.msi" | Sort-Object LastWriteTime | Select-Object -last 1
if (![string]::IsNullOrEmpty($msiFile)) {
$msiUpdateContents = New-MsiUpdateFileContent -MsiFile $msiFile -TagName $ModifiedTagName
$msiUpdateFileName = Resolve-UpdateCheckFileName -UpdateChannel $UpdateChannel -Type Normal
Write-Output "`n`nMSI Update Check File Contents ($msiUpdateFileName)`n------------------------------"
Tee-Object -InputObject $msiUpdateContents -FilePath "$releaseFolder\$msiUpdateFileName"
write-host "msiUpdateFileName $releaseFolder\$msiUpdateFileName"
# commit msi update txt file
if ($env:WEBSITE_UPDATE_ENABLED.ToLower() -eq "true") {
if ((Test-Path -Path "$releaseFolder\$msiUpdateFileName") -and (-not [string]::IsNullOrEmpty($WebsiteTargetRepository))) {
Write-Output "Publish $msiUpdateFileName to $WebsiteTargetRepository"
$update_file_content_string = Get-Content "$releaseFolder\$msiUpdateFileName" | Out-String
Set-GitHubContent -OwnerName $WebsiteTargetOwner -RepositoryName $WebsiteTargetRepository -Path $msiUpdateFileName -CommitMessage "Build $ModifiedTagName" -Content $update_file_content_string -BranchName main
}
}
}
# build msi update file
$msiFile = Get-ChildItem -Path "$releaseFolder\*.msi" | sort LastWriteTime | select -last 1
$msiUpdateContents = New-MsiUpdateFileContent -MsiFile $msiFile -TagName $TagName
$msiUpdateFileName = Resolve-UpdateCheckFileName -UpdateChannel $UpdateChannel -Type Normal
Write-Output "`n`nMSI Update Check File Contents ($msiUpdateFileName)`n------------------------------"
Tee-Object -InputObject $msiUpdateContents -FilePath "$releaseFolder\$msiUpdateFileName"
# build zip update file
$releaseFolder = Join-Path -Path $PSScriptRoot -ChildPath "..\Release" -Resolve
$zipFile = Get-ChildItem -Path "$releaseFolder\*.zip" -Exclude "*-symbols-*.zip" | Sort-Object LastWriteTime | Select-Object -last 1
if (![string]::IsNullOrEmpty($zipFile)) {
$zipUpdateContents = New-ZipUpdateFileContent -ZipFile $zipFile -TagName $ModifiedTagName
$zipUpdateFileName = Resolve-UpdateCheckFileName -UpdateChannel $UpdateChannel -Type Portable
Write-Output "`n`nZip Update Check File Contents ($zipUpdateFileName)`n------------------------------"
Tee-Object -InputObject $zipUpdateContents -FilePath "$releaseFolder\$zipUpdateFileName"
write-host "zipUpdateFileName $releaseFolder\$zipUpdateFileName"
# commit zip update txt file
if ($env:WEBSITE_UPDATE_ENABLED.ToLower() -eq "true") {
if ((Test-Path -Path "$releaseFolder\$zipUpdateFileName") -and (-not [string]::IsNullOrEmpty($WebsiteTargetRepository))) {
Write-Output "Publish $zipUpdateFileName to $WebsiteTargetRepository"
$update_file_content_string = Get-Content "$releaseFolder\$zipUpdateFileName" | Out-String
Set-GitHubContent -OwnerName $WebsiteTargetOwner -RepositoryName $WebsiteTargetRepository -Path $zipUpdateFileName -CommitMessage "Build $ModifiedTagName" -Content $update_file_content_string -BranchName main
}
}
}
} else {
write-host "BuildFolder not found"
}
# build zip update file
$zipFile = Get-ChildItem -Path "$releaseFolder\*.zip" | sort LastWriteTime | select -last 1
$zipUpdateContents = New-ZipUpdateFileContent -ZipFile $zipFile -TagName $TagName
$zipUpdateFileName = Resolve-UpdateCheckFileName -UpdateChannel $UpdateChannel -Type Portable
Write-Output "`n`nZip Update Check File Contents ($zipUpdateFileName)`n------------------------------"
Tee-Object -InputObject $zipUpdateContents -FilePath "$releaseFolder\$zipUpdateFileName"
Write-Output "End create_upg_chk_files.ps1"

View File

@@ -2,6 +2,22 @@ $githubUrl = 'https://api.github.com'
# GitHub doesn't support the default powershell protocol (TLS 1.0)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
#$ConfigurationName = $ConfigurationName.Trim()
if (![string]::IsNullOrEmpty($env:APPVEYOR_REPO_NAME)) {
$CURRENT_GITHUB_USER = $env:APPVEYOR_REPO_NAME.Split("/")[0]
Install-Module -Name PowerShellForGitHub -Scope CurrentUser
Set-GitHubConfiguration -DisableTelemetry
$PSDefaultParameterValues["*-GitHub*:AccessToken"] = "$env:ACCESS_TOKEN"
}
Function ConvertFrom-Base64($base64) {
return [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($base64))
}
Function ConvertTo-Base64($plain) {
return [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($plain))
}
function Publish-GitHubRelease {
param (
[string]

View File

@@ -25,6 +25,8 @@ param (
$ExcludeFromSigning
)
. "$PSScriptRoot\github_functions.ps1"
Write-Output "+===========================================================================================+"
Write-Output "| Beginning mRemoteNG Installer Post Build |"
Write-Output "+===========================================================================================+"
@@ -39,5 +41,16 @@ Format-Table -AutoSize -Wrap -InputObject @{
& "$PSScriptRoot\sign_binaries.ps1" -TargetDir $TargetDir -CertificatePath $CertificatePath -CertificatePassword $CertificatePassword -ConfigurationName $ConfigurationName -Exclude $ExcludeFromSigning -SolutionDir $SolutionDir
& "$PSScriptRoot\verify_binary_signatures.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName -CertificatePath $CertificatePath -SolutionDir $SolutionDir
& "$PSScriptRoot\rename_and_copy_installer.ps1" -SolutionDir $SolutionDir -BuildConfiguration $ConfigurationName.Trim()
if (![string]::IsNullOrEmpty($CURRENT_GITHUB_USER)) {
& "$PSScriptRoot\create_upg_chk_files.ps1" -WebsiteTargetOwner $CURRENT_GITHUB_USER -WebsiteTargetRepository $env:WEBSITE_TARGET_REPOSITORY -PreTagName $env:NightlyBuildTagName -TagName $env:APPVEYOR_BUILD_VERSION -ProjectName $env:APPVEYOR_PROJECT_NAME
& "$PSScriptRoot\update_and_upload_website_release_json_file.ps1" -WebsiteTargetOwner $CURRENT_GITHUB_USER -WebsiteTargetRepository $env:WEBSITE_TARGET_REPOSITORY -PreTagName $env:NightlyBuildTagName -TagName $env:APPVEYOR_BUILD_VERSION -ProjectName $env:APPVEYOR_PROJECT_NAME
}
Write-Output "End mRemoteNG Installer Post Build"

View File

@@ -25,6 +25,8 @@ param (
$ExcludeFromSigning
)
. "$PSScriptRoot\github_functions.ps1"
Write-Output "+===========================================================================================+"
Write-Output "| Beginning mRemoteNG Post Build |"
Write-Output "+===========================================================================================+"
@@ -56,7 +58,21 @@ Format-Table -AutoSize -Wrap -InputObject @{
# Currently targeting x64, shouldn't need to manually set LargeAddressAware...
#& "$PSScriptRoot\set_LargeAddressAware.ps1" -TargetDir $TargetDir -TargetFileName $TargetFileName
& "$PSScriptRoot\verify_LargeAddressAware.ps1" -TargetDir $TargetDir -TargetFileName $TargetFileName
& "$PSScriptRoot\tidy_files_for_release.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName
& "$PSScriptRoot\sign_binaries.ps1" -TargetDir $TargetDir -CertificatePath $CertificatePath -CertificatePassword $CertificatePassword -ConfigurationName $ConfigurationName -Exclude $ExcludeFromSigning -SolutionDir $SolutionDir
& "$PSScriptRoot\verify_binary_signatures.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName -CertificatePath $CertificatePath -SolutionDir $SolutionDir
& "$PSScriptRoot\zip_files.ps1" -SolutionDir $SolutionDir -TargetDir $TargetDir -ConfigurationName $ConfigurationName
if (![string]::IsNullOrEmpty($CURRENT_GITHUB_USER)) {
& "$PSScriptRoot\create_upg_chk_files.ps1" -WebsiteTargetOwner $CURRENT_GITHUB_USER -WebsiteTargetRepository $env:WEBSITE_TARGET_REPOSITORY -PreTagName $env:NightlyBuildTagName -TagName $env:APPVEYOR_BUILD_VERSION -ProjectName $env:APPVEYOR_PROJECT_NAME
& "$PSScriptRoot\update_and_upload_website_release_json_file.ps1" -WebsiteTargetOwner $CURRENT_GITHUB_USER -WebsiteTargetRepository $env:WEBSITE_TARGET_REPOSITORY -PreTagName $env:NightlyBuildTagName -TagName $env:APPVEYOR_BUILD_VERSION -ProjectName $env:APPVEYOR_PROJECT_NAME
}
Write-Output "End mRemoteNG Post Build"

View File

@@ -7,9 +7,10 @@
$targetVersionedFile = "$SolutionDir\mRemoteNG\bin\x64\$BuildConfiguration\mRemoteNG.exe"
$version = &"$SolutionDir\Tools\exes\sigcheck.exe" /accepteula -q -n $targetVersionedFile
#$fileversion = &"$SolutionDir\Tools\exes\sigcheck.exe" /accepteula -q -n $targetVersionedFile
$prodversion = ((Get-Item -Path $targetVersionedFile).VersionInfo | Select-Object -Property ProductVersion)."ProductVersion"
$src = $SolutionDir + "mRemoteNGInstaller\Installer\bin\x64\$BuildConfiguration\en-US\mRemoteNG-Installer.msi"
$dst = $SolutionDir + "mRemoteNG\bin\x64\$BuildConfiguration\mRemoteNG-Installer-" + $version + ".msi"
$dst = $SolutionDir + "mRemoteNG\bin\x64\$BuildConfiguration\mRemoteNG-Installer-" + $prodversion + ".msi"
# Copy file
Copy-Item $src -Destination $dst -Force

View File

@@ -0,0 +1,168 @@
#Requires -Version 4.0
param (
[string]
[Parameter(Mandatory=$true)]
$WebsiteTargetOwner,
[string]
[Parameter(Mandatory=$true)]
$WebsiteTargetRepository,
[string]
[Parameter(Mandatory=$false)]
$PreTagName = "",
[string]
[Parameter(Mandatory=$true)]
$TagName,
[string]
[Parameter(Mandatory=$true)]
$ProjectName
)
Write-Output "Begin create_website_release_json_file.ps1"
# determine update channel
if ($env:APPVEYOR_PROJECT_NAME -match "(Nightly)") {
write-host "UpdateChannel = Nightly"
$UpdateChannel = "Nightly"
$ModifiedTagName = "$PreTagName-$TagName-NB"
} elseif ($env:APPVEYOR_PROJECT_NAME -match "(Preview)") {
write-host "UpdateChannel = Preview"
$UpdateChannel = "Preview"
$ModifiedTagName = "v$TagName-PB"
} elseif ($env:APPVEYOR_PROJECT_NAME -match "(Stable)") {
write-host "UpdateChannel = Stable"
$UpdateChannel = "Stable"
$ModifiedTagName = "v" + $TagName.Split("-")[0]
} else {
$UpdateChannel = ""
}
$buildFolder = Join-Path -Path $PSScriptRoot -ChildPath "..\mRemoteNG\bin\x64\Release" -Resolve -ErrorAction Ignore
if ($UpdateChannel -ne "" -and $buildFolder -ne "") {
$releaseFolder = Join-Path -Path $PSScriptRoot -ChildPath "..\Release" -Resolve
$published_at = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
#$websiteJsonReleaseFile = Join-Path -Path $PSScriptRoot -ChildPath "..\..\mRemoteNG.github.io\_data\releases.json" -Resolve
# get releases.json from github
$releases_json = Get-GitHubContent -OwnerName $WebsiteTargetOwner -RepositoryName $WebsiteTargetRepository -Path _data\releases.json
ConvertFrom-Base64($releases_json.content) | Out-File -FilePath "$releaseFolder\releases.json"
$websiteJsonReleaseFile = Get-ChildItem -Path "$releaseFolder\releases.json"
# installer
$msiFile = Get-ChildItem -Path "$buildFolder\*.msi" | Sort-Object LastWriteTime | Select-Object -last 1
if (![string]::IsNullOrEmpty($msiFile)) {
$checksum = (Get-FileHash $msiFile -Algorithm SHA512).Hash
$file_size = (Get-ChildItem $msiFile).Length
$a = Get-Content $websiteJsonReleaseFile | ConvertFrom-Json
switch ($UpdateChannel) {
"Nightly" {
$GithubTag = "$((Get-Date).ToUniversalTime().ToString("yyyyMMdd"))-$TagName-NB"
$html_url = "https://github.com/mRemoteNG/mRemoteNG/releases/tag/$GithubTag"
$browser_download_url = "https://github.com/mRemoteNG/mRemoteNG/releases/download/$GithubTag/$($msiFile.Name)"
$a.nightlybuild.name = "v$TagName"
$a.nightlybuild.published_at = $published_at
$a.nightlybuild.html_url = $html_url
$a.nightlybuild.assets.installer.browser_download_url = $browser_download_url
$a.nightlybuild.assets.installer.checksum = $checksum
$a.nightlybuild.assets.installer.size = $file_size
break
}
"Preview" {
$GithubTag = "$TagName-PB"
$html_url = "https://github.com/mRemoteNG/mRemoteNG/releases/tag/$GithubTag"
$browser_download_url = "https://github.com/mRemoteNG/mRemoteNG/releases/download/$GithubTag/$($msiFile.Name)"
$a.prerelease.name = "v$TagName"
$a.prerelease.published_at = $published_at
$a.prerelease.html_url = $html_url
$a.prerelease.assets.installer.browser_download_url = $browser_download_url
$a.prerelease.assets.installer.checksum = $checksum
$a.prerelease.assets.installer.size = $file_size
break
}
"Stable" {
$GithubTag = "$TagName"
$html_url = "https://github.com/mRemoteNG/mRemoteNG/releases/tag/$GithubTag"
$browser_download_url = "https://github.com/mRemoteNG/mRemoteNG/releases/download/$GithubTag/$($msiFile.Name)"
$a.stable.name = "v$TagName"
$a.stable.published_at = $published_at
$a.stable.html_url = $html_url
$a.stable.assets.installer.browser_download_url = $browser_download_url
$a.stable.assets.installer.checksum = $checksum
$a.stable.assets.installer.size = $file_size
break
}
}
}
# portable
$zipFile = Get-ChildItem -Path "$releaseFolder\*.zip" -Exclude "*-symbols-*.zip" | Sort-Object LastWriteTime | Select-Object -last 1
if (![string]::IsNullOrEmpty($zipFile)) {
$checksum = (Get-FileHash $zipFile -Algorithm SHA512).Hash
$file_size = (Get-ChildItem $zipFile).Length
$a = Get-Content $websiteJsonReleaseFile | ConvertFrom-Json
switch ($UpdateChannel) {
"Nightly" {
$GithubTag = "$((Get-Date).ToUniversalTime().ToString("yyyyMMdd"))-$TagName-NB"
$html_url = "https://github.com/mRemoteNG/mRemoteNG/releases/tag/$GithubTag"
$browser_download_url = "https://github.com/mRemoteNG/mRemoteNG/releases/download/$GithubTag/$($zipFile.Name)"
$a.nightlybuild.name = "v$TagName"
$a.nightlybuild.published_at = $published_at
$a.nightlybuild.html_url = $html_url
$a.nightlybuild.assets.portable.browser_download_url = $browser_download_url
$a.nightlybuild.assets.portable.checksum = $checksum
$a.nightlybuild.assets.portable.size = $file_size
break
}
"Preview" {
$GithubTag = "$TagName-PB"
$html_url = "https://github.com/mRemoteNG/mRemoteNG/releases/tag/$GithubTag"
$browser_download_url = "https://github.com/mRemoteNG/mRemoteNG/releases/download/$GithubTag/$($zipFile.Name)"
$a.prerelease.name = "v$TagName"
$a.prerelease.published_at = $published_at
$a.prerelease.html_url = $html_url
$a.prerelease.assets.portable.browser_download_url = $browser_download_url
$a.prerelease.assets.portable.checksum = $checksum
$a.prerelease.assets.portable.size = $file_size
break
}
"Stable" {
$GithubTag = "$TagName"
$html_url = "https://github.com/mRemoteNG/mRemoteNG/releases/tag/$GithubTag"
$browser_download_url = "https://github.com/mRemoteNG/mRemoteNG/releases/download/$GithubTag/$($zipFile.Name)"
$a.stable.name = "v$TagName"
$a.stable.published_at = $published_at
$a.stable.html_url = $html_url
$a.stable.assets.portable.browser_download_url = $browser_download_url
$a.stable.assets.portable.checksum = $checksum
$a.stable.assets.portable.size = $file_size
break
}
}
}
$a | ConvertTo-Json -Depth 10 | set-content $websiteJsonReleaseFile
# commit releases.json change
if ($env:WEBSITE_UPDATE_ENABLED.ToLower() -eq "true") {
Write-Output "publish releases.json"
if (Test-Path -Path "$releaseFolder\releases.json") {
$releases_json_string = Get-Content "$releaseFolder\releases.json" | Out-String
Set-GitHubContent -OwnerName $WebsiteTargetOwner -RepositoryName $WebsiteTargetRepository -Path _data\releases.json -CommitMessage "Updated for $UpdateChannel $ModifiedTagName" -Content $releases_json_string -BranchName main
}
}
} else {
write-host "BuildFolder not found"
}
Write-Output "End create_website_release_json_file.ps1"

View File

@@ -18,7 +18,7 @@ Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) ====="
$ConfigurationName = $ConfigurationName.Trim()
Write-Output "Config Name (trimmed): '$($ConfigurationName)'"
$exe = Join-Path -Path $TargetDir -ChildPath $TargetFileName
$Version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($exe).FileVersion
$version = ((Get-Item -Path $exe).VersionInfo | Select-Object -Property ProductVersion)."ProductVersion"
Write-Output "Version is $($version)"
# Fix for AppVeyor

View File

@@ -16,7 +16,7 @@
<Label Name="lblLogoPartA" Content="m" HorizontalAlignment="Left" VerticalAlignment="Top" Height="59" Margin="78,12,0,0" Width="40" FontFamily="HandelGotDBol" FontSize="40" Foreground="#5289F9"/>
<Label Name="lblLogoPartB" Content="RemoteNG" HorizontalAlignment="Left" VerticalAlignment="Top" Height="59" Margin="109,12,0,0" Width="210" FontFamily="HandelGotDBol" FontSize="40" Foreground="#E8EBEE"/>
<Label Name="lblLogoPartC" Content="Multi-Remote Next Generation Connection Manager" HorizontalAlignment="Center" VerticalAlignment="Top" Height="30" Margin="0,72,0,0" Width="410" FontFamily="Segoe" FontSize="16" Foreground="#E8EBEE" FontWeight="Bold"/>
<Label Name="lblLogoPartD" Content="v.?.??.?" HorizontalAlignment="Left" VerticalAlignment="Top" Height="30" Margin="319,36,0,0" Width="75" FontFamily="Segoe" FontSize="16" Foreground="#E8EBEE"/>
<Label Name="lblLogoPartD" Content="v.?.??.?" HorizontalAlignment="Left" VerticalAlignment="Top" Height="30" Margin="319,36,0,0" Width="115" FontFamily="Segoe" FontSize="16" Foreground="#E8EBEE"/>
</Grid>
</Border>
</Window>