@@ -147,24 +147,58 @@ jobs:
147147 # Define the URL for the Pandoc binary and the target path
148148 $pandocUrl = "https://github.com/jgm/pandoc/releases/download/3.1.9/pandoc-3.1.9-windows-x86_64.zip"
149149 $pandocZipPath = "pandoc.zip"
150+ $tempDir = "pandoc_temp"
150151 $targetDir = "$env:build_location\t"
151152
152153 # Download the zip file
153- Write-Host "Downloading Pandoc from $pandocUrl "
154- curl.exe -L -o $pandocZipPath $pandocUrl
154+ Write-Host "Downloading Pandoc from $env:pandoc_source "
155+ curl.exe -L -o $pandocZipPath $env:pandoc_source
155156
156157 # Create the target directory
157158 Write-Host "Creating directory $targetDir"
158159 mkdir $targetDir
159160
160- # Unzip the contents into the new directory
161- Write-Host "Extracting archive to $targetDir"
162- Expand-Archive -Path $pandocZipPath -DestinationPath $targetDir -Force
161+ # Create a temporary directory for extraction
162+ Write-Host "Creating temporary directory for extraction"
163+ New-Item -ItemType Directory -Path $tempDir
164+
165+ # Unzip the contents to the temporary directory
166+ Write-Host "Extracting archive to temporary directory"
167+ Expand-Archive -Path $zipPath -DestinationPath $tempDir
168+
169+ # Create the final target directory
170+ Write-Host "Creating final target directory: $targetDir"
171+ New-Item -ItemType Directory -Path $targetDir
172+
173+ # Find and copy only the pandoc.exe file
174+ Write-Host "Copying pandoc.exe to $targetDir"
175+ Copy-Item -Path (Join-Path $tempDir "pandoc-3.1.9\pandoc.exe") -Destination $targetDir -Force
176+
177+ # Optional: Clean up temporary files
178+ Write-Host "Cleaning up temporary files..."
179+ Remove-Item -Path $tempDir -Recurse -Force
180+ Remove-Item -Path $zipPath -Force
163181
164182 # Optional: Verify the contents
165- Write-Host "Listing contents of $targetDir: "
183+ Write-Host "Listing contents of $targetDir"
166184 Get-ChildItem -Path $targetDir
167185
186+ # Calculate SHA256 hash
187+ $filePath = $pandocZipPath
188+ $expectedHash = $env:pandoc_sha256
189+
190+ $hashObject = Get-FileHash -Path $filePath -Algorithm SHA256
191+ $actualHash = $hashObject.Hash.ToLower()
192+
193+ if ($actualHash -eq $expectedHash.ToLower()) {
194+ Write-Output "Hash matches."
195+ } else {
196+ Write-Output "Hash does NOT match."
197+ Write-Output "Actual: $actualHash"
198+ Write-Output "Expected: $expectedHash"
199+ exit 1
200+ }
201+
168202 - name : Upgrade pip and patch launchers
169203 shell : pwsh
170204 run : |
0 commit comments