Skip to content

Instantly share code, notes, and snippets.

@ehrnst
Last active September 29, 2020 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ehrnst/3cf676cab15c1193d2d0c42c2da0f8c1 to your computer and use it in GitHub Desktop.
Save ehrnst/3cf676cab15c1193d2d0c42c2da0f8c1 to your computer and use it in GitHub Desktop.
Hugo + powershell + az devops
$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