Chore: change the scripts for installing cli (#627)
Signed-off-by: barnettZQG <barnett.zqg@gmail.com>
This commit is contained in:
parent
c5e944feaf
commit
5647857003
|
@ -2,9 +2,11 @@ name: documentation
|
|||
|
||||
on:
|
||||
pull_request:
|
||||
branches: main
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches: main
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
check-link:
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
name: script
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
check-linux:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Check Install Script
|
||||
run: static/script/install.sh
|
||||
check-windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Check Install Script
|
||||
run: static/script/install.ps1
|
|
@ -15,19 +15,7 @@ $VelaRoot = $VelaRoot -replace ' ', '` '
|
|||
$VelaCliBuildName = "vela"
|
||||
$VelaCliFileName = "vela.exe"
|
||||
$VelaCliFilePath = "${VelaRoot}\${VelaCliFileName}"
|
||||
|
||||
# GitHub Org and repo hosting Vela CLI
|
||||
$GitHubOrg = "oam-dev"
|
||||
$GitHubRepo = "kubevela"
|
||||
|
||||
# Set Github request authentication for basic authentication.
|
||||
if ($Env:GITHUB_USER) {
|
||||
$basicAuth = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($Env:GITHUB_USER + ":" + $Env:GITHUB_TOKEN));
|
||||
$githubHeader = @{"Authorization" = "Basic $basicAuth" }
|
||||
}
|
||||
else {
|
||||
$githubHeader = @{}
|
||||
}
|
||||
$RemoteURL = "https://static.kubevela.net/binary/vela"
|
||||
|
||||
if ((Get-ExecutionPolicy) -gt 'RemoteSigned' -or (Get-ExecutionPolicy) -eq 'ByPass') {
|
||||
Write-Output "PowerShell requires an execution policy of 'RemoteSigned'."
|
||||
|
@ -56,32 +44,24 @@ if (!(Test-Path $VelaRoot -PathType Container)) {
|
|||
throw "Cannot create $VelaRoot"
|
||||
}
|
||||
|
||||
# Get the list of release from GitHub
|
||||
$releases = Invoke-RestMethod -Headers $githubHeader -Uri "https://api.github.com/repos/${GitHubOrg}/${GitHubRepo}/releases" -Method Get
|
||||
if ($releases.Count -eq 0) {
|
||||
throw "No releases from github.com/oam-dev/kubevela repo"
|
||||
}
|
||||
|
||||
# Filter windows binary and download archive
|
||||
$os_arch = "windows-amd64"
|
||||
$vela_cli_filename="vela"
|
||||
$vela_cli_filename = "vela"
|
||||
if (!$Version) {
|
||||
$windowsAsset = $releases | Where-Object { $_.tag_name -notlike "*rc*" } | Select-Object -First 1 | Select-Object -ExpandProperty assets | Where-Object { $_.name -Like "${vela_cli_filename}-*${os_arch}.zip" }
|
||||
if (!$windowsAsset) {
|
||||
throw "Cannot find the windows KubeVela CLI binary"
|
||||
}
|
||||
$zipFileUrl = $windowsAsset.url
|
||||
$assetName = $windowsAsset.name
|
||||
} else {
|
||||
$assetName = "${vela_cli_filename}-${Version}-${os_arch}.zip"
|
||||
$zipFileUrl = "https://github.com/${GitHubOrg}/${GitHubRepo}/releases/download/${Version}/${assetName}"
|
||||
$Version = Invoke-RestMethod -Headers $githubHeader -Uri "${RemoteURL}/latest_version" -Method Get
|
||||
$Version = $Version.Trim()
|
||||
}
|
||||
if (!$Version.startswith("v")) {
|
||||
$Version = "v" + $Version
|
||||
}
|
||||
|
||||
$assetName = "${vela_cli_filename}-${Version}-${os_arch}.zip"
|
||||
$zipFileUrl = "${RemoteURL}/${Version}/${assetName}"
|
||||
|
||||
$zipFilePath = $VelaRoot + "\" + $assetName
|
||||
Write-Output "Downloading $zipFileUrl ..."
|
||||
|
||||
$githubHeader.Accept = "application/octet-stream"
|
||||
Invoke-WebRequest -Headers $githubHeader -Uri $zipFileUrl -OutFile $zipFilePath
|
||||
Invoke-WebRequest -Uri $zipFileUrl -OutFile $zipFilePath
|
||||
if (!(Test-Path $zipFilePath -PathType Leaf)) {
|
||||
throw "Failed to download Vela Cli binary - $zipFilePath"
|
||||
}
|
||||
|
|
|
@ -11,15 +11,13 @@
|
|||
# Http request CLI
|
||||
VELA_HTTP_REQUEST_CLI=curl
|
||||
|
||||
# GitHub Organization and repo name to download release
|
||||
GITHUB_ORG=oam-dev
|
||||
GITHUB_REPO=kubevela
|
||||
|
||||
# Vela CLI filename
|
||||
VELA_CLI_FILENAME=vela
|
||||
|
||||
VELA_CLI_FILE="${VELA_INSTALL_DIR}/${VELA_CLI_FILENAME}"
|
||||
|
||||
DOWNLOAD_BASE="https://static.kubevela.net/binary/vela"
|
||||
|
||||
getSystemInfo() {
|
||||
ARCH=$(uname -m)
|
||||
case $ARCH in
|
||||
|
@ -85,16 +83,15 @@ checkExistingVela() {
|
|||
}
|
||||
|
||||
getLatestRelease() {
|
||||
local velaReleaseUrl="https://api.github.com/repos/${GITHUB_ORG}/${GITHUB_REPO}/releases"
|
||||
local velaReleaseUrl="${DOWNLOAD_BASE}/latest_version"
|
||||
local latest_release=""
|
||||
|
||||
if [ "$VELA_HTTP_REQUEST_CLI" == "curl" ]; then
|
||||
latest_release=$(curl -s $velaReleaseUrl | grep \"tag_name\" | grep -v rc | awk '{print $2}' | sed -n 's/\"\(.*\)\",/\1/p' | sed -n '/^v[.0-9]*$/ p'|awk 'NR==1{print $1}')
|
||||
latest_release=$(curl -s $velaReleaseUrl)
|
||||
else
|
||||
latest_release=$(wget -q --header="Accept: application/json" -O - $velaReleaseUrl | grep \"tag_name\" | grep -v rc | awk '{print $2}' | sed -n 's/\"\(.*\)\",/\1/p' | sed -n '/^v[.0-9]*$/ p'|awk 'NR==1{print $1}')
|
||||
latest_release=$(wget -q -O - $velaReleaseUrl)
|
||||
fi
|
||||
|
||||
|
||||
ret_val=$latest_release
|
||||
}
|
||||
|
||||
|
@ -103,7 +100,6 @@ downloadFile() {
|
|||
|
||||
VELA_CLI_ARTIFACT="${VELA_CLI_FILENAME}-${LATEST_RELEASE_TAG}-${OS}-${ARCH}.tar.gz"
|
||||
# convert `-` to `_` to let it work
|
||||
DOWNLOAD_BASE="https://github.com/${GITHUB_ORG}/${GITHUB_REPO}/releases/download"
|
||||
DOWNLOAD_URL="${DOWNLOAD_BASE}/${LATEST_RELEASE_TAG}/${VELA_CLI_ARTIFACT}"
|
||||
|
||||
# Create the temp directory
|
||||
|
@ -179,6 +175,8 @@ checkHttpRequestCLI
|
|||
if [ -z "$1" ]; then
|
||||
echo "Getting the latest Vela CLI..."
|
||||
getLatestRelease
|
||||
elif [[ $1 == v* ]]; then
|
||||
ret_val=$1
|
||||
else
|
||||
ret_val=v$1
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue