Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23656db23a | ||
|
|
3d11e1d509 | ||
|
|
dba3303d7a |
@@ -1,3 +1,4 @@
|
||||
dist/
|
||||
lib/
|
||||
node_modules/
|
||||
jest.config.js
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"project": "./tsconfig.json"
|
||||
},
|
||||
"rules": {
|
||||
"i18n-text/no-en": "off",
|
||||
"eslint-comments/no-use": "off",
|
||||
"import/no-namespace": "off",
|
||||
"no-unused-vars": "off",
|
||||
|
||||
6
.github/codeql/codeql-config.yml
vendored
Normal file
6
.github/codeql/codeql-config.yml
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
name: "CodeQL config"
|
||||
queries:
|
||||
- uses: security-extended
|
||||
- uses: security-and-quality
|
||||
paths:
|
||||
- src
|
||||
11
.github/dependabot.yml
vendored
Normal file
11
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: github-actions
|
||||
directory: /
|
||||
schedule:
|
||||
interval: daily
|
||||
|
||||
- package-ecosystem: npm
|
||||
directory: /
|
||||
schedule:
|
||||
interval: daily
|
||||
53
.github/workflows/check-dist.yml
vendored
Normal file
53
.github/workflows/check-dist.yml
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
# `dist/index.js` is a special file in Actions.
|
||||
# When you reference an action with `uses:` in a workflow,
|
||||
# `index.js` is the code that will run.
|
||||
# For our project, we generate this file through a build process from other source files.
|
||||
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
|
||||
name: Check dist/
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check-dist:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set Node.js 16.x
|
||||
uses: actions/setup-node@v2.5.1
|
||||
with:
|
||||
node-version: 16.x
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Rebuild the dist/ directory
|
||||
run: |
|
||||
npm run build
|
||||
npm run package
|
||||
|
||||
- name: Compare the expected and actual dist/ directories
|
||||
run: |
|
||||
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
|
||||
echo "Detected uncommitted changes after build. See status below:"
|
||||
git diff
|
||||
exit 1
|
||||
fi
|
||||
id: diff
|
||||
|
||||
# If index.js was different than expected, upload the expected version as an artifact
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
||||
with:
|
||||
name: dist
|
||||
path: dist/
|
||||
73
.github/workflows/codeql.yml
vendored
Normal file
73
.github/workflows/codeql.yml
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ "master" ]
|
||||
schedule:
|
||||
- cron: '25 23 * * 6'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'TypeScript' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
config-file: ./.github/codeql/codeql-config.yml
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
|
||||
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
||||
# queries: security-extended,security-and-quality
|
||||
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||
|
||||
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
||||
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
|
||||
|
||||
# - run: |
|
||||
# echo "Run, Build Application using script"
|
||||
# ./location_of_script_within_repo/buildscript.sh
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
20
.github/workflows/dependency-review.yml
vendored
Normal file
20
.github/workflows/dependency-review.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
# Dependency Review Action
|
||||
#
|
||||
# This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging.
|
||||
#
|
||||
# Source repository: https://github.com/actions/dependency-review-action
|
||||
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
|
||||
name: 'Dependency Review'
|
||||
on: [pull_request]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
dependency-review:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'Checkout Repository'
|
||||
uses: actions/checkout@v3
|
||||
- name: 'Dependency Review'
|
||||
uses: actions/dependency-review-action@v2
|
||||
5
.github/workflows/test.yml
vendored
5
.github/workflows/test.yml
vendored
@@ -4,13 +4,12 @@ on: # rebuild any PRs and main branch changes
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- 'releases/*'
|
||||
|
||||
jobs:
|
||||
build: # make sure build/ci work properly
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/checkout@v3
|
||||
- run: npm ci
|
||||
- run: npm run all
|
||||
|
||||
@@ -20,7 +19,7 @@ jobs:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ./
|
||||
with:
|
||||
endpoint: ${{ secrets.OSS_ENDPOINT }}
|
||||
|
||||
@@ -16,7 +16,7 @@ steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: yizhoumo/setup-ossutil@v1
|
||||
with:
|
||||
ossutil-version: '1.7.0' # Optional, default to '1.7.0'
|
||||
ossutil-version: '1.7.0' # Optional, default to 'latest'
|
||||
endpoint: ${{ secrets.OSS_ENDPOINT }}
|
||||
access-key-id: ${{ secrets.OSS_ACCESS_KEY_ID }}
|
||||
access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }}
|
||||
|
||||
@@ -5,47 +5,31 @@ const TEMP_DIR = path.join(__dirname, 'runner', 'temp')
|
||||
process.env['RUNNER_TOOL_CACHE'] = TOOL_DIR
|
||||
process.env['RUNNER_TEMP'] = TEMP_DIR
|
||||
|
||||
import * as core from '@actions/core'
|
||||
import * as io from '@actions/io'
|
||||
import * as fs from 'fs'
|
||||
import * as installer from '../src/installer'
|
||||
|
||||
const FILE_NAME = process.platform === 'win32' ? 'ossutil.exe' : 'ossutil'
|
||||
|
||||
jest.setTimeout(60000)
|
||||
|
||||
describe('installer tests', () => {
|
||||
beforeAll(async () => {
|
||||
beforeEach(async () => {
|
||||
await io.rmRF(TOOL_DIR)
|
||||
await io.rmRF(TEMP_DIR)
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
afterEach(async () => {
|
||||
await io.rmRF(TOOL_DIR)
|
||||
await io.rmRF(TEMP_DIR)
|
||||
})
|
||||
|
||||
it('install ossutil 1.7.0', async () => {
|
||||
const version = '1.7.0'
|
||||
const versions = ['1.7.0', 'latest']
|
||||
|
||||
it.each(versions)('install ossutil %s', async version => {
|
||||
await installer.getOssutil(version)
|
||||
|
||||
const ossutilDir = path.join(TOOL_DIR, 'ossutil', version, process.arch)
|
||||
expect(fs.existsSync(`${ossutilDir}.complete`)).toBe(true)
|
||||
|
||||
const exist = fs.existsSync(path.join(ossutilDir, FILE_NAME))
|
||||
expect(exist).toBe(true)
|
||||
|
||||
expect(await io.which('ossutil', true)).toBeTruthy()
|
||||
})
|
||||
|
||||
it('throw if wrong version', async () => {
|
||||
let thrown = false
|
||||
try {
|
||||
await installer.getOssutil('1000.0.0')
|
||||
} catch (error) {
|
||||
core.error(error)
|
||||
thrown = true
|
||||
}
|
||||
expect(thrown).toBe(true)
|
||||
await expect(installer.getOssutil('1000.0.0')).rejects.toThrowError()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -5,7 +5,7 @@ inputs:
|
||||
ossutil-version:
|
||||
description: 'The OSSUTIL version to download and use'
|
||||
required: false
|
||||
default: '1.7.0'
|
||||
default: 'latest'
|
||||
endpoint:
|
||||
description: 'The endpoint of your bucket'
|
||||
required: true
|
||||
@@ -19,7 +19,7 @@ inputs:
|
||||
description: 'The STS Token of the credentials'
|
||||
required: false
|
||||
runs:
|
||||
using: 'node12'
|
||||
using: 'node16'
|
||||
main: 'dist/index.js'
|
||||
branding:
|
||||
icon: 'download-cloud'
|
||||
|
||||
2915
dist/index.js
generated
vendored
2915
dist/index.js
generated
vendored
File diff suppressed because it is too large
Load Diff
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
47
dist/licenses.txt
generated
vendored
47
dist/licenses.txt
generated
vendored
@@ -12,6 +12,15 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
||||
|
||||
@actions/exec
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@actions/http-client
|
||||
MIT
|
||||
@@ -40,9 +49,27 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@actions/io
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@actions/tool-cache
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
semver
|
||||
ISC
|
||||
@@ -92,22 +119,10 @@ uuid
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2010-2016 Robert Kieffer and other contributors
|
||||
Copyright (c) 2010-2020 Robert Kieffer and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
3911
dist/sourcemap-register.js
generated
vendored
3911
dist/sourcemap-register.js
generated
vendored
File diff suppressed because one or more lines are too long
@@ -1,9 +1,7 @@
|
||||
module.exports = {
|
||||
clearMocks: true,
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
testRunner: 'jest-circus/runner',
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest'
|
||||
},
|
||||
|
||||
17256
package-lock.json
generated
17256
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
31
package.json
31
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "setup-ossutil",
|
||||
"version": "1.0.2",
|
||||
"version": "1.1.0",
|
||||
"private": true,
|
||||
"description": "setup ossutil action",
|
||||
"main": "lib/setup-ossutil.js",
|
||||
@@ -25,22 +25,21 @@
|
||||
"author": "Rimo",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/tool-cache": "^1.3.0"
|
||||
"@actions/core": "^1.6.0",
|
||||
"@actions/tool-cache": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.15",
|
||||
"@types/node": "^14.14.9",
|
||||
"@typescript-eslint/parser": "^4.8.1",
|
||||
"@vercel/ncc": "^0.25.1",
|
||||
"eslint": "^7.13.0",
|
||||
"eslint-plugin-github": "^4.1.1",
|
||||
"eslint-plugin-jest": "^23.20.0",
|
||||
"jest": "^24.9.0",
|
||||
"jest-circus": "^26.4.2",
|
||||
"js-yaml": "^3.14.0",
|
||||
"prettier": "2.1.1",
|
||||
"ts-jest": "^24.3.0",
|
||||
"typescript": "^4.0.2"
|
||||
"@types/jest": "^27.0.0",
|
||||
"@types/node": "^16.10.5",
|
||||
"@typescript-eslint/parser": "^5.8.1",
|
||||
"@vercel/ncc": "^0.31.1",
|
||||
"eslint": "^8.0.1",
|
||||
"eslint-plugin-github": "^4.3.2",
|
||||
"eslint-plugin-jest": "^25.3.2",
|
||||
"jest": "^27.2.5",
|
||||
"js-yaml": "^4.1.0",
|
||||
"prettier": "2.5.1",
|
||||
"ts-jest": "^27.1.2",
|
||||
"typescript": "^4.4.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +1,54 @@
|
||||
import * as core from '@actions/core'
|
||||
import * as tc from '@actions/tool-cache'
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
import {HttpClient} from '@actions/http-client'
|
||||
|
||||
const TOOL_NAME = 'ossutil'
|
||||
const ToolName = 'ossutil'
|
||||
const UpdateEndpoint =
|
||||
'https://ossutil-version-update.oss-cn-hangzhou.aliyuncs.com'
|
||||
|
||||
/**
|
||||
* Get ossutil ready for use
|
||||
* @param version the version of ossutil
|
||||
*/
|
||||
export async function getOssutil(version: string): Promise<void> {
|
||||
let toolPath = tc.find(TOOL_NAME, version)
|
||||
if (!toolPath) {
|
||||
// download, extract, cache
|
||||
toolPath = await acquireOssutil(version)
|
||||
if (version.toLowerCase() === 'latest') {
|
||||
version = await getLatestVersion()
|
||||
core.info(`Using the latest version of ossutil: ${version}`)
|
||||
}
|
||||
|
||||
let toolPath = tc.find(ToolName, version)
|
||||
if (!toolPath) {
|
||||
toolPath = await downloadOssutil(version)
|
||||
}
|
||||
|
||||
core.debug(`ossutil is cached under ${toolPath}`)
|
||||
core.addPath(toolPath)
|
||||
}
|
||||
|
||||
/**
|
||||
* Acquire ossutil and install it into the tool cache
|
||||
* @param version the version of ossutil to acquire
|
||||
* Download ossutil and install it into the tool cache
|
||||
* @param version the version of ossutil to download
|
||||
* @returns the path to the tool directory
|
||||
*/
|
||||
async function acquireOssutil(version: string): Promise<string> {
|
||||
async function downloadOssutil(version: string): Promise<string> {
|
||||
// download
|
||||
let downloadFile: string
|
||||
let toolFile: string
|
||||
try {
|
||||
const downloadUrl = getDownloadUrl(version)
|
||||
core.info(`Downloading ossutil from: ${downloadUrl}`)
|
||||
downloadFile = await tc.downloadTool(downloadUrl)
|
||||
toolFile = await tc.downloadTool(downloadUrl)
|
||||
} catch (error) {
|
||||
core.error(error)
|
||||
throw new Error('Failed to download ossutil')
|
||||
core.error('Failed to download ossutil')
|
||||
throw error
|
||||
}
|
||||
core.debug(`ossutil downloaded to: ${downloadFile}`)
|
||||
core.debug(`ossutil downloaded to: ${toolFile}`)
|
||||
|
||||
// extract (if needed)
|
||||
let toolFile = downloadFile
|
||||
if (process.platform === 'win32') {
|
||||
const extractFolder = await tc.extractZip(downloadFile)
|
||||
toolFile = path.join(extractFolder, 'ossutil64', 'ossutil64.exe')
|
||||
core.debug(`ossutil extracted to: ${toolFile}`)
|
||||
}
|
||||
// change permission
|
||||
fs.chmodSync(toolFile, 0o755)
|
||||
|
||||
// cache
|
||||
const fileName = process.platform === 'win32' ? 'ossutil.exe' : 'ossutil'
|
||||
const toolPath = await tc.cacheFile(toolFile, fileName, TOOL_NAME, version)
|
||||
const fileName = process.platform === 'win32' ? `${ToolName}.exe` : ToolName
|
||||
const toolPath = await tc.cacheFile(toolFile, fileName, ToolName, version)
|
||||
core.debug(`ossutil cached to: ${toolPath}`)
|
||||
return toolPath
|
||||
}
|
||||
@@ -60,14 +59,13 @@ async function acquireOssutil(version: string): Promise<string> {
|
||||
* @returns the URL
|
||||
*/
|
||||
function getDownloadUrl(version: string): string {
|
||||
let downloadUrl = `http://gosspublic.alicdn.com/ossutil/${version}/`
|
||||
|
||||
let downloadUrl = `${UpdateEndpoint}/${version}/`
|
||||
switch (process.platform) {
|
||||
case 'linux':
|
||||
downloadUrl += 'ossutil64'
|
||||
break
|
||||
case 'win32':
|
||||
downloadUrl += 'ossutil64.zip'
|
||||
downloadUrl += 'ossutil64.exe'
|
||||
break
|
||||
case 'darwin':
|
||||
downloadUrl += 'ossutilmac64'
|
||||
@@ -78,3 +76,14 @@ function getDownloadUrl(version: string): string {
|
||||
|
||||
return downloadUrl
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest version of ossutil
|
||||
* @returns the latest version
|
||||
*/
|
||||
async function getLatestVersion(): Promise<string> {
|
||||
const http = new HttpClient()
|
||||
const response = await http.get(`${UpdateEndpoint}/ossutilversion`)
|
||||
const content = await response.readBody()
|
||||
return content.trim()
|
||||
}
|
||||
|
||||
@@ -32,8 +32,10 @@ async function run(): Promise<void> {
|
||||
core.info('ossutil config is done')
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
run()
|
||||
|
||||
Reference in New Issue
Block a user