microsoft/hve-core
Publicmirrored fromhttps://github.com/microsoft/hve-coreAvailable
scripts/lib/README.md
81lines · modecode
| 1 | --- |
| 2 | title: Shared Library |
| 3 | description: Shared utility scripts and modules used across hve-core automation |
| 4 | author: HVE Core Team |
| 5 | ms.date: 2026-03-17 |
| 6 | ms.topic: reference |
| 7 | keywords: |
| 8 | - powershell |
| 9 | - utilities |
| 10 | - ci |
| 11 | - downloads |
| 12 | estimated_reading_time: 3 |
| 13 | --- |
| 14 | |
| 15 | This directory contains shared utility scripts and modules used across the |
| 16 | `hve-core` automation scripts. |
| 17 | |
| 18 | ## Scripts |
| 19 | |
| 20 | ### `Get-VerifiedDownload.ps1` |
| 21 | |
| 22 | Downloads and verifies artifacts using SHA256 checksums. |
| 23 | |
| 24 | Purpose: Provide tamper-evident file downloads for CI tooling. |
| 25 | |
| 26 | #### Features |
| 27 | |
| 28 | * Downloads files from a URL and verifies against an expected SHA256 hash |
| 29 | * Supports optional extraction of archives |
| 30 | * Exposes `Get-FileHashValue` and `Test-HashMatch` functions for reuse |
| 31 | |
| 32 | #### Parameters |
| 33 | |
| 34 | * `-Url` - Download URL |
| 35 | * `-ExpectedSHA256` - Expected SHA256 hash for verification |
| 36 | * `-OutputPath` - Local file path for the download |
| 37 | * `-Extract` (switch) - Extract the downloaded archive after verification |
| 38 | * `-ExtractPath` - Destination path for extraction |
| 39 | |
| 40 | #### Usage |
| 41 | |
| 42 | ```powershell |
| 43 | # Download and verify a tool |
| 44 | ./scripts/lib/Get-VerifiedDownload.ps1 -Url "https://example.com/tool.zip" ` |
| 45 | -ExpectedSHA256 "abc123..." -OutputPath "./tools/tool.zip" |
| 46 | |
| 47 | # Download, verify, and extract |
| 48 | ./scripts/lib/Get-VerifiedDownload.ps1 -Url "https://example.com/tool.zip" ` |
| 49 | -ExpectedSHA256 "abc123..." -OutputPath "./tools/tool.zip" ` |
| 50 | -Extract -ExtractPath "./tools/" |
| 51 | ``` |
| 52 | |
| 53 | ## Modules |
| 54 | |
| 55 | ### `Modules/CIHelpers.psm1` |
| 56 | |
| 57 | Shared CI platform detection and output utilities imported by scripts across |
| 58 | the repository. |
| 59 | |
| 60 | | Function | Purpose | |
| 61 | |----------------------------------|--------------------------------------------------------| |
| 62 | | `ConvertTo-GitHubActionsEscaped` | Escapes strings for GitHub Actions workflow commands | |
| 63 | | `ConvertTo-AzureDevOpsEscaped` | Escapes strings for Azure DevOps logging commands | |
| 64 | | `Get-CIPlatform` | Returns the current CI platform (GitHub, AzureDevOps) | |
| 65 | | `Test-CIEnvironment` | Detects whether the script runs in a CI environment | |
| 66 | | `Set-CIOutput` | Sets output variables for the current CI platform | |
| 67 | | `Set-CIEnv` | Sets environment variables for the current CI platform | |
| 68 | | `Write-CIStepSummary` | Appends content to the GitHub Actions step summary | |
| 69 | | `Write-CIAnnotation` | Writes a single CI warning or error annotation | |
| 70 | | `Write-CIAnnotations` | Writes multiple CI annotations from a violations array | |
| 71 | | `Set-CITaskResult` | Sets the CI task result (succeeded, failed) | |
| 72 | | `Publish-CIArtifact` | Publishes a file as a CI artifact | |
| 73 | |
| 74 | ## Related Documentation |
| 75 | |
| 76 | * [Scripts README](../README.md) for overall script organization |
| 77 | |
| 78 | <!-- markdownlint-disable MD036 --> |
| 79 | *🤖 Crafted with precision by ✨Copilot following brilliant human instruction, |
| 80 | then carefully refined by our team of discerning human reviewers.* |
| 81 | <!-- markdownlint-enable MD036 --> |
| 82 | |