From 72f86392dd7bf482f409dfe4dd00219ef422ad9c Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Tue, 18 Jun 2019 19:12:06 +0800 Subject: support download tag from ci --- scripts/get.ps1 | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/get.ps1 b/scripts/get.ps1 index 0a07c8d2e..726d74a42 100644 --- a/scripts/get.ps1 +++ b/scripts/get.ps1 @@ -6,7 +6,7 @@ # Invoke-Expression (Invoke-Webrequest -UseBasicParsing).Content param ( - [string]$branch = "master", + [string]$version = "master", [string]$installdir = "" ) @@ -57,10 +57,15 @@ if ($null -eq $installdir -or $installdir -match '^\s*$') { } } -if ($null -eq $branch -or $branch -match '^\s*$') { - $branch = 'master' +if ($null -eq $version -or $version -match '^\s*$') { + $v = 'master' +} else { + $v = $version.Trim() + if ($v.Contains('.')) { + $v = [version]::Parse($version) + $v = New-Object -TypeName version -ArgumentList $v.Major, $v.Minor, $v.Build + } } - function checkTempAccess { $outfile = Join-Path $temppath "$pid.tmp" try { @@ -77,7 +82,15 @@ function xmakeInstall { $outfile = Join-Path $temppath "$pid-xmake-installer.exe" $x64arch = @('AMD64', 'IA64', 'ARM64') $arch = if ($env:PROCESSOR_ARCHITECTURE -in $x64arch -or $env:PROCESSOR_ARCHITEW6432 -in $x64arch) { 'x64' } else { 'x86' } - $url = "https://ci.appveyor.com/api/projects/waruqi/xmake/artifacts/xmake-installer.exe?branch=$branch&pr=false&job=Image%3A+Visual+Studio+2017%3B+Platform%3A+$arch" + $url = if ($v -is [version]) { + if ($v -gt "2.2.6") { + "https://ci.appveyor.com/api/projects/waruqi/xmake/artifacts/xmake-installer.exe?tag=v$v&pr=false&job=Image%3A+Visual+Studio+2017%3B+Platform%3A+$arch" + } else { + "https://github.com/xmake-io/xmake/releases/download/v$v/xmake-v$v.exe" + } + } else { + "https://ci.appveyor.com/api/projects/waruqi/xmake/artifacts/xmake-installer.exe?branch=$v&pr=false&job=Image%3A+Visual+Studio+2017%3B+Platform%3A+$arch" + } Write-Host "Start downloading $url .." try { Invoke-Webrequest $url -OutFile $outfile -UseBasicParsing -- cgit v1.3.1