This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git

commit 51d974014f277cbe8360693b3b0123a25a317833
Author: Shad Storhaug <[email protected]>
AuthorDate: Thu Dec 23 16:35:38 2021 +0700

    build/build.ps1: Added function to update version info in docs/index.md 
using regex replace prior to packing
---
 build/build.ps1 | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/build/build.ps1 b/build/build.ps1
index f4609c7..5aef4b0 100644
--- a/build/build.ps1
+++ b/build/build.ps1
@@ -32,6 +32,9 @@ properties {
     [string]$globalJsonFile = "$base_directory/global.json"
     [string]$versionPropsFile = "$base_directory/Version.props"
     [string]$build_bat = "$base_directory/build.bat"
+    [string]$luceneCLIReadmeFile = 
"$base_directory/src/dotnet/tools/lucene-cli/docs/index.md"
+    [string]$rootWebsiteUrl = "https://lucenenet.apache.org";
+    [string]$rootDocsWebsiteUrl = "$rootWebsiteUrl/docs"
 
     [string]$buildCounter     = $(if ($buildCounter) { $buildCounter } else { 
$env:BuildCounter }) #NOTE: Pass in as a parameter (not a property) or 
environment variable to override
     [string]$preReleaseCounterPattern = $(if ($preReleaseCounterPattern) { 
$preReleaseCounterPattern } else { if ($env:PreReleaseCounterPattern) { 
$env:PreReleaseCounterPattern } else { "0000000000" } })  #NOTE: Pass in as a 
parameter (not a property) or environment variable to override
@@ -165,6 +168,7 @@ task Pack -depends Compile -description "This task creates 
the NuGet packages" {
     Write-Host "##vso[task.setprogress]'Packing'"
     #create the nuget package output directory
     Ensure-Directory-Exists "$nuget_package_directory"
+    Update-LuceneCLI-Readme-For-Pack $packageVersion
 
     try {
         Exec {
@@ -512,6 +516,17 @@ function Update-Constants-Version([string]$version) {
     } | Set-Content $constantsFile -Force
 }
 
+function Update-LuceneCLI-Readme-For-Pack([string]$version) {
+    Backup-File $luceneCLIReadmeFile
+    (Get-Content $luceneCLIReadmeFile) | % {
+        # Replace version in lucene-cli install command
+        $_ -replace 
"(?<=lucene-cli(?:\s?-{1,2}\w*?)*?\s+--version\s+)(\d+\.\d+\.\d+(?:\.\d+)?(?:-\w*)?)",
 $version
+    } | % {
+        # Replace markdown file references with website URLs to the correct 
documentation version
+        $_ -replace "(?<=\()(\w*/index).md(?=\))", 
"$rootDocsWebsiteUrl/$version/cli/`$1.html"
+    } | Set-Content $luceneCLIReadmeFile -Force
+}
+
 function Generate-Global-Json {
 param(
     [string]$sdkVersion,

Reply via email to