Last active
September 29, 2020 15:48
-
-
Save ehrnst/3cf676cab15c1193d2d0c42c2da0f8c1 to your computer and use it in GitHub Desktop.
Hugo + powershell + az devops
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$x = Invoke-restmethod -Uri "https://api.github.com/repos/gohugoio/hugo/releases/latest?draft=false" -Headers @{"accept"="application/vnd.github.v3+json"} -UseBasicParsing | |
$release = $x | where-object { -not $_.draft} | Select-Object id,name,assets -First 1 | |
$windows = $release.assets | Where-Object {$_.Name -like '*Windows*64*' -and $_.browser_download_url -like '*extended*'} | |
$windowsReleaseDownload = $windows.browser_download_url | |
$hugoFolder = "${env:TEMP}\hugotask_" | |
$hugoExe = "${hugoFolder}\hugo.exe" | |
New-Item -Path $hugoFolder -ItemType Directory -Force | Out-Null | |
$hugoZip = "${hugoFolder}\hugo.zip" | |
Invoke-WebRequest -Uri $windowsReleaseDownload -OutFile $hugoZip -UseBasicParsing | |
Write-Verbose "Download complete: unzipping" | |
[System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') | Out-Null | |
[System.IO.Compression.ZipFile]::ExtractToDirectory($hugoZip, $hugoFolder) | |
start-process -NoNewWindow -FilePath $hugoExe -ArgumentList "--destination $ENV:BUILD_ARTIFACTSTAGINGDIRECTORY --minify" -Verbose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment