Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,15 @@ jobs:
unzip -Z1 dist/lexmount-webfetch.zip | grep -qx 'SKILL.md'
! unzip -Z1 dist/lexmount-webfetch.zip | grep -q '^lexmount-webfetch/'
! unzip -Z1 dist/lexmount-webfetch.zip | grep -q '^bin/'

windows-bootstrap:
runs-on: windows-latest
steps:
- uses: actions/checkout@v5
- name: Bootstrap from COS with Windows PowerShell 5.1
shell: powershell
run: |
if ($PSVersionTable.PSVersion.Major -ne 5) { throw "Expected Windows PowerShell 5.1" }
$env:LEXMOUNT_WEBFETCH_CLI_INSTALL_DIR = Join-Path $env:RUNNER_TEMP "webfetch-cli-bootstrap"
& .\skills\lexmount-webfetch\scripts\bootstrap.ps1
& (Join-Path $env:LEXMOUNT_WEBFETCH_CLI_INSTALL_DIR "webfetch-cli.exe") version
27 changes: 25 additions & 2 deletions skills/lexmount-webfetch/scripts/bootstrap.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
$ErrorActionPreference = "Stop"

function Invoke-Tls12Download {
param(
[Parameter(Mandatory = $true)][string]$Uri,
[Parameter(Mandatory = $true)][string]$OutFile
)
try {
Invoke-WebRequest -UseBasicParsing -Uri $Uri -OutFile $OutFile
} catch {
throw "Failed to download $Uri with TLS 1.2 enabled: $($_.Exception.Message)"
}
}

$version = if ($env:LEXMOUNT_WEBFETCH_CLI_VERSION) { $env:LEXMOUNT_WEBFETCH_CLI_VERSION } else { "0.1.1" }
$downloadBaseUrl = if ($env:LEXMOUNT_WEBFETCH_CLI_DOWNLOAD_BASE_URL) { $env:LEXMOUNT_WEBFETCH_CLI_DOWNLOAD_BASE_URL.TrimEnd('/') } else { "https://cli-bin-1377899528.cos.ap-nanjing.myqcloud.com/releases/webfetch-cli" }
$architecture = if ($env:PROCESSOR_ARCHITEW6432) { $env:PROCESSOR_ARCHITEW6432 } else { $env:PROCESSOR_ARCHITECTURE }
Expand All @@ -8,8 +21,18 @@ $repo = "$downloadBaseUrl/v$version"
$tmp = Join-Path ([IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString())
New-Item -ItemType Directory -Path $tmp | Out-Null
try {
Invoke-WebRequest -UseBasicParsing "$repo/$asset" -OutFile (Join-Path $tmp $asset)
Invoke-WebRequest -UseBasicParsing "$repo/SHA256SUMS" -OutFile (Join-Path $tmp "SHA256SUMS")
$previousSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol
try {
[Net.ServicePointManager]::SecurityProtocol = $previousSecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
} catch {
throw "Failed to enable TLS 1.2 for COS downloads: $($_.Exception.Message)"
}
try {
Invoke-Tls12Download "$repo/$asset" (Join-Path $tmp $asset)
Invoke-Tls12Download "$repo/SHA256SUMS" (Join-Path $tmp "SHA256SUMS")
} finally {
[Net.ServicePointManager]::SecurityProtocol = $previousSecurityProtocol
}
# GNU sha256sum prefixes binary filenames with `*`; shasum uses plain whitespace.
$line = Get-Content (Join-Path $tmp "SHA256SUMS") | Where-Object { $_ -match "\s+\*?$([regex]::Escape($asset))$" } | Select-Object -First 1
if (-not $line) { throw "No checksum published for $asset" }
Expand Down