Skip to content

Commit

Permalink
[Build] Fix GitInfo usage to calculate version (#501)
Browse files Browse the repository at this point in the history
* Update regex tag

* Update reg for tag

* Don't compare gitbranch

* Update GitInfo

* Add GitIgnoreBranchVersion

* correct value

* Test set GitIgnoreTagVersion

* Fix GitIgnoreTagVersion
  • Loading branch information
rmarinho authored Mar 12, 2021
1 parent 8e8eea4 commit 5762536
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions eng/Git.Build.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<ItemGroup>
<PackageReference Include="GitInfo" Version="2.0.26" PrivateAssets="All" />
<PackageReference Include="MSBuilder.GenerateAssemblyInfo" Version="0.2.1" PrivateAssets="All" />
<PackageReference Include="GitInfo" Version="2.1.2" PrivateAssets="All" />
<PackageReference Include="MSBuilder.GenerateAssemblyInfo" Version="0.2.2" PrivateAssets="All" />
</ItemGroup>
</Project>
18 changes: 17 additions & 1 deletion eng/Version.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<NightlyTag>nightly</NightlyTag>
<RegexPre>pre\d</RegexPre>
<RegexTag>[a-z]+\.[0-9]</RegexTag>
</PropertyGroup>
<PropertyGroup>
<GitBranch Condition="'$(SYSTEM_PULLREQUEST_TARGETBRANCH)' != ''">$(SYSTEM_PULLREQUEST_TARGETBRANCH)</GitBranch>
Expand Down Expand Up @@ -33,10 +33,26 @@
GitVersion;
$(SetVersionsDependsOn);
</SetVersionsDependsOn>
<SetGitInfoPropsBefore>
GitInfo;
GitVersion;
</SetGitInfoPropsBefore>
</PropertyGroup>

<Target Name="SetGitInfoProps" BeforeTargets="$(SetGitInfoPropsBefore)">
<PropertyGroup>
<GitDefaultBranch>main</GitDefaultBranch>
<GitIgnoreBranchVersion>true</GitIgnoreBranchVersion>
<GitIgnoreTagVersion>true</GitIgnoreTagVersion>
</PropertyGroup>
</Target>
<Target Name="SetVersions" BeforeTargets="$(SetVersionsBefore)" DependsOnTargets="$(SetVersionsDependsOn)" Returns="$(Version)">
<PropertyGroup>
<SemVerLabel>$([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(RegexTag)))</SemVerLabel>
<GitDefaultBranch>main</GitDefaultBranch>
<GitIgnoreBranchVersion>true</GitIgnoreBranchVersion>
<GitIgnoreTagVersion>true</GitIgnoreTagVersion>
<GitSemVerLabel Condition=" '$(GitTag)' != '' and $([System.Text.RegularExpressions.Regex]::IsMatch('$(GitTag)', $(RegexTag))) ">$(SemVerLabel)</GitSemVerLabel>
<GitSemVerLabel Condition="$(CI) and '$(BUILD_REASON)' == 'Schedule'">$(NightlyTag)</GitSemVerLabel>
<GitSemVerDashLabel Condition="'$(GitSemVerLabel)' != ''" >-$(GitSemVerLabel)</GitSemVerDashLabel>
</PropertyGroup>
Expand Down

0 comments on commit 5762536

Please sign in to comment.