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,6 +4,8 @@ on: # rebuild any PRs and main branch changes
push: push:
branches: branches:
- master - master
schedule:
- cron: '0 0 * * *'
jobs: jobs:
build: # make sure build/ci work properly build: # make sure build/ci work properly
@@ -36,6 +38,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: ./ - uses: ./
with: with:
ossutil-version: 'latest'
endpoint: ${{ secrets.OSS_ENDPOINT }} endpoint: ${{ secrets.OSS_ENDPOINT }}
access-key-id: ${{ secrets.OSS_ACCESS_KEY_ID }} access-key-id: ${{ secrets.OSS_ACCESS_KEY_ID }}
access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }} access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }}

View File

@@ -16,7 +16,7 @@ steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- uses: yizhoumo/setup-ossutil@v1 - uses: yizhoumo/setup-ossutil@v1
with: with:
ossutil-version: '1.7.0' # Optional, default to 'latest' ossutil-version: '1.7.14' # Optional, default to '1.7.14'. Use 'latest' to get the latest version.
endpoint: ${{ secrets.OSS_ENDPOINT }} endpoint: ${{ secrets.OSS_ENDPOINT }}
access-key-id: ${{ secrets.OSS_ACCESS_KEY_ID }} access-key-id: ${{ secrets.OSS_ACCESS_KEY_ID }}
access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }} access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }}

View File

@@ -21,15 +21,11 @@ describe('installer tests', () => {
await io.rmRF(TEMP_DIR) await io.rmRF(TEMP_DIR)
}) })
const versions = ['1.7.0', 'latest'] const versions = ['1.7.14', 'latest']
it.each(versions)('install ossutil %s', async version => { it.each(versions)('install ossutil %s', async version => {
await installer.getOssutil(version) await installer.getOssutil(version)
expect(await io.which('ossutil', true)).toBeTruthy() expect(await io.which('ossutil', true)).toBeTruthy()
}) })
it('throw if wrong version', async () => {
await expect(installer.getOssutil('1000.0.0')).rejects.toThrowError()
})
}) })

View File

@@ -5,7 +5,7 @@ inputs:
ossutil-version: ossutil-version:
description: 'The OSSUTIL version to download and use' description: 'The OSSUTIL version to download and use'
required: false required: false
default: 'latest' default: '1.7.14'
endpoint: endpoint:
description: 'The endpoint of your bucket' description: 'The endpoint of your bucket'
required: true required: true

12
dist/index.js generated vendored
View File

@@ -45,7 +45,8 @@ const tc = __importStar(__nccwpck_require__(7784));
const fs = __importStar(__nccwpck_require__(5747)); const fs = __importStar(__nccwpck_require__(5747));
const http_client_1 = __nccwpck_require__(6255); const http_client_1 = __nccwpck_require__(6255);
const ToolName = 'ossutil'; 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 * Get ossutil ready for use
* @param version the version of ossutil * @param version the version of ossutil
@@ -98,7 +99,7 @@ function downloadOssutil(version) {
* @returns the URL * @returns the URL
*/ */
function getDownloadUrl(version) { function getDownloadUrl(version) {
let downloadUrl = `${UpdateEndpoint}/${version}/`; let downloadUrl = `${DownloadEndpoint}/${version}/`;
switch (process.platform) { switch (process.platform) {
case 'linux': case 'linux':
downloadUrl += 'ossutil64'; downloadUrl += 'ossutil64';
@@ -120,8 +121,11 @@ function getDownloadUrl(version) {
*/ */
function getLatestVersion() { function getLatestVersion() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const http = new http_client_1.HttpClient(); const http = new http_client_1.HttpClient('setup-ossutil', [], {
const response = yield http.get(`${UpdateEndpoint}/ossutilversion`); allowRetries: true,
maxRetries: 5
});
const response = yield http.get(UpdateUrl);
const content = yield response.readBody(); const content = yield response.readBody();
return content.trim(); return content.trim();
}); });

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{ {
"name": "setup-ossutil", "name": "setup-ossutil",
"version": "1.1.0", "version": "1.1.1",
"private": true, "private": true,
"description": "setup ossutil action", "description": "setup ossutil action",
"main": "lib/setup-ossutil.js", "main": "lib/setup-ossutil.js",

View File

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