Skip to content

Commit

Permalink
Use versions repo tooling from BuildTools.
Browse files Browse the repository at this point in the history
Sets up dependencies.props config. Removes UpdateDependencies powershell script, to be replaced by a call into VersionTools in Maestro automation. Changes UpdatePublishedVersions to pass through to VersionTools for backward compatibility.
  • Loading branch information
dagood committed Aug 22, 2016
1 parent 158db01 commit 5a63fd8
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 338 deletions.
157 changes: 0 additions & 157 deletions UpdateDependencies.ps1

This file was deleted.

138 changes: 10 additions & 128 deletions UpdatePublishedVersions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,131 +14,13 @@ param(
[Parameter(Mandatory=$true)][string]$versionsRepo,
[Parameter(Mandatory=$true)][string]$versionsRepoPath,
# A pattern matching all packages in the set that the versions repository should be set to.
[Parameter(Mandatory=$true)][string]$nupkgPath,
# Print out the new file contents, but don't change the versions repository.
[switch]$dryRun)

function ConvertPathTo-Package([string]$path)
{
# Find the package ID and version using a regex. This matches the semantic version
# and assumes everything to the left is the id or a path to the package directory.
$matched = $path -match '^(.*\\)?(.*?)\.(([0-9]+\.)?[0-9]+\.[0-9]+(-([A-z0-9-]+))?)\.(symbols\.)?nupkg$'
if ($matched)
{
$packageInfo = @{
Path = $path
Name = $matches[2]
Version = $matches[3]
Prerelease = $matches[6]
}
$packageInfo.NameVersion = "$($packageInfo.Name) $($packageInfo.Version)"
return $packageInfo
}
else
{
throw "Couldn't find name and version from path $path."
}
}

# Updates a GitHub file with the specified file contents
function Update-GitHub-File(
[string]$user = $gitHubUser,
[string]$email = $gitHubEmail,
[string]$authToken = $gitHubAuthToken,
[string]$owner = $versionsRepoOwner,
[string]$repo = $versionsRepo,
[string]$path,
[string]$newFileContent,
[string]$commitMessage)
{
function message([string]$message)
{
Write-Host -ForegroundColor Green "*** $message ***"
}

$headers = @{
'Accept' = 'application/vnd.github.v3+json'
'Authorization' = "token $authToken"
}

$fileUrl = "https://api.github.com/repos/$owner/$repo/contents/$path"

message "Getting the `"sha`" of the current contents of file '$owner/$repo/$path'"

$currentFile = Invoke-WebRequest $fileUrl -UseBasicParsing -Headers $headers
$currentSha = (ConvertFrom-Json $currentFile.Content).sha

message "Got `"sha`" value of '$currentSha'"

message "Request to update file '$owner/$repo/$path' contents to:"
Write-Host $newFileContent

if ($dryRun)
{
message 'Not sending request: dry run.'
return
}

# Base64 encode the string
function ToBase64([string]$value)
{
return [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($value))
}

$updateFileBody =
@"
{
"message": "$commitMessage",
"committer": {
"name": "$user",
"email": "$email"
},
"content": "$(ToBase64 $newFileContent)",
"sha": "$currentSha"
}
"@

message 'Sending request...'
$putResponse = Invoke-WebRequest $fileUrl -UseBasicParsing -Method PUT -Body $updateFileBody -Headers $headers

if ($putResponse.StatusCode -ge 200 -and $putResponse.StatusCode -lt 300)
{
message 'Successfully updated the file'
}
}

# Store result of Get-ChildItem before piping to ConvertPathTo-Package. When directly piping, exceptions are ignored.
$packagePaths = Get-ChildItem $nupkgPath
$packages = $packagePaths | %{ ConvertPathTo-Package $_ }

$prereleaseVersion = ''
foreach ($package in $packages)
{
if ($package.Prerelease)
{
$prereleaseVersion = $package.Prerelease
break
}
}

if (!$prereleaseVersion)
{
throw "Could not find a Prerelease version in '$newPackages'"
}

$versionFilePath = "$versionsRepoPath/Latest.txt"
$versionFileContent = "$prereleaseVersion`n"

Update-GitHub-File `
-path $versionFilePath `
-newFileContent $versionFileContent `
-commitMessage "Update '$versionFilePath' with $prereleaseVersion"

$packageInfoFilePath = "$versionsRepoPath/Latest_Packages.txt"
$packageInfoFileContent = ($packages | %{ $_.NameVersion } | Sort-Object) -join "`r`n"

Update-GitHub-File `
-path $packageInfoFilePath `
-newFileContent $packageInfoFileContent `
-commitMessage "Adding package info to '$packageInfoFilePath' for $prereleaseVersion"

[Parameter(Mandatory=$true)][string]$nupkgPath)

& "$PSScriptRoot\run.cmd" build -- tests\build.proj /t:UpdatePublishedVersions `
/p:GitHubUser="$gitHubUser" `
/p:GitHubEmail="$gitHubEmail" `
/p:GitHubAuthToken="$gitHubAuthToken" `
/p:VersionsRepoOwner="$versionsRepoOwner" `
/p:VersionsRepo="$versionsRepo" `
/p:VersionsRepoPath="$versionsRepoPath" `
/p:ShippedNuGetPackageGlobPath="$nupkgPath"
94 changes: 94 additions & 0 deletions dependencies.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Source of truth for dependency tooling: the commit hash of the dotnet/versions master branch as of the last auto-upgrade. -->
<PropertyGroup>
<CoreFxCurrentRef>afe7fab6bb2a2cd82d381eab880d290b23ed5214</CoreFxCurrentRef>
<CoreClrCurrentRef>5adc811e2d62ae1543bc3e88748476d088532d2a</CoreClrCurrentRef>
<ExternalCurrentRef>039e8532657c2599e2f8baf2c3dcd95265f28645</ExternalCurrentRef>
</PropertyGroup>

<!-- Auto-upgraded properties for each build info dependency. -->
<PropertyGroup>
<CoreFxExpectedPrerelease>beta-24328-05</CoreFxExpectedPrerelease>
<ExternalExpectedPrerelease>beta-24417-00</ExternalExpectedPrerelease>
</PropertyGroup>

<!-- Full package version strings that are used in other parts of the build. -->
<PropertyGroup>
<CoreClrPackageVersion>1.0.4-beta-24325-02</CoreClrPackageVersion>
<XunitPackageVersion>2.1.0</XunitPackageVersion>
</PropertyGroup>

<!-- Package dependency verification/auto-upgrade configuration. -->
<PropertyGroup>
<BaseDotNetBuildInfo>build-info/dotnet/</BaseDotNetBuildInfo>
<DependencyBranch>master</DependencyBranch>
<CurrentRefXmlPath>$(MSBuildThisFileFullPath)</CurrentRefXmlPath>
</PropertyGroup>

<ItemGroup>
<RemoteDependencyBuildInfo Include="CoreFx">
<BuildInfoPath>$(BaseDotNetBuildInfo)corefx/$(DependencyBranch)</BuildInfoPath>
<CurrentRef>$(CoreFxCurrentRef)</CurrentRef>
</RemoteDependencyBuildInfo>
<RemoteDependencyBuildInfo Include="CoreClr">
<BuildInfoPath>$(BaseDotNetBuildInfo)coreclr/$(DependencyBranch)</BuildInfoPath>
<CurrentRef>$(CoreClrCurrentRef)</CurrentRef>
</RemoteDependencyBuildInfo>
<RemoteDependencyBuildInfo Include="External">
<BuildInfoPath>$(BaseDotNetBuildInfo)projectk-tfs/$(DependencyBranch)</BuildInfoPath>
<CurrentRef>$(ExternalCurrentRef)</CurrentRef>
</RemoteDependencyBuildInfo>

<DependencyBuildInfo Include="@(RemoteDependencyBuildInfo)">
<RawVersionsBaseUrl>https://raw.githubusercontent.com/dotnet/versions</RawVersionsBaseUrl>
</DependencyBuildInfo>

<XmlUpdateStep Include="CoreFx">
<Path>$(MSBuildThisFileFullPath)</Path>
<ElementName>CoreFxExpectedPrerelease</ElementName>
<BuildInfoName>CoreFx</BuildInfoName>
</XmlUpdateStep>
<XmlUpdateStep Include="CoreClr">
<Path>$(MSBuildThisFileFullPath)</Path>
<ElementName>CoreClrPackageVersion</ElementName>
<PackageId>Microsoft.NETCore.Runtime.CoreCLR</PackageId>
</XmlUpdateStep>
<XmlUpdateStep Include="External">
<Path>$(MSBuildThisFileFullPath)</Path>
<ElementName>ExternalExpectedPrerelease</ElementName>
<BuildInfoName>External</BuildInfoName>
</XmlUpdateStep>
</ItemGroup>

<!-- Set up dependencies on packages that aren't found in a BuildInfo. -->
<ItemGroup>
<XUnitDependency Include="xunit"/>
<XUnitDependency Include="xunit.assert"/>
<XUnitDependency Include="xunit.core"/>
<XUnitDependency Include="xunit.runner.console"/>
<XUnitDependency Include="xunit.runner.msbuild"/>
<XUnitDependency Include="xunit.runner.utility"/>
<StaticDependency Include="@(XUnitDependency)">
<Version>$(XunitPackageVersion)</Version>
</StaticDependency>

<XunitPerformanceDependency Include="Microsoft.DotNet.xunit.performance.analysis" />
<XunitPerformanceDependency Include="Microsoft.DotNet.xunit.performance.analysis.cli" />
<XunitPerformanceDependency Include="Microsoft.DotNet.xunit.performance.metrics" />
<XunitPerformanceDependency Include="Microsoft.DotNet.xunit.performance.run.core" />
<XunitPerformanceDependency Include="Microsoft.DotNet.xunit.performance.runner.cli" />
<XunitPerformanceDependency Include="Microsoft.DotNet.xunit.performance.runner.Windows" />
<StaticDependency Include="@(XunitPerformanceDependency)">
<Version>1.0.0-alpha-build0035</Version>
</StaticDependency>

<StaticDependency Include="xunit.console.netcore">
<Version>1.0.2-prerelease-00101</Version>
</StaticDependency>

<DependencyBuildInfo Include="@(StaticDependency)">
<PackageId>%(Identity)</PackageId>
<UpdateStableVersions>true</UpdateStableVersions>
</DependencyBuildInfo>
</ItemGroup>
</Project>
Loading

0 comments on commit 5a63fd8

Please sign in to comment.