Download ossutil from CDN endpoint (#30)

* use cdn to download

* set default version to 1.7.14

* schedule daily test

* bump up version 1.1.1

* use 'latest' in CI test
This commit is contained in:
Rimo
2022-09-28 22:49:06 +08:00
committed by GitHub
parent 0677c3a661
commit 7771e4ad5d
8 changed files with 25 additions and 18 deletions

View File

@@ -4,8 +4,9 @@ import * as fs from 'fs'
import {HttpClient} from '@actions/http-client'
const ToolName = 'ossutil'
const UpdateEndpoint =
'https://ossutil-version-update.oss-cn-hangzhou.aliyuncs.com'
const UpdateUrl =
'https://ossutil-version-update.oss-cn-hangzhou.aliyuncs.com/ossutilversion'
const DownloadEndpoint = 'https://gosspublic.alicdn.com/ossutil'
/**
* Get ossutil ready for use
@@ -59,7 +60,7 @@ async function downloadOssutil(version: string): Promise<string> {
* @returns the URL
*/
function getDownloadUrl(version: string): string {
let downloadUrl = `${UpdateEndpoint}/${version}/`
let downloadUrl = `${DownloadEndpoint}/${version}/`
switch (process.platform) {
case 'linux':
downloadUrl += 'ossutil64'
@@ -82,8 +83,11 @@ function getDownloadUrl(version: string): string {
* @returns the latest version
*/
async function getLatestVersion(): Promise<string> {
const http = new HttpClient()
const response = await http.get(`${UpdateEndpoint}/ossutilversion`)
const http = new HttpClient('setup-ossutil', [], {
allowRetries: true,
maxRetries: 5
})
const response = await http.get(UpdateUrl)
const content = await response.readBody()
return content.trim()
}