Files
Microtracking/tools/download_tectonic.ps1
T

29 lines
1.4 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
$root = 'C:\Users\fdavalos\OneDrive - up.edu.mx\microtracking\MicrotrackingFer\tools'
New-Item -ItemType Directory -Force -Path $root | Out-Null
# Resolve the latest release Windows asset URL via the GitHub API (reliable)
$api = 'https://api.github.com/repos/tectonic-typesetting/tectonic/releases/latest'
$rel = Invoke-RestMethod -Uri $api -TimeoutSec 60
Write-Output ("Release tag: " + $rel.tag_name)
$assets = @($rel.assets.browser_download_url | Where-Object { $_ -match 'x86_64-pc-windows-msvc\.zip$' })
if ($assets.Count -eq 0) {
Write-Output 'Available assets:'
$rel.assets.browser_download_url | ForEach-Object { Write-Output (' ' + $_) }
throw 'No Windows x86_64 MSVC zip asset found in the latest release'
}
$url = $assets[0]
Write-Output ("Asset: " + $url)
$zip = Join-Path $root 'tectonic.zip'
Invoke-WebRequest -Uri $url -OutFile $zip -UseBasicParsing -TimeoutSec 600
Write-Output ("Downloaded: " + (Get-Item $zip).Length + " bytes")
$extract = Join-Path $root 'extract'
Expand-Archive -Path $zip -DestinationPath $extract -Force
$exe = Get-ChildItem -Path $extract -Recurse -Filter 'tectonic.exe' | Select-Object -First 1
if ($null -eq $exe) { throw 'tectonic.exe not found inside the zip' }
$dst = Join-Path $root 'tectonic.exe'
Copy-Item $exe.FullName $dst -Force
Write-Output ("Installed: " + (Get-Item $dst).Length + " bytes")