CI: fetch-qpdf dung GITHUB_TOKEN + fallback ban pin v12.2.0 - het fail oan vi API rate limit tu runner
Build Windows portable / build (push) Canceled after 0s

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-10 16:50:05 +07:00
co-authored by Claude Fable 5
parent 74f161a627
commit fd90a124dc
6 changed files with 72 additions and 10 deletions
+28
View File
@@ -0,0 +1,28 @@
# TUY CHON: tai bo font Noto Sans CJK (Hoa gian the/phon the + Nhat + Han)
# vao fonts/ - phuc vu tai lieu CJK khong nhung font. KHONG chay trong CI
# mac dinh (moi file ~16-20MB lam zip phinh to); nguoi dung/dev can thi chay:
# powershell -ExecutionPolicy Bypass -File scripts/fetch-fonts-cjk.ps1
# App tu nhan dien file trong fonts/ luc khoi dong - khong can cau hinh.
$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $PSScriptRoot
$fontsDir = Join-Path $root "fonts"
New-Item -ItemType Directory -Force -Path $fontsDir | Out-Null
# Ban OTC gop 4 ngon ngu (SC/TC/JP/KR) tu repo phat hanh chinh thuc.
$files = @(
@{ name = "NotoSansCJK-Regular.ttc"; url = "https://github.com/notofonts/noto-cjk/raw/main/Sans/OTC/NotoSansCJK-Regular.ttc" },
@{ name = "NotoSansCJK-Bold.ttc"; url = "https://github.com/notofonts/noto-cjk/raw/main/Sans/OTC/NotoSansCJK-Bold.ttc" }
)
foreach ($f in $files) {
$dest = Join-Path $fontsDir $f.name
if ((Test-Path $dest) -and ((Get-Item $dest).Length -gt 1000000)) {
Write-Output "Da co: $($f.name)"
continue
}
Write-Output "Tai $($f.name) (~20MB)..."
Invoke-WebRequest -Uri $f.url -OutFile $dest -UseBasicParsing
if ((Get-Item $dest).Length -lt 1000000) { throw "File $($f.name) qua nho - tai hong?" }
}
Write-Output "Xong. De dong goi kem ban portable: copy fonts/ (gom ca file CJK) canh FoFreeXit.exe."
+17 -6
View File
@@ -9,12 +9,23 @@ $qpdfDir = Join-Path $root "qpdf"
$tmp = Join-Path $env:TEMP "qpdf-win-msvc64.zip"
Write-Output "Tra cuu release moi nhat cua qpdf/qpdf..."
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/qpdf/qpdf/releases/latest" -UseBasicParsing
$asset = $release.assets | Where-Object { $_.name -like "*msvc64.zip" } | Select-Object -First 1
if (-not $asset) { throw "Khong tim thay asset msvc64.zip trong release $($release.tag_name)" }
Write-Output "Tai $($asset.name) (tu release $($release.tag_name))..."
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $tmp -UseBasicParsing
# Dung GITHUB_TOKEN khi co (CI) - goi API khong xac thuc tu runner hay dinh
# rate limit lam fail build oan. API loi thi roi ve ban pin cung.
$headers = @{}
if ($env:GITHUB_TOKEN) { $headers["Authorization"] = "Bearer $($env:GITHUB_TOKEN)" }
$dlUrl = $null
try {
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/qpdf/qpdf/releases/latest" -Headers $headers -UseBasicParsing
$asset = $release.assets | Where-Object { $_.name -like "*msvc64.zip" } | Select-Object -First 1
if ($asset) { $dlUrl = $asset.browser_download_url; Write-Output "Tai $($asset.name) (release $($release.tag_name))..." }
} catch {
Write-Output "API loi ($($_.Exception.Message)) - dung ban pin."
}
if (-not $dlUrl) {
$dlUrl = "https://github.com/qpdf/qpdf/releases/download/v12.2.0/qpdf-12.2.0-msvc64.zip"
Write-Output "Tai ban pin: $dlUrl"
}
Invoke-WebRequest -Uri $dlUrl -OutFile $tmp -UseBasicParsing
$extractDir = Join-Path $env:TEMP "qpdf-extract"
if (Test-Path $extractDir) { Remove-Item -Recurse -Force $extractDir }