Skip to content

Commit

Permalink
#77. Package and release script done + project cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
zionyx committed Jan 8, 2018
1 parent a1b72ef commit 49bc1e9
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,5 @@ version.json
version.txt

.vscode/
# Squirrel.Windows Releases folder
Releases/
39 changes: 20 additions & 19 deletions JenkinsTray.nuspec
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Jenkins.Tray</id>
<id>JenkinsTray</id>
<version>$version$</version>
<authors>Jenkins Tray Project contributors and Hudson Tray Tracker author</authors>
<owners>Jenkins Tray Project</owners>
<licenseUrl>https://raw.githubusercontent.com/zionyx/jenkins-tray/master/LICENSE</licenseUrl>
<iconUrl>https://github.com/zionyx/jenkins-tray/raw/master/JenkinsTray/JenkinsTray.ico</iconUrl>
<projectUrl>https://github.com/zionyx/jenkins-tray</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Jenkins Tray App for Windows</description>
<copyright>Copyright 2017 Jenkins Tray Project</copyright>
<tags>Jenkins Desktop Tray Client Application</tags>
</metadata>
<files>
<file src="$BasePath$\Common.*.dll" target="lib\net45" />
<file src="$BasePath$\Common.Logging.xml" target="lib\net45" />
<file src="$BasePath$\DeltaCompressionDotNet.dll" target="lib\net45" />
<file src="$BasePath$\DeltaCompressionDotNet.*.dll" target="lib\net45" />
<file src="$BasePath$\DevExpress.*.dll" target="lib\net45" />
<file src="$BasePath$\ICSharpCode.SharpZipLib.dll" target="lib\net45" />
<file src="$BasePath$\JenkinsTray.exe" target="lib\net45" />
<file src="$BasePath$\JenkinsTray.exe.config" target="lib\net45" />
<file src="$BasePath$\JenkinsTray.ico" target="lib\net45" />
<file src="$BasePath$\log4net.dll" target="lib\net45" />
<file src="$BasePath$\LoggingConfig.xml" target="lib\net45" />
<file src="$BasePath$\Mono.*.dll" target="lib\net45" />
<file src="$BasePath$\Newtonsoft.Json.dll" target="lib\net45" />
<file src="$BasePath$\NuGet.Squirrel.dll" target="lib\net45" />
<file src="$BasePath$\SmartThreadPool.dll" target="lib\net45" />
<file src="$BasePath$\Splat.dll" target="lib\net45" />
<file src="$BasePath$\Spring.Core.dll" target="lib\net45" />
<file src="$BasePath$\Squirrel.dll" target="lib\net45" />
<file src="Common.*.dll" target="lib\net45" />
<file src="Common.Logging.xml" target="lib\net45" />
<file src="DeltaCompressionDotNet.dll" target="lib\net45" />
<file src="DeltaCompressionDotNet.*.dll" target="lib\net45" />
<file src="DevExpress.*.dll" target="lib\net45" />
<file src="ICSharpCode.SharpZipLib.dll" target="lib\net45" />
<file src="JenkinsTray.exe" target="lib\net45" />
<file src="JenkinsTray.exe.config" target="lib\net45" />
<file src="JenkinsTray.ico" target="lib\net45" />
<file src="log4net.dll" target="lib\net45" />
<file src="LoggingConfig.xml" target="lib\net45" />
<file src="Mono.*.dll" target="lib\net45" />
<file src="Newtonsoft.Json.dll" target="lib\net45" />
<file src="NuGet.Squirrel.dll" target="lib\net45" />
<file src="SmartThreadPool.dll" target="lib\net45" />
<file src="Splat.dll" target="lib\net45" />
<file src="Spring.Core.dll" target="lib\net45" />
<file src="Squirrel.dll" target="lib\net45" />
</files>
</package>
1 change: 0 additions & 1 deletion JenkinsTray/JenkinsTray.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@
<DependentUpon>EditServerForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\licenses.licx" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
Expand Down
6 changes: 0 additions & 6 deletions JenkinsTray/Properties/licenses.licx

This file was deleted.

53 changes: 53 additions & 0 deletions scripts/build-utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,59 @@ function Exec-Command([string]$command, [string]$commandArgs, [switch]$forwardEx
}
}

# Refer to Exec-Command above
#
# Returns stdout, stderr and exit code as an array.
function Exec-Command2([string]$command, [string]$commandArgs) {
$startInfo = New-Object System.Diagnostics.ProcessStartInfo
$startInfo.FileName = $command
$startInfo.Arguments = $commandArgs

$startInfo.RedirectStandardOutput = $true
$startInfo.UseShellExecute = $false
$startInfo.CreateNoWindow = $true
$startInfo.WorkingDirectory = Get-Location

$process = New-Object System.Diagnostics.Process
$process.StartInfo = $startInfo
$process.StartInfo.RedirectStandardOutput = $true;
$process.StartInfo.RedirectStandardError = $true;
$process.Start() | Out-Null

$finished = $false
$stdout = [string]::Empty
$stderr = [string]::Empty
$exitCode = -1
try {
# The OutputDataReceived event doesn't fire as events are sent by the
# process in powershell. Possibly due to subtlties of how Powershell
# manages the thread pool that I'm not aware of. Using blocking
# reading here as an alternative which is fine since this blocks
# on completion already.
$stdout = $process.StandardOutput.ReadToEnd()
$stderr = $process.StandardError.ReadToEnd()
while (-not $process.WaitForExit(100)) {
# Non-blocking loop done to allow ctr-c interrupts
}

$finished = $true
$exitCode = $process.ExitCode
}
catch {
Write-Host "$($_.Exception.Message)"
$exitCode = -1
}
finally {
# If we didn't finish then an error occured or the user hit ctrl-c. Either
# way kill the process
if (-not $finished) {
$process.Kill()
$exitCode = -1
}
}
return $stdout, $stderr, $exitCode
}

# Handy function for executing a powershell script in a clean environment with
# arguments. Prefer this over & sourcing a script as it will both use a clean
# environment and do proper error checking
Expand Down
37 changes: 30 additions & 7 deletions scripts/package-release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,47 @@ param (
#Requires -Version 3.0

try {
. (Join-Path $PSScriptRoot "build-utils.ps1")

if (!(Test-Path $repoRoot -PathType Container)) {
Write-Error "$repoRoot does not exist. Aborting."
}
if (!(Test-Path $versionjson -PathType Leaf)) {
Write-Error "$versionjson does not exist. Aborting."
}
if (!(Test-Path $nuspec -PathType Leaf)) {
Write-Error "$nuspec does not exist. Aborting."
}
if (!(Test-Path $outputPath -PathType Container)) {
Write-Error "$outputPath does not exist. Aborting."
}
$squirrelPath = Get-Item -Path "$($repoRoot)\packages\*" -Filter "squirrel.windows*"
if (!(Test-Path "$($squirrelPath)\tools" -PathType Container)) {
Write-Error "$($squirrelPath)\tools is not found. Aborting." -ErrorAction Stop
Write-Error "$($squirrelPath)\tools is not found. Aborting."
}

$json = Get-Content $versionjson | ConvertFrom-Json
. (Join-Path $PSScriptRoot "build-utils.ps1")

Get-ChildItem -Path $repoRoot -Filter *.nupkg -ErrorAction SilentlyContinue | Remove-Item -Force | Out-Host

$json = Get-Content $versionjson | ConvertFrom-Json
$nuget = Ensure-NuGet
Exec-Command -command $nuget -commandArgs "pack `"$($nuspec)`" -o `"$($repoRoot)`" -Version $($json.MajorMinorPatch) -NonInteractive -Properties BasePath=$outputPath" | Out-Host

$nupkg = Get-ChildItem -Path "$($repoRoot)" -Filter "Jenkins.Tray*.nupkg"
$cmdInfo = Exec-Command2 -command $nuget -commandArgs "pack `"$($nuspec)`" -o `"$($repoRoot)`" -Version $($json.MajorMinorPatch) -NonInteractive -BasePath `"$outputPath`"" -forwardExitCode
Write-Host $cmdInfo[0], $cmdInfo[1]
if ($cmdInfo[2] -ne 0) {
Write-Error "NuGet package generation failed. Aborting."
}

$nupkg = Get-ChildItem -Path $repoRoot -Filter "Jenkins*.nupkg" | Select -First 1
if (!(Test-Path $nupkg -PathType Leaf)) {
Write-Error "Cannot find NuGet package. Aborting." -ErrorAction Stop
Write-Error "Cannot find NuGet package. Aborting."
}

Exec-Command -command "$($squirrelPath)\tools\Squirrel.exe" -commandArgs "--releasify $($nupkg.FullName)" | Out-Host
$cmdInfo = Exec-Command2 -command "$($squirrelPath)\tools\Squirrel.exe" -commandArgs "--releasify $($nupkg.FullName)"
Write-Host $cmdInfo[0], $cmdInfo[1]
if ($cmdInfo[2] -ne 0) {
Write-Error "Squirrel releasify failed. Aborting."
}
Write-Host "Releasified $($nupkg.FullName)."

} catch {
Expand Down

0 comments on commit 49bc1e9

Please sign in to comment.