Skip to content

Commit 963ec41

Browse files
RichardChukwureyangCodeBlanch
authored
[repo] Add RELEASENOTES and READMEs to NuGet packages (open-telemetry#5885)
Co-authored-by: Reiley Yang <[email protected]> Co-authored-by: Mikel Blanchard <[email protected]>
1 parent dba7d25 commit 963ec41

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

build/Common.prod.props

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
2626
<PackagePrimaryLicenseFile>$(RepoRoot)\LICENSE.TXT</PackagePrimaryLicenseFile>
2727
<PackageThirdPartyNoticesFile>$(RepoRoot)\THIRD-PARTY-NOTICES.TXT</PackageThirdPartyNoticesFile>
28+
<PackageReadmeFile>README.md</PackageReadmeFile>
29+
<PackageChangelogFile>CHANGELOG.md</PackageChangelogFile>
30+
<PackageReleaseNotesFile>$(RepoRoot)\RELEASENOTES.md</PackageReleaseNotesFile>
2831
</PropertyGroup>
2932

3033
<PropertyGroup Label="SourceLinkProperties">
@@ -57,7 +60,7 @@
5760
<None Include=".publicApi\**\PublicAPI.*.txt" />
5861
</ItemGroup>
5962

60-
<Target Name="AssemblyVersionTarget" AfterTargets="MinVer" Condition="'$(MinVerVersion)'!='' AND '$(BuildNumber)' != ''">
63+
<Target Name="AssemblyVersionTarget" AfterTargets="MinVer" Condition="'$(MinVerVersion)' != '' AND '$(BuildNumber)' != ''">
6164
<!-- Note: $(BuildNumber) is typically only set for builds initiated by the
6265
publish workflow. The goal here is to set the assembly FileVersion and
6366
resolve ExposeExperimentalFeatures based on the version MinVer resolved from
@@ -87,6 +90,66 @@
8790
<Error Text="Cannot perform package validation without a baseline package version." />
8891
</Target>
8992

93+
<Target Name="IncludeReadmeAndReleaseNotesInPackages" BeforeTargets="_GetTargetFrameworksOutput">
94+
<!-- Note: This target runs during pack to convert relative links in
95+
markdowns into github permalinks which will work when rendered on Nuget. -->
96+
97+
<Exec
98+
Command="git rev-parse HEAD"
99+
ConsoleToMsBuild="True"
100+
IgnoreExitCode="True"
101+
StandardOutputImportance="low">
102+
<Output PropertyName="GitCommitConsoleOutput" TaskParameter="ConsoleOutput"/>
103+
<Output PropertyName="GitCommitExitCode" TaskParameter="ExitCode"/>
104+
</Exec>
105+
106+
<Exec
107+
Command="git remote get-url origin"
108+
ConsoleToMsBuild="True"
109+
IgnoreExitCode="True"
110+
StandardOutputImportance="low">
111+
<Output PropertyName="GitOriginConsoleOutput" TaskParameter="ConsoleOutput"/>
112+
<Output PropertyName="GitOriginExitCode" TaskParameter="ExitCode"/>
113+
</Exec>
114+
115+
<PropertyGroup>
116+
<MarkdownCommentRegex>\[([^]]+?)\]\(\.(.+?)\)</MarkdownCommentRegex>
117+
<GitHubRepoUrl>$(GitOriginConsoleOutput.Replace('.git',''))</GitHubRepoUrl>
118+
<GitHubPermalinkUrl Condition="'$(PackTag)' != ''">$(GitHubRepoUrl)/blob/$(PackTag)</GitHubPermalinkUrl>
119+
<GitHubPermalinkUrl Condition="'$(PackTag)' == ''">$(GitHubRepoUrl)/blob/$(GitCommitConsoleOutput)</GitHubPermalinkUrl>
120+
</PropertyGroup>
121+
122+
<Message Importance="high" Text="**GitInformationDebug** GitCommitConsoleOutput: $(GitCommitConsoleOutput), GitCommitExitCode: $(GitCommitExitCode), GitOriginConsoleOutput: $(GitOriginConsoleOutput), GitOriginExitCode: $(GitOriginExitCode), GitHubPermalinkUrl: $(GitHubPermalinkUrl)" />
123+
124+
<ItemGroup>
125+
<PackageMarkdownFiles Include="README.md" />
126+
</ItemGroup>
127+
128+
<ItemGroup>
129+
<PackageMarkdownFiles Update="@(PackageMarkdownFiles)" Path="$([MSBuild]::ValueOrDefault('%(FullPath)','').Replace('$(RepoRoot)', '').Replace('%(FileName)%(Extension)', ''))" />
130+
</ItemGroup>
131+
132+
<WriteLinesToFile
133+
File="$(IntermediateOutputPath)%(PackageMarkdownFiles.Filename)%(PackageMarkdownFiles.Extension)"
134+
Lines="$([System.Text.RegularExpressions.Regex]::Replace($([System.IO.File]::ReadAllText(%(PackageMarkdownFiles.FullPath))), '$(MarkdownCommentRegex)', '[$1]($(GitHubPermalinkUrl)%(PackageMarkdownFiles.Path).$2)').Replace('\', '/'))"
135+
Overwrite="true"
136+
Encoding="UTF-8"/>
137+
138+
<PropertyGroup>
139+
<_PackageReleaseNotesFilePath>$([System.IO.Path]::GetFullPath('$(PackageReleaseNotesFile)').Replace('$(RepoRoot)', '').Replace('\', '/'))</_PackageReleaseNotesFilePath>
140+
<_PackageChangelogFilePath>$([System.IO.Path]::GetFullPath('$(PackageChangelogFile)').Replace('$(RepoRoot)', '').Replace('\', '/'))</_PackageChangelogFilePath>
141+
<PackageReleaseNotes>
142+
For highlights and announcements see: $(GitHubPermalinkUrl)$(_PackageReleaseNotesFilePath).
143+
144+
For detailed changes see: $(GitHubPermalinkUrl)$(_PackageChangelogFilePath).
145+
</PackageReleaseNotes>
146+
</PropertyGroup>
147+
148+
<ItemGroup>
149+
<Content Include="$(IntermediateOutputPath)*.md" PackagePath="/" />
150+
</ItemGroup>
151+
</Target>
152+
90153
<Target Name="ResolveExposeExperimentalFeatures" BeforeTargets="CoreCompile" DependsOnTargets="AssemblyVersionTarget">
91154
<!-- Note: This runs for all builds. The goal here is to set the
92155
EXPOSE_EXPERIMENTAL_FEATURES compiler constant if

0 commit comments

Comments
 (0)