@@ -62,6 +62,22 @@ function readProjectFileProperty {
6262 $propertyValue
6363}
6464
65+ function changelogTopVersionAndDate {
66+
67+ $topSectionVersion = " "
68+ $topSectionDate = " "
69+
70+ foreach ( $line in ( Get-Content .\CHANGELOG.md ) ) {
71+ $versionMatch = ( [ regex ] " ^#+ (\d+(?:\.\d+){2,}(?:-\S+)?) \((\S+)\)" ).Match( $line )
72+ if ( $versionMatch.Success ) {
73+ $topSectionVersion , $topSectionDate = $versionMatch.Groups [ 1 ].Value , $versionMatch.Groups [ 2 ].Value
74+ break
75+ }
76+ }
77+
78+ $topSectionVersion , $topSectionDate
79+ }
80+
6581task . Build
6682
6783task Clean {
@@ -136,9 +152,16 @@ task PackInternal {
136152 $yearStart = Get-Date - Year ( ( Get-Date ).Year ) - Month 1 - Day 1 - Hour 0 - Minute 0 - Second 0 - Millisecond 0
137153 $now = Get-Date
138154 $seconds = [ int ] ( $now - $yearStart ).TotalSeconds
139- $internalVersionPrefix = " $VersionPrefix .$seconds "
140- exec { dotnet pack ./ src - c $Configuration - p:VersionPrefix= $internalVersionPrefix }
141- $internalFullVersion = combinePrefixSuffix $internalVersionPrefix $VersionSuffix
155+ if ( $VersionSuffix ) {
156+ $internalVersionPrefix = $VersionPrefix
157+ $internalVersionSuffix = " $VersionSuffix .$seconds "
158+ }
159+ else {
160+ $internalVersionPrefix = " $VersionPrefix .$seconds "
161+ $internalVersionSuffix = $VersionSuffix
162+ }
163+ exec { dotnet pack ./ src - c $Configuration - p:VersionPrefix= $internalVersionPrefix - p:VersionSuffix= $internalVersionSuffix }
164+ $internalFullVersion = combinePrefixSuffix $internalVersionPrefix $internalVersionSuffix
142165 $filename = " $basePackageName .$internalFullVersion .nupkg"
143166 Copy-Item ./ src/ bin/ $Configuration / $filename $LocalPackageDir
144167 Write-Build Green " Copied $filename to $LocalPackageDir "
@@ -158,3 +181,26 @@ task EnsureCommitted {
158181 $gitoutput = exec { git status - s - uall }
159182 if ( $gitoutput ) { throw " uncommitted changes exist in working directory" }
160183}
184+
185+ task UpdateProjectFromChangelog {
186+ $version , $date = changelogTopVersionAndDate
187+ if ( $version -match ' -' ) {
188+ $prefix , $suffix = $version -split ' -'
189+ }
190+ else {
191+ $prefix , $suffix = $version , " "
192+ }
193+
194+ writeProjectFileProperty $mainProjectFilePath " VersionPrefix" $prefix
195+ writeProjectFileProperty $mainProjectFilePath " VersionSuffix" $suffix
196+
197+ $anchor = ( $version -replace ' \.' , ' ' ) + " -$date "
198+ $url = " https://github.com/zanaptak/TypedCssClasses/blob/main/CHANGELOG.md#$anchor "
199+
200+ writeProjectFileProperty $mainProjectFilePath " PackageReleaseNotes" $url
201+
202+ Write-Build Green " ****"
203+ Write-Build Green " **** Assumed changelog URL (VERIFY): $url "
204+ Write-Build Green " ****"
205+
206+ } , ReportProjectFileVersion
0 commit comments