diff --git a/src/Plugin.Discord/DeployBetaToGithub.cmd b/src/Plugin.Discord/DeployBetaToGithub.cmd new file mode 100644 index 00000000..3033a56f --- /dev/null +++ b/src/Plugin.Discord/DeployBetaToGithub.cmd @@ -0,0 +1,2 @@ +powershell -ExecutionPolicy Bypass -File MakeLatestBetaVersionGithub.ps1 +PAUSE \ No newline at end of file diff --git a/src/Plugin.Discord/DeployToGithub.cmd b/src/Plugin.Discord/DeployToGithub.cmd new file mode 100644 index 00000000..dd24efae --- /dev/null +++ b/src/Plugin.Discord/DeployToGithub.cmd @@ -0,0 +1,2 @@ +powershell -ExecutionPolicy Bypass -File MakeLatestVersionGithub.ps1 +PAUSE \ No newline at end of file diff --git a/src/Plugin.Discord/MakeLatestBetaVersionGithub.ps1 b/src/Plugin.Discord/MakeLatestBetaVersionGithub.ps1 new file mode 100644 index 00000000..bd73472c --- /dev/null +++ b/src/Plugin.Discord/MakeLatestBetaVersionGithub.ps1 @@ -0,0 +1,111 @@ +Param +( + [Parameter()] + [string]$rootPath = "D:\GitHub\ServerManagers\src\Plugin.Discord", + + [Parameter()] + [string]$binDir = "bin\Release\net462", + + [Parameter()] + [string]$publishDir = "Publish", + + [Parameter()] + [string]$srcFilename = "ServerManager.Plugin.Discord.dll", + + [Parameter()] + [string]$destLatestFilename = "latestbeta.txt", + + [Parameter()] + [string]$filenamePrefix = "ServerManager.Plugin.Discord_", + + [Parameter()] + [string]$feedFilename = "VersionFeedBeta.xml", + + [Parameter()] + [string]$signTool = "C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\SignTool.exe", + + [Parameter()] + [string]$signNFlag = "${env:SIGN_NFLAG}", + + [Parameter()] + [string]$signTFlag = "http://timestamp.digicert.com", + + [Parameter()] + [string]$githubRoot = "D:\GitHub\ServerManagers\Plugins\Discord\beta" +) + +[string] $AppVersion = "" +[string] $AppVersionShort = "" + +function Get-LatestVersion( $srcFile ) +{ + $assembly = [Reflection.Assembly]::Loadfile($srcFile) + $assemblyName = $assembly.GetName() + return $assemblyName.version; +} + +function Sign-Application ( $sourcedir , $signFile ) +{ + if(Test-Path $signTool) + { + if(($signFile -ne "") -and ($signNFlag -ne "") -and ($signTFlag -ne "")) + { + Write-Host "Signing $($signFile)" + & $signTool sign /n "$($signNFlag)" /t $signTFlag "$($sourcedir)\$($signFile)" + } + } +} + +function Create-Zip( $sourcePath , $zipFile ) +{ + if(Test-Path $zipFile) + { + Remove-Item -LiteralPath:$zipFile -Force + } + Add-Type -Assembly System.IO.Compression.FileSystem + Write-Host "Zipping $($sourcePath) into $($zipFile)" + $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal + [System.IO.Compression.ZipFile]::CreateFromDirectory($sourcePath, $zipFile, $compressionLevel, $false) +} + +$srcFile = "$($rootPath)\$($binDir)\$($srcFilename)" +$feedFile = "$($rootPath)\$($feedFilename)" +$languageFile = "$($rootPath)\Globalization\en-US\en-US.xaml" + +$AppVersion = Get-LatestVersion $srcFile +$AppVersionShort = $AppVersion +Write-Host "LatestVersion $($AppVersionShort) ($($AppVersion))" + +# test if the publish directory exists +$versionWithUnderscores = $AppVersion.Replace('.', '_') +$publishPath = "$($rootPath)\$($publishDir)\$($filenamePrefix)$($versionWithUnderscores)" +if(!(Test-Path -Path ($publishPath))) +{ + Write-Host "Creating folder $($publishPath)" + + # create the destination directory + New-Item -ItemType directory -Path "$($publishPath)" +} + +# copy the source file +Copy-Item -Path $($srcFile) -Destination $($publishPath) -Force +Write-Host "Copied $($srcFile) to $($publishPath)" + +# write latest version file +$txtDestFileName = "$($destLatestFilename)" +$txtDestFile = "$($rootPath)\$($publishDir)\$($txtDestFileName)" +$AppVersionShort | Set-Content "$($txtDestFile)" + +Sign-Application $publishPath "*.dll" + +# create the zip file +$zipDestFileName = "$($filenamePrefix)$($AppVersionShort).zip" +$zipDestFile = "$($rootPath)\$($publishDir)\$($zipDestFileName)" +Create-Zip $publishPath $zipDestFile + +# copy the files to the GITHUB folder +Write-Host "Copying files to the github folder" +Copy-Item -Path "$feedFile" -Destination "$githubRoot\VersionFeed.xml" +Copy-Item -Path "$languageFile" -Destination $githubRoot +Copy-Item -Path "$txtDestFile" -Destination "$githubRoot\latest.txt" +Copy-Item -Path "$zipDestFile" -Destination "$githubRoot\latest.zip" diff --git a/src/Plugin.Discord/MakeLatestVersionGithub.ps1 b/src/Plugin.Discord/MakeLatestVersionGithub.ps1 new file mode 100644 index 00000000..861ea7bd --- /dev/null +++ b/src/Plugin.Discord/MakeLatestVersionGithub.ps1 @@ -0,0 +1,112 @@ +Param +( + [Parameter()] + [string]$rootPath = "D:\GitHub\ServerManagers\src\Plugin.Discord", + + [Parameter()] + [string]$binDir = "bin\Release\net462", + + [Parameter()] + [string]$publishDir = "Publish", + + [Parameter()] + [string]$srcFilename = "ServerManager.Plugin.Discord.dll", + + [Parameter()] + [string]$destLatestFilename = "latest.txt", + + [Parameter()] + [string]$filenamePrefix = "ServerManager.Plugin.Discord_", + + [Parameter()] + [string]$feedFilename = "VersionFeed.xml", + + [Parameter()] + [string]$signTool = "C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\SignTool.exe", + + [Parameter()] + [string]$signNFlag = "${env:SIGN_NFLAG}", + + [Parameter()] + [string]$signTFlag = "http://timestamp.digicert.com", + + [Parameter()] + [string]$githubRoot = "D:\GitHub\ServerManagers\Plugins\Discord" +) + +[string] $AppVersion = "" +[string] $AppVersionShort = "" + +function Get-LatestVersion( $srcFile ) +{ + $assembly = [Reflection.Assembly]::Loadfile($srcFile) + $assemblyName = $assembly.GetName() + return $assemblyName.version; +} + +function Sign-Application ( $sourcedir , $signFile ) +{ + if(Test-Path $signTool) + { + if(($signFile -ne "") -and ($signNFlag -ne "") -and ($signTFlag -ne "")) + { + Write-Host "Signing $($signFile)" + & $signTool sign /n "$($signNFlag)" /t $signTFlag "$($sourcedir)\$($signFile)" + } + } +} + +function Create-Zip( $sourcePath , $zipFile ) +{ + if(Test-Path $zipFile) + { + Remove-Item -LiteralPath:$zipFile -Force + } + Add-Type -Assembly System.IO.Compression.FileSystem + Write-Host "Zipping $($sourcePath) into $($zipFile)" + $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal + [System.IO.Compression.ZipFile]::CreateFromDirectory($sourcePath, $zipFile, $compressionLevel, $false) +} + +$srcFile = "$($rootPath)\$($binDir)\$($srcFilename)" +$feedFile = "$($rootPath)\$($feedFilename)" +$languageFile = "$($rootPath)\Globalization\en-US\en-US.xaml" + +$AppVersion = Get-LatestVersion $srcFile +$AppVersionShort = $AppVersion.Substring(0, $AppVersion.LastIndexOf('.')) +Write-Host "LatestVersion $($AppVersionShort) ($($AppVersion))" + +# test if the publish directory exists +$versionWithUnderscores = $AppVersion.Replace('.', '_') +$publishPath = "$($rootPath)\$($publishDir)\$($filenamePrefix)$($versionWithUnderscores)" +if(!(Test-Path -Path ($publishPath))) +{ + Write-Host "Creating folder $($publishPath)" + + # create the destination directory + New-Item -ItemType directory -Path "$($publishPath)" +} + +# copy the source file +Copy-Item -Path $($srcFile) -Destination $($publishPath) -Force +Write-Host "Copied $($srcFile) to $($publishPath)" + +# write latest version file +$txtDestFileName = "$($destLatestFilename)" +$txtDestFile = "$($rootPath)\$($publishDir)\$($txtDestFileName)" +$AppVersionShort | Set-Content "$($txtDestFile)" + +Sign-Application $publishPath "*.dll" + +# create the zip file +$zipDestFileName = "$($filenamePrefix)$($AppVersionShort).zip" +$zipDestFile = "$($rootPath)\$($publishDir)\$($zipDestFileName)" +Create-Zip $publishPath $zipDestFile + +# copy the files to the GITHUB folder +Write-Host "Copying files to the github folder" +Copy-Item -Path "$feedFile" -Destination "$githubRoot\VersionFeed.xml" +Copy-Item -Path "$languageFile" -Destination $githubRoot +Copy-Item -Path "$zipDestFile" -Destination $githubRoot +Copy-Item -Path "$txtDestFile" -Destination "$githubRoot\latest.txt" +Copy-Item -Path "$zipDestFile" -Destination "$githubRoot\latest.zip" diff --git a/src/Plugin.Discord/Plugin.Discord.csproj b/src/Plugin.Discord/Plugin.Discord.csproj index 5879a668..b0530f7b 100644 --- a/src/Plugin.Discord/Plugin.Discord.csproj +++ b/src/Plugin.Discord/Plugin.Discord.csproj @@ -30,9 +30,13 @@ + + + +