Files
git-tfs/Release.proj
T
2014-06-16 10:33:04 -04:00

228 lines
10 KiB
XML

<?xml version="1.0"?>
<Project ToolsVersion="4.0" DefaultTargets="Help" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Where the solution lives, relative to this file. -->
<SolutionDir>.</SolutionDir>
<!-- The file that includes the AssemblyVersionAttribute. -->
<VersionFilePath>$(SolutionDir)\Version.cs</VersionFilePath>
<!-- git-tfs can run as 32-bit or 64-bit. -->
<TargetPlatform>Any CPU</TargetPlatform>
<!-- Where git-tfs.exe and its dependencies are built. -->
<BuildDir>$(SolutionDir)/GitTfs/bin/Release</BuildDir>
<!-- The name of the output zip file. -->
<PackagedDir>$(SolutionDir)/Releases</PackagedDir>
<PackageFile>GitTfs-$(Version).zip</PackageFile>
<Archive>$(PackagedDir)/$(PackageFile)</Archive>
<!-- Where to push the release tag. -->
<GitHubOwner>git-tfs</GitHubOwner>
<GitHubRepository>git-tfs</GitHubRepository>
<OriginUrl>https://github.com/$(GitHubOwner)/$(GitHubRepository).git</OriginUrl>
<!-- The API doesn't provide this, but it follows a pattern that we can mimic. -->
<DownloadUrl>https://github.com/git-tfs/git-tfs/releases/download/v$(Version)/$(PackageFile)</DownloadUrl>
<!-- A directory to use when changing the download button on the website. -->
<WebSiteDir>$(PackagedDir)/git-tfs.github.com</WebSiteDir>
<DownloadButton>_includes/download_button.html</DownloadButton>
<WebSiteRepository>https://github.com/$(GitHubOwner)/git-tfs.github.com.git</WebSiteRepository>
</PropertyGroup>
<!-- Internal. -->
<Target Name="VersionRequired">
<Error Text="You must specify a version number! (/p:Version=X.Y.Z)" Condition="'$(Version)' == ''" />
</Target>
<!-- Try to load the oauth token -->
<Import Project="Auth.targets" Condition="Exists('Auth.targets')" />
<!-- Internal. -->
<Target Name="AuthTokenRequired">
<Error Text="You must set a github.com auth token in auth.targets (see auth.targets.example)" Condition="'$(GitHubAuthToken)' == ''" />
</Target>
<!-- The contents of the zip. -->
<ItemGroup>
<ReleaseFiles Include="$(SolutionDir)\README.md" />
<ReleaseFiles Include="$(SolutionDir)\LICENSE" />
<ReleaseFiles Include="$(SolutionDir)\NOTICE" />
<ReleaseFiles Include="$(BuildDir)\git-tfs.exe" />
<ReleaseFiles Include="$(BuildDir)\*.config" />
<ReleaseFiles Include="$(BuildDir)\*.dll" Exclude="$(BuildDir)\Microsoft.*.dll" />
<ReleaseFiles Include="$(BuildDir)\NativeBinaries\**\*.dll" />
</ItemGroup>
<!-- The zip. -->
<ItemGroup>
<ArchiveFile Include="$(Archive)">
<ContentType>application/zip</ContentType>
</ArchiveFile>
</ItemGroup>
<!-- Load nuget, so we can get dependencies. (Dependencies are not checked in to git.) -->
<PropertyGroup>
<PackagesConfig>$(SolutionDir)/.nuget/packages.config</PackagesConfig>
<RequireRestoreConsent>false</RequireRestoreConsent>
<MSBuildCommunityTasksPath>$(SolutionDir)/packages/MSBuildTasks.1.4.0.45/tools</MSBuildCommunityTasksPath>
<MSBuildCommunityTasksLib>$(MSBuildCommunityTasksPath)/MSBuild.Community.Tasks.dll</MSBuildCommunityTasksLib>
<MSBuildGitTfsTasksLib>$(SolutionDir)/packages/MSBuildGitTfsTasks/GitTfsTasks.dll</MSBuildGitTfsTasksLib>
</PropertyGroup>
<Import Project="$(SolutionDir)/.nuget/nuget.targets" />
<!-- Load some extra tasks. -->
<Target Name="MSBuildCommunityTasks" DependsOnTargets="RestorePackages" />
<UsingTask AssemblyFile="$(MSBuildCommunityTasksLib)" TaskName="MSBuild.Community.Tasks.TemplateFile" />
<UsingTask AssemblyFile="$(MSBuildCommunityTasksLib)" TaskName="MSBuild.Community.Tasks.Zip" />
<UsingTask AssemblyFile="$(MSBuildCommunityTasksLib)" TaskName="MSBuild.Community.Tasks.FileUpdate" />
<UsingTask AssemblyFile="$(MSBuildGitTfsTasksLib)" TaskName="GitTfsTasks.CreateRelease" />
<!-- Default: Show the howto. -->
<Target Name="Help">
<ReadLinesFromFile File="Releasing.md">
<Output TaskParameter="Lines" ItemName="DeployInstructions"/>
</ReadLinesFromFile>
<Message Text="@(DeployInstructions->'%(Identity)','%0a%0d')" />
</Target>
<!-- Public: Build the release and put it on github.com -->
<Target Name="Release" DependsOnTargets="EverythingRequired; UpdateVersion; Build; TagSource; PushSource; Package; ReleaseOnGitHub; UpdateWebSite; Chocolatey">
</Target>
<!-- Internal: If we don't have all the information we need, bail early. -->
<Target Name="EverythingRequired" DependsOnTargets="VersionRequired; AuthTokenRequired">
</Target>
<!-- Internal: Called by Release to set the new version. -->
<Target Name="UpdateVersion" DependsOnTargets="UpdateAssemblyVersionAttribute; UpdateVersionInReadme">
<Exec Command="git commit -m v$(Version) $(VersionFilePath) README.md" />
</Target>
<!-- Internal. -->
<Target Name="UpdateAssemblyVersionAttribute" DependsOnTargets="VersionRequired">
<WriteLinesToFile File="$(VersionFilePath)" Lines="partial class GitTfsProperties ; { ; public const string Version = %22$(Version)%22%3B ; }" Overwrite="true" Encoding="ASCII"/>
</Target>
<!-- Internal. -->
<Target Name="UpdateVersionInReadme" DependsOnTargets="VersionRequired">
<FileUpdate Files="README.md" Regex="The most recent version is __.*__\." ReplacementText="The most recent version is __$(Version)__." />
</Target>
<!-- Internal: Called by release to compile git-tfs.exe -->
<Target Name="Build">
<MSBuild Projects="GitTfs.sln" Targets="Rebuild" Properties="Configuration=Release;Platform=$(TargetPlatform);WarningLevel=0" />
</Target>
<!-- Internal: Called by Release to tag the git-tfs repository. -->
<Target Name="TagSource" DependsOnTargets="VersionRequired">
<Exec Command="git tag v$(Version)" />
</Target>
<!-- Internal: Called by Release to push the release tag to github.com -->
<Target Name="PushSource" DependsOnTargets="VersionRequired">
<Exec Command="git push $(OriginUrl) master v$(Version)" />
</Target>
<!-- Internal: Called by Release to create the zip. -->
<Target Name="Package" DependsOnTargets="VersionRequired; MSBuildCommunityTasks">
<Zip Files="@(ReleaseFiles)" ZipFileName="$(Archive)" WorkingDirectory="$(BuildDir)" />
</Target>
<!-- Internal: Create a release on github.com -->
<Target Name="ReleaseOnGitHub" DependsOnTargets="VersionRequired; AuthTokenRequired; MSBuildCommunityTasks">
<CreateRelease Repository="$(GitHubOwner)/$(GitHubRepository)" TagName="v$(Version)" Files="@(ArchiveFile)" OauthToken="$(GitHubAuthToken)" ReleaseNotesFile="$(ReleaseNotes)" />
</Target>
<!-- Internal: Update the "download" button on git-tfs.com -->
<Target Name="UpdateWebSite" DependsOnTargets="VersionRequired; ClonePagesRepository">
<Exec WorkingDirectory="$(WebSiteDir)" Command="git checkout master" />
<WriteLinesToFile File="$(WebSiteDir)/$(DownloadButton)" Lines="&lt;a href=%22$(DownloadUrl)%22 class=%22download-button%22&gt;Download v$(Version)&lt;/a&gt;" Overwrite="true" Encoding="ASCII"/>
<Exec WorkingDirectory="$(WebSiteDir)" Command="git commit -m %22v$(Version)%22 $(DownloadButton)" />
<Exec WorkingDirectory="$(WebSiteDir)" Command="git push $(WebSiteRepository) master" />
</Target>
<!-- Internal. -->
<Target Name="ClonePagesRepository" Condition="!Exists($(WebSiteDir))">
<Exec Command="git clone $(WebSiteRepository) $(WebSiteDir)" />
</Target>
<!-- Internal: Build and upload a chocolatey package. -->
<Target Name="Chocolatey" DependsOnTargets="CleanChocolateyTempDir; PushChocolateyPackage">
</Target>
<!-- Chocolatey-releated properties. -->
<PropertyGroup>
<ChocolateyBuildDir>$(SolutionDir)\tmp\choc</ChocolateyBuildDir>
<ChocolateyTemplateDir>$(SolutionDir)\ChocolateyTemplates</ChocolateyTemplateDir>
<ChocolateyNupkg>$(ChocolateyBuildDir)\gittfs.$(Version).nupkg</ChocolateyNupkg>
</PropertyGroup>
<!-- Chocolatey-related files. -->
<ItemGroup>
<!-- TemplateFile needs a full path, so we define the output files here so that MSBuild can resolve the paths. -->
<ChocolateyNuspec Include="$(ChocolateyBuildDir)\gittfs.nuspec" />
<ChocolateyInstallScript Include="$(ChocolateyBuildDir)/tools/chocolateyInstall.ps1" />
</ItemGroup>
<!-- Internal. -->
<Target Name="CleanChocolateyTempDir">
<RemoveDir Directories="$(ChocolateyBuildDir)" />
</Target>
<!-- Internal. -->
<Target Name="ChocolateyTempDir">
<MakeDir Directories="$(ChocolateyBuildDir)\tools" />
</Target>
<!-- Internal. -->
<Target Name="ChocolateyReadReleaseNotes">
<ReadLinesFromFile File="$(ReleaseNotes)" Condition="'$(ReleaseNotes)' != ''">
<Output TaskParameter="Lines" ItemName="ReleaseNotesContents" />
</ReadLinesFromFile>
<ItemGroup Condition="'$(ReleaseNotes)' == ''">
<ReleaseNotesContents Include="See https://github.com/git-tfs/git-tfs/releases/tag/v$(Version)" />
</ItemGroup>
</Target>
<!-- Internal: Generate a nuspec file for the chocolatey package. -->
<Target Name="ChocolateyNuspec" DependsOnTargets="VersionRequired; MSBuildCommunityTasks; ChocolateyTempDir; ChocolateyReadReleaseNotes">
<ItemGroup>
<ChocolateyTokens Include="PackageVersion">
<ReplacementValue>$(Version)</ReplacementValue>
</ChocolateyTokens>
<ChocolateyTokens Include="DownloadUrl">
<ReplacementValue>$(DownloadUrl)</ReplacementValue>
</ChocolateyTokens>
<ChocolateyTokens Include="ReleaseNotesContents">
<ReplacementValue>@(ReleaseNotesContents, '%0a')</ReplacementValue>
</ChocolateyTokens>
</ItemGroup>
<TemplateFile
Template="$(ChocolateyTemplateDir)\gittfs.nuspec"
OutputFilename="%(ChocolateyNuspec.FullPath)"
Tokens="@(ChocolateyTokens)" />
</Target>
<!-- Internal: Generate an install script for the chocolatey package. -->
<Target Name="ChocolateyInstallScript" DependsOnTargets="VersionRequired; MSBuildCommunityTasks; ChocolateyTempDir">
<TemplateFile
Template="$(ChocolateyTemplateDir)\chocolateyInstall.ps1"
OutputFilename="%(ChocolateyInstallScript.FullPath)"
Tokens="@(ChocolateyTokens)" />
</Target>
<!-- Internal. -->
<Target Name="BuildChocolateyPackage" DependsOnTargets="ChocolateyNuspec; ChocolateyInstallScript">
<Exec Command="cpack" WorkingDirectory="$(ChocolateyBuildDir)" />
</Target>
<!-- Internal. -->
<Target Name="PushChocolateyPackage" DependsOnTargets="BuildChocolateyPackage">
<Exec Command="cpush $(ChocolateyNupkg)" />
</Target>
</Project>