Skip to content

Prepare projects for NuGet publishing #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ App_Data
TestResults
[Tt]humbs.db
buildd.*
build/cxtcache/
release/
*.log
*.bak
packages
Expand Down
10 changes: 7 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
version: 0.2.0.{build}
version: '$(core_version).{build}'
os: Unstable
configuration: Release
clone_depth: 10

environment:
core_version: '0.2.0'
prerelease_name: '-beta'

branches:
only:
- master
Expand All @@ -18,9 +22,9 @@ branches:
assembly_info:
patch: true
file: '**\AssemblyInfo.*'
assembly_version: '0.2.0' # This version number should always have 0 for the last section
assembly_version: '{version}'
assembly_file_version: '{version}'
assembly_informational_version: '{version}'
assembly_informational_version: '$(core_version)$(prerelease_name)+{build}'

install:
- git submodule -q update --init
Expand Down
51 changes: 51 additions & 0 deletions scripts/FetchLatestBuild.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
param($buildVersion = $null)

$releasePath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\release")
$binariesToSignPath = [System.IO.Path]::GetFullPath("$releasePath\BinariesToSign")
$unpackedPackagesPath = [System.IO.Path]::GetFullPath("$releasePath\UnpackedPackages")

# Ensure that the release path exists and clear out old folders
mkdir $releasePath -Force | Out-Null

# Install prerequisite packages
#Install-Package -Name "Nito.AsyncEx" -RequiredVersion "3.0.1" -Source "nuget.org" -ProviderName "NuGet" -Destination $buildPath -Force
#Install-Package -Name "Newtonsoft.Json" -RequiredVersion "7.0.1" -Source "nuget.org" -ProviderName "NuGet" -Destination $buildPath -Force

if ($buildVersion -eq $null) {
# Get the current build status
$headers = @{ "Content-Type" = "application/json" }
$project = Invoke-RestMethod -Method Get -Uri "https://ci.appveyor.com/api/projects/PowerShell/PowerShellEditorServices/branch/master" -Headers $headers
$buildVersion = $project.build.version
if ($project.build.status -eq "success") {
Write-Output "Latest build version on master is $buildVersion`r`n"
}
else {
Write-Error "PowerShellEditorServices build $buildVersion was not successful!" -ErrorAction "Stop"
}
}

function Install-BuildPackage($packageName, $extension) {
$uri = "https://ci.appveyor.com/nuget/powershelleditorservices/api/v2/package/{0}/{1}" -f $packageName.ToLower(), $buildVersion
Write-Verbose "Fetching from URI: $uri"

# Download the package and extract it
$zipPath = "$releasePath\$packageName.zip"
$packageContentPath = "$unpackedPackagesPath\$packageName"
Invoke-WebRequest $uri -OutFile $zipPath -ErrorAction "Stop"
Expand-Archive $zipPath -DestinationPath $packageContentPath -Force -ErrorAction "Stop"
Remove-Item $zipPath -ErrorAction "Stop"

# Copy the binary to the binary signing folder
mkdir $binariesToSignPath -Force | Out-Null
cp "$packageContentPath\lib\net45\$packageName.$extension" -Force -Destination $binariesToSignPath

Write-Output "Extracted package $packageName ($buildVersion)"
}

# Pull the build packages from AppVeyor
Install-BuildPackage "Microsoft.PowerShell.EditorServices" "dll"
Install-BuildPackage "Microsoft.PowerShell.EditorServices.Protocol" "dll"
Install-BuildPackage "Microsoft.PowerShell.EditorServices.Host" "exe"

# Open the BinariesToSign folder
& start $binariesToSignPath
33 changes: 33 additions & 0 deletions scripts/PackageSignedBinaries.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This script assumes the FetchBuildBinaries.ps1 has been run and
# the binaries in 'release\BinariesToSign' have been signed and
# replaced.

param($FailIfNotSigned = $true)

$releasePath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\release")
$finalPackagePath = [System.IO.Path]::GetFullPath("$releasePath\FinalPackages")
$binariesToSignPath = [System.IO.Path]::GetFullPath("$releasePath\BinariesToSign")
$unpackedPackagesPath = [System.IO.Path]::GetFullPath("$releasePath\UnpackedPackages")
$nugetPath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\.nuget\NuGet.exe")

mkdir $finalPackagePath -Force | Out-Null

$binaries = Get-ChildItem $binariesToSignPath
foreach ($binaryPath in $binaries) {
$signature = Get-AuthenticodeSignature $binaryPath.FullName

# TODO: More validation here?
if ($signature.Status -eq "NotSigned" -and $FailIfNotSigned) {
Write-Error "Binary file is not authenticode signed: $binaryPath" -ErrorAction Stop
}

# Copy the file back where it belongs
$packageName = [System.IO.Path]::GetFileNameWithoutExtension($binaryPath)
$packagePath = "$unpackedPackagesPath\$packageName"
cp $binaryPath.FullName -Destination "$packagePath\lib\net45\" -Force

# Repackage the nupkg with NuGet
Push-Location $finalPackagePath
& $nugetPath pack "$packagePath\$packageName.nuspec"
Pop-Location
}
22 changes: 22 additions & 0 deletions scripts/PublishPackages.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

$releasePath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\release")
$finalPackagePath = [System.IO.Path]::GetFullPath("$releasePath\FinalPackages")
$nugetPath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\.nuget\NuGet.exe")

$packages = Get-ChildItem $finalPackagePath -Filter "*.nupkg"

foreach ($package in $packages) {
& $nugetPath push -NonInteractive $package.FullName
if ($LASTEXITCODE -ne 0)
{
Write-Output "`r`n'nuget push' has failed. You may need to run the following command to set the NuGet account API key:`r`n"
Write-Output "& $nuGetPath setApiKey"
break
}
else
{
Write-Output "Pushed package $package.FullName"
}
}

# TODO: Use Find-Package to verify that the package is there?
16 changes: 16 additions & 0 deletions scripts/ReleaseProcess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## PowerShell Editor Services Release Process

1. Find the latest build version for the `master` branch on AppVeyor:

2. Run `.\scripts\FetchLatestBuild.ps1`

3. Once this script completes, sign the binaries in `.\release\BinariesToSign`.

4. Once you have the authenticode-signed binaries, copy them back into
`.\release\BinariesToSign`

5. Run `.\scripts\PackageSignedBinaries.ps1`. If any binaries didn't get signed
correctly, this script will tell you. Once this script completes, the updated
.nupkg files will be in `.\release\FinalPackages`

6. Run `.\scripts\PublishPackages.ps1` to publish the final packages to NuGet.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>Windows PowerShell Editor Services - Host Process</title>
<title>PowerShell Editor Services Host Process</title>
<authors>$author$</authors>
<owners>$author$</owners>
<licenseUrl>https://raw.githubusercontent.com/PowerShell/PowerShellEditorServices/master/LICENSE</licenseUrl>
<projectUrl>http://github.com/PowerShell/PowerShellEditorServices</projectUrl>
<projectUrl>https://github.com/PowerShell/PowerShellEditorServices</projectUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>$description$</description>
<copyright>� Microsoft Corporation. All rights reserved.</copyright>
<tags>Microsoft Windows PowerShell editor</tags>
</metadata>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
<tags>PowerShell editor development language debugging</tags>
<dependencies>
<group>
<dependency id="Microsoft.PowerShell.EditorServices" version="$version$" />
<dependency id="Microsoft.PowerShell.EditorServices.Protocol" version="$version$" />
</group>
</dependencies>
</metadata>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("PowerShell Editor Services - Host Process")]
[assembly: AssemblyTitle("PowerShell Editor Services Host Process")]
[assembly: AssemblyDescription("Provides a process for hosting the PowerShell Editor Services library exposed by a JSON message protocol.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>Windows PowerShell Editor Services - Standard I/O Transport</title>
<title>PowerShell Editor Services Host Protocol Library</title>
<authors>$author$</authors>
<owners>$author$</owners>
<licenseUrl>https://raw.githubusercontent.com/PowerShell/PowerShellEditorServices/master/LICENSE</licenseUrl>
<projectUrl>http://github.com/PowerShell/PowerShellEditorServices</projectUrl>
<projectUrl>https://github.com/PowerShell/PowerShellEditorServices</projectUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>$description$</description>
<copyright>� Microsoft Corporation. All rights reserved.</copyright>
<tags>Microsoft Windows PowerShell editor</tags>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
<tags>PowerShell editor development language debugging</tags>
<dependencies>
<group>
<dependency id="Microsoft.PowerShell.EditorServices" version="$version$" />
</group>
</dependencies>
</metadata>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("PowerShell Editor Services - Standard I/O Transport")]
[assembly: AssemblyDescription("Provides standard I/O transport for the PowerShell Editor Services host process.")]
[assembly: AssemblyTitle("PowerShell Editor Services Host Protocol Library")]
[assembly: AssemblyDescription("Provides message types and client/server APIs for the PowerShell Editor Services JSON protocol.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("PowerShell Editor Services")]
Expand Down
8 changes: 4 additions & 4 deletions src/PowerShellEditorServices/PowerShellEditorServices.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>Windows PowerShell Editor Services Library</title>
<title>PowerShell Editor Services</title>
<authors>$author$</authors>
<owners>$author$</owners>
<licenseUrl>https://raw.githubusercontent.com/PowerShell/PowerShellEditorServices/master/LICENSE</licenseUrl>
<projectUrl>http://github.com/PowerShell/PowerShellEditorServices</projectUrl>
<projectUrl>https://github.com/PowerShell/PowerShellEditorServices</projectUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>$description$</description>
<copyright> Microsoft Corporation. All rights reserved.</copyright>
<tags>Microsoft Windows PowerShell editor</tags>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
<tags>PowerShell editor development language debugging</tags>
</metadata>
</package>
2 changes: 1 addition & 1 deletion src/PowerShellEditorServices/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("PowerShell Editor Services Library")]
[assembly: AssemblyTitle("PowerShell Editor Services")]
[assembly: AssemblyDescription("Provides common PowerShell editor capabilities as a .NET library.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
Expand Down