This repository has been archived by the owner on Jul 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Splitting the GetSemanticVersion.msbuild script into CalculateSemanti…
…cVersion.msbuild and GetSemanticVersion.msbuild. The first script calls GitHubVersion to determine the semantic version and writes that to a file. Then the second script can be used to parse that file to get the version numbers where they are needed. This ensures that we only get the version once during the build process which prevents while tagging. references #30
- Loading branch information
1 parent
60f7f30
commit ec60053
Showing
6 changed files
with
174 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" | ||
DefaultTargets="Run" | ||
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<!-- Build flags --> | ||
<ShouldClean>true</ShouldClean> | ||
<ShouldCleanPackages>false</ShouldCleanPackages> | ||
|
||
<!-- Directories --> | ||
<DirWorkspace>$(MSBuildProjectDirectory)</DirWorkspace> | ||
<DirPackages>$(DirWorkspace)\packages</DirPackages> | ||
<DirTools>$(DirWorkspace)\tools</DirTools> | ||
<DirBuild>$(DirWorkspace)\build</DirBuild> | ||
<DirBuildBin>$(DirBuild)\bin\$(PlatformTranslated)\$(Configuration)</DirBuildBin> | ||
<DirBuildDeploy>$(DirBuild)\deploy</DirBuildDeploy> | ||
<DirBuildLogs>$(DirBuild)\logs</DirBuildLogs> | ||
<DirBuildTemp>$(DirBuild)\temp</DirBuildTemp> | ||
<DirSrc>$(DirWorkspace)\src</DirSrc> | ||
|
||
<!-- Issue tracker --> | ||
<GitHubUserName></GitHubUserName> | ||
<GitHubToken></GitHubToken> | ||
|
||
<!-- Version number --> | ||
<VersionSemantic>0</VersionSemantic> | ||
|
||
<!-- Tools --> | ||
<MsBuildExtensionsPath>$(DirTools)\msbuild.extensions</MsBuildExtensionsPath> | ||
</PropertyGroup> | ||
|
||
<Import Project="$(MsBuildExtensionsPath)\FindToolFromPackages.msbuild" | ||
Condition="Exists('$(MsBuildExtensionsPath)\FindToolFromPackages.msbuild')" /> | ||
<Import Project="$(MsBuildExtensionsPath)\CalculateSemanticVersion.msbuild" | ||
Condition="Exists('$(MsBuildExtensionsPath)\CalculateSemanticVersion.msbuild')" /> | ||
<Import Project="$(MsBuildExtensionsPath)\GetSemanticVersion.msbuild" | ||
Condition="Exists('$(MsBuildExtensionsPath)\GetSemanticVersion.msbuild')" /> | ||
<Import Project="$(MsBuildExtensionsPath)\TemplateFile.msbuild" | ||
Condition="Exists('$(MsBuildExtensionsPath)\TemplateFile.msbuild')"/> | ||
|
||
<Target Name="Run" DependsOnTargets="_DisplayInfo;_GatherReleaseNotes"> | ||
<!-- Do nothing here --> | ||
</Target> | ||
|
||
<!-- Display info --> | ||
<Target Name="_DisplayInfo"> | ||
<Message Text="Gathering release notes ..." /> | ||
<Message Text="WARNING: Github username not specified" Condition=" '$(GitHubUserName)' == '' " /> | ||
<Message Text="WARNING: Github token not specified" Condition=" '$(GitHubToken)' == '' " /> | ||
</Target> | ||
|
||
<PropertyGroup> | ||
<FileGitVersionExe>GitHubFlowVersion.exe</FileGitVersionExe> | ||
<FileSemanticVersion>$(DirBuildTemp)\semantic_version.json</FileSemanticVersion> | ||
</PropertyGroup> | ||
<Target Name="_GetSemanticVersion"> | ||
<FindToolFromPackages PackagesDir="$(DirPackages)" FileToLocate="$(FileGitVersionExe)"> | ||
<Output TaskParameter="Path" PropertyName="PathGitVersionExe" /> | ||
</FindToolFromPackages> | ||
|
||
<CalculateSemanticVersion ExePath="$(PathGitVersionExe)" VersionFile="$(FileSemanticVersion)" Condition="!Exists('$(FileSemanticVersion)')" /> | ||
|
||
<GetSemanticVersion VersionFile="$(FileSemanticVersion)"> | ||
<Output TaskParameter="VersionSemantic" PropertyName="VersionSemantic" /> | ||
</GetSemanticVersion> | ||
</Target> | ||
|
||
<PropertyGroup> | ||
<FileGitReleaseNotes>GitReleaseNotes.exe</FileGitReleaseNotes> | ||
<FileReleaseNotesShort>$(DirBuildTemp)\releasenotes_short.md</FileReleaseNotesShort> | ||
<FileReleaseNotesFull>$(DirBuildTemp)\releasenotes_full.md</FileReleaseNotesFull> | ||
</PropertyGroup> | ||
<Target Name="_GatherReleaseNotes" DependsOnTargets="_DisplayInfo;_GetSemanticVersion" Condition=" '$(GitHubUserName)' != '' AND '$(GitHubToken)' != '' "> | ||
<FindToolFromPackages PackagesDir="$(DirPackages)" FileToLocate="$(FileGitReleaseNotes)"> | ||
<Output TaskParameter="Path" PropertyName="PathGitReleaseNotesExe" /> | ||
</FindToolFromPackages> | ||
|
||
<Exec Command=""$(PathGitReleaseNotesExe)" /I GitHub /R $(GitHubUserName)/nuclei /U $(GitHubUserName) /T $(GitHubToken) /V $(VersionSemantic) /O "$(FileReleaseNotesShort)"" | ||
WorkingDirectory="$(DirWorkspace)" /> | ||
|
||
<Exec Command=""$(PathGitReleaseNotesExe)" /I GitHub /R $(GitHubUserName)/nuclei /U $(GitHubUserName) /T $(GitHubToken) /F all /V $(VersionSemantic) /O "$(FileReleaseNotesFull)"" | ||
WorkingDirectory="$(DirWorkspace)" /> | ||
</Target> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<!-- | ||
Copyright 2013 Nuclei. Licensed under the Apache License, Version 2.0. | ||
--> | ||
|
||
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003' | ||
ToolsVersion="4.0"> | ||
<UsingTask TaskName="CalculateSemanticVersion" | ||
TaskFactory="CodeTaskFactory" | ||
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> | ||
<ParameterGroup> | ||
<ExePath ParameterType="System.String" Required="true" /> | ||
<VersionFile ParameterType="System.String" Required="true" /> | ||
</ParameterGroup> | ||
<Task> | ||
<Code Type="Method" Language="cs"> | ||
<![CDATA[ | ||
public override bool Execute() | ||
{ | ||
var info = new System.Diagnostics.ProcessStartInfo | ||
{ | ||
FileName = ExePath, | ||
Arguments = string.Format("/ToFile \"{0}\"", VersionFile), | ||
UseShellExecute = false, | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true, | ||
}; | ||
|
||
Log.LogMessage(MessageImportance.Normal, ExePath); | ||
Log.LogMessage(MessageImportance.Normal, info.Arguments); | ||
|
||
var process = new System.Diagnostics.Process(); | ||
process.StartInfo = info; | ||
process.OutputDataReceived += | ||
(s, e) => | ||
{ | ||
if (!string.IsNullOrWhiteSpace(e.Data)) | ||
{ | ||
Log.LogMessage(MessageImportance.Normal, e.Data); | ||
} | ||
}; | ||
process.ErrorDataReceived += | ||
(s, e) => | ||
{ | ||
if (!string.IsNullOrWhiteSpace(e.Data)) | ||
{ | ||
Log.LogError(e.Data); | ||
} | ||
}; | ||
process.Start(); | ||
|
||
process.BeginOutputReadLine(); | ||
process.BeginErrorReadLine(); | ||
process.WaitForExit(); | ||
|
||
if (process.ExitCode != 0) | ||
{ | ||
Log.LogError("Failed to get semantic version information"); | ||
return false; | ||
} | ||
|
||
// Log.HasLoggedErrors is true if the task logged any errors -- even if they were logged | ||
// from a task's constructor or property setter. As long as this task is written to always log an error | ||
// when it fails, we can reliably return HasLoggedErrors. | ||
return !Log.HasLoggedErrors; | ||
} | ||
]]> | ||
</Code> | ||
</Task> | ||
</UsingTask> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters