forked from git-tfs/git-tfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Release.proj
233 lines (195 loc) · 11 KB
/
Release.proj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<?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>
<!-- The default location of the release notes -->
<ReleaseNotes Condition="'$(ReleaseNotes)' == ''">$(SolutionDir)/doc/release-notes/v$(VERSION).md</ReleaseNotes>
<!-- 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>
<DryRun Condition="'$(DryRun)' == ''">True</DryRun>
</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="'$(DryRun)' == 'False' And '$(GitHubAuthToken)' == ''" />
</Target>
<!-- The contents of the zip. -->
<Target Name="DefineReleaseFiles">
<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)\LibGit2Sharp.dll" />
<ReleaseFiles Include="$(BuildDir)\NDesk.Options.dll" />
<ReleaseFiles Include="$(BuildDir)\StructureMap.dll" />
<ReleaseFiles Include="$(BuildDir)\NativeBinaries\**\*.dll" />
<ReleaseFiles Include="$(BuildDir)\GitTfs.Vs20*\GitTfs.Vs20*.dll" />
<ReleaseFiles Include="$(BuildDir)\GitTfs.Vs2015\*.dll" Exclude="$(BuildDir)\GitTfs.Vs2015\GitTfs.Vs20*.dll" />
</ItemGroup>
</Target>
<!-- The zip. -->
<ItemGroup>
<ArchiveFile Include="$(Archive)">
<ContentType>application/zip</ContentType>
</ArchiveFile>
</ItemGroup>
<!-- Use nuget get dependencies. (Dependencies are not checked in to git.) -->
<PropertyGroup>
<MSBuildCommunityTasksPath>$(SolutionDir)/packages/MSBuildTasks/tools</MSBuildCommunityTasksPath>
<MSBuildCommunityTasksLib>$(MSBuildCommunityTasksPath)/MSBuild.Community.Tasks.dll</MSBuildCommunityTasksLib>
<MSBuildGitTfsTasksLib>$(SolutionDir)/packages/MSBuildGitTfsTasks/GitTfsTasks.dll</MSBuildGitTfsTasksLib>
</PropertyGroup>
<Target Name="RestorePackages">
<Exec Command="$(SolutionDir)\.paket\paket.bootstrapper.exe" />
<Exec Command="$(SolutionDir)\.paket\paket.exe restore" />
</Target>
<!-- 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; 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; UpdateVersionInAppVeyorConfig">
<!-- This is OK to fail. If a previous release attempt failed, the commit will now be empty. -->
<Exec Condition="'$(DryRun)' == 'False'" Command="git commit -m v$(Version) $(VersionFilePath) appveyor.yml" IgnoreExitCode="true" />
<Message Condition="'$(DryRun)' != 'False'" Text="(would git commit -m v$(Version) $(VersionFilePath) appveyor.yml)" />
</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="UpdateVersionInAppVeyorConfig" DependsOnTargets="VersionRequired; MSBuildCommunityTasks">
<FileUpdate Files="appveyor.yml" Regex="version: .*\.{build}" ReplacementText="version: $(Version).{build}" />
</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 -f v$(Version)" />
</Target>
<!-- Internal: Called by Release to push the release tag to github.com -->
<Target Name="PushSource" DependsOnTargets="VersionRequired">
<!-- Do these separately so that the push to master blocks the push of the tag. -->
<Exec Condition="'$(DryRun)' == 'False'" Command="git push $(OriginUrl) HEAD:refs/heads/master" />
<Exec Condition="'$(DryRun)' == 'False'" Command="git push $(OriginUrl) v$(Version)" />
<Message Condition="'$(DryRun)' != 'False'" Text="(would push to github.com)" />
</Target>
<!-- Internal: Called by Release to create the zip. -->
<Target Name="Package" DependsOnTargets="VersionRequired; MSBuildCommunityTasks; DefineReleaseFiles">
<Zip Files="@(ReleaseFiles)" ZipFileName="$(Archive)" WorkingDirectory="$(BuildDir)" />
</Target>
<!-- Internal: Create a release on github.com -->
<Target Name="ReleaseOnGitHub" DependsOnTargets="VersionRequired; AuthTokenRequired; MSBuildCommunityTasks">
<CreateRelease Condition="'$(DryRun)' == 'False'" Repository="$(GitHubOwner)/$(GitHubRepository)" TagName="v$(Version)" Files="@(ArchiveFile)" OauthToken="$(GitHubAuthToken)" ReleaseNotesFile="$(ReleaseNotes)" ContinueOnError="ErrorAndContinue" />
<Message Condition="'$(DryRun)' != 'False'" Text="(would create release on github.com)" />
</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>https://github.com/git-tfs/git-tfs/tree/master/doc/release-notes</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 Condition="'$(DryRun)' == 'False'" Command="cpush $(ChocolateyNupkg)" />
<Message Condition="'$(DryRun)' != 'False'" Text="(would push chocolatey package)" />
</Target>
</Project>