-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrelease.proj
115 lines (90 loc) · 5.18 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
<?xml version="1.0"?>
<Project ToolsVersion="4.0" DefaultTargets="Help" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Where to push the release tag. -->
<PushUrl>https://github.com/git-tfs/msbuild-tasks.git</PushUrl>
<!-- Where the solution lives, relative to this file. -->
<SolutionDir>.</SolutionDir>
<!-- Normally, we build in release mode. We might want to build in debug mode, e.g. to debug. -->
<Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
<!-- Where the build output and its dependencies are built to. -->
<BuildDir>$(SolutionDir)/GitTfsTasks/bin/$(Configuration)</BuildDir>
<!-- Yo. -->
<TargetPlatform>Any CPU</TargetPlatform>
<!-- The file that includes the AssemblyVersionAttribute. -->
<VersionFilePath>$(SolutionDir)\Version.cs</VersionFilePath>
<!-- Where to build the release zip file. -->
<PackagedDir>$(SolutionDir)/Releases</PackagedDir>
<!-- The output zip file. -->
<Archive>$(PackagedDir)/GitTfsTasks-$(Version).zip</Archive>
<!-- The version tag. -->
<VersionTag>v$(Version)</VersionTag>
<!-- Where the MSBuildCommunityTasks live -->
<MSBuildCommunityTasksLib>$(SolutionDir)\packages\MSBuildTasks.1.4.0.61\tools\MSBuild.Community.Tasks.dll</MSBuildCommunityTasksLib>
</PropertyGroup>
<!-- Files that go into the zip. -->
<ItemGroup>
<ReleaseFiles Include="$(SolutionDir)\README.md" />
<ReleaseFiles Include="$(SolutionDir)\LICENSE" />
<ReleaseFiles Include="$(SolutionDir)\NOTICE" />
<ReleaseFiles Include="$(BuildDir)\*.dll" />
</ItemGroup>
<!-- The zip. -->
<ItemGroup>
<ArchiveFile Include="$(Archive)">
<ContentType>application/zip</ContentType>
</ArchiveFile>
</ItemGroup>
<!-- Internal: Load some extra tasks. -->
<Target Name="MSBuildCommunityTasks"></Target><!-- pseudo-target so we can track things that use MSBuildTasks -->
<UsingTask AssemblyFile="$(MSBuildCommunityTasksLib)" TaskName="MSBuild.Community.Tasks.TemplateFile" />
<UsingTask AssemblyFile="$(MSBuildCommunityTasksLib)" TaskName="MSBuild.Community.Tasks.Zip" />
<!-- Internal: Build and load the CreateRelease task. -->
<Target Name="GitTfsTasks" DependsOnTargets="Build"></Target><!-- Normally, you'd just load it from the dll, without needing to build it too. -->
<UsingTask TaskName="GitTfsTasks.CreateRelease" AssemblyFile="$(SolutionDir)\GitTfsTasks\bin\$(Configuration)\GitTfsTasks.dll" />
<!-- Public: Show the howto by default. -->
<Target Name="Help">
<Message Text="Usage: msbuild release.proj /t:Release /p:Version=0.0.1 /p:ReleaseNotes=releasenotes-0.0.1.md" />
</Target>
<!-- Public: Build the release. -->
<Target Name="Release" DependsOnTargets="UpdateVersion; Build; TagSource; PushSource; Package; UploadToGitHub">
</Target>
<!-- Internal: Called by Release to set the new version. -->
<Target Name="UpdateVersion" DependsOnTargets="VersionRequired">
<WriteLinesToFile File="$(VersionFilePath)" Lines="partial class GitTfsTasksProperties ; { ; public const string Version = %22$(Version)%22%3B ; }" Overwrite="true" Encoding="ASCII"/>
<Exec Command="git add $(VersionFilePath)" />
<Exec Command="git commit -m $(VersionTag)" />
</Target>
<!-- Internal: Called by Release to build a release version of git-tfs.exe -->
<Target Name="Build">
<MSBuild Projects="$(SolutionDir)\GitTfsTasks.sln" Targets="Rebuild" Properties="Configuration=$(Configuration);Platform=$(TargetPlatform);WarningLevel=0" />
</Target>
<!-- Internal: Called by Release to tag the git-tfs repository. -->
<Target Name="TagSource" DependsOnTargets="VersionRequired">
<Exec Command="git tag $(VersionTag)" />
</Target>
<!-- Internal: Called by Release to push the release tag to GitHub. -->
<Target Name="PushSource" DependsOnTargets="VersionRequired">
<Exec Command="git push $(PushUrl) master $(VersionTag)" />
</Target>
<!-- Internal: Called by Release to create the zip archive. -->
<Target Name="Package" DependsOnTargets="VersionRequired; MSBuildCommunityTasks">
<Zip Files="@(ReleaseFiles)" ZipFileName="$(Archive)" WorkingDirectory="$(BuildDir)" />
</Target>
<!-- Internal: Called by Release to create the release on github.com. -->
<Target Name="UploadToGitHub" DependsOnTargets="VersionRequired; AuthTokenRequired; GitTfsTasks">
<CreateRelease Repository="git-tfs/msbuild-tasks" OauthToken="$(GitHubAuthToken)" TagName="$(VersionTag)" Files="@(ArchiveFile)" ReleaseNotesFile="$(ReleaseNotes)">
<Output TaskParameter="UploadedAssets" ItemName="UploadedAssets" />
</CreateRelease>
<Message Text="yes! -> @(UploadedAssets)" />
</Target>
<!-- Private: Exits with error when the Version property is not defined. -->
<Target Name="VersionRequired">
<Error Text="You must specify a version number! (/p:Version=X.Y.Z)" Condition="'$(Version)' == ''" />
</Target>
<!-- Private: Exits with error when the GitHubAuthToken property is not defined. -->
<Import Project="Auth.targets" />
<Target Name="AuthTokenRequired">
<Error Text="You must set a github.com auth token in auth.targets (see auth.targets.example)" Condition="'$(GitHubAuthToken)' == ''" />
</Target>
</Project>