@@ -63,26 +63,75 @@ jobs:
6363 -Configuration Release `
6464 -APIVersion $apiVersion
6565
66+ - name : Get Assembly File Version
67+ id : assembly-version
68+ shell : pwsh
69+ run : |
70+ $dllPath = "./Application/EdFi.Ods.AdminApi/publish/EdFi.Ods.AdminApi.dll"
71+
72+ if (-not (Test-Path $dllPath))
73+ {
74+ throw "Could not find EdFi.Ods.AdminApi.dll at $dllPath"
75+ }
76+
77+ $fileVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($dllPath).FileVersion
78+ "file-version=$fileVersion" >> $env:GITHUB_OUTPUT
79+
6680 - name : Setup Nuget.exe
6781 uses : nuget/setup-nuget@323ab0502cd38fdc493335025a96c8fdb0edc71f # v2.0.1
6882
6983 - name : Replace Installer Version Token
7084 shell : pwsh
7185 run : |
72- $version = "${{ github.ref_name }}"
73- $versionWithoutPrefix = $version -replace '^v', ''
86+ $version = "${{ steps.assembly-version.outputs.file-version }}"
87+
88+ Write-Host "Replacing version token with: $version"
7489
7590 $installerPath = "Installer.AdminApi/Install-AdminApi.psm1"
76- $content = Get-Content $installerPath -Raw
77- $content = $content -replace '"__ADMINAPI_VERSION__"', "`"$versionWithoutPrefix`""
78- $content | Set-Content $installerPath -NoNewline
91+
92+ if (Test-Path $installerPath)
93+ {
94+ $content = Get-Content $installerPath -Raw
95+ $content = $content -replace '"__ADMINAPI_VERSION__"', "`"$version`""
96+ $content | Set-Content $installerPath -NoNewline
97+
98+ Write-Host "Successfully updated version in $installerPath"
99+ }
100+ else
101+ {
102+ throw "Could not find installer module at $installerPath"
103+ }
79104
80105 $installScriptPath = "Installer.AdminApi/install.ps1"
81- $content = Get-Content $installScriptPath -Raw
82- $content = $content -replace '"__ADMINAPI_VERSION__"', "`"$versionWithoutPrefix`""
83- $content | Set-Content $installScriptPath -NoNewline
84106
85- Write-Output "Updated version to $version (or $versionWithoutPrefix) in installer files"
107+ if (Test-Path $installScriptPath)
108+ {
109+ $content = Get-Content $installScriptPath -Raw
110+ $content = $content -replace '"__ADMINAPI_VERSION__"', "`"$version`""
111+ $content | Set-Content $installScriptPath -NoNewline
112+
113+ Write-Host "Successfully updated version in $installScriptPath"
114+ }
115+ else
116+ {
117+ throw "Could not find installer script at $installScriptPath"
118+ }
119+
120+ # Verify the replacement
121+ $verifyContent = Get-Content $installerPath -Raw
122+
123+ if ($verifyContent -match '__ADMINAPI_VERSION__')
124+ {
125+ throw "Token replacement failed - __ADMINAPI_VERSION__ still found in $installerPath"
126+ }
127+
128+ $verifyInstallScriptContent = Get-Content $installScriptPath -Raw
129+
130+ if ($verifyInstallScriptContent -match '__ADMINAPI_VERSION__')
131+ {
132+ throw "Token replacement failed - __ADMINAPI_VERSION__ still found in $installScriptPath"
133+ }
134+ Write-Host "Verification passed - token successfully replaced with version: $version"
86135
87136 - name : Create NuGet Packages
88137 if : success()
0 commit comments