42 Commits
v1.0.1 ... v2

Author SHA1 Message Date
Rimo
80f4dc3682 release v2 2024-01-26 17:11:39 +00:00
Rimo
60c150d787 get latest version from official 2024-01-26 16:43:52 +00:00
Rimo
2081cee43c fix for mac 2024-01-26 16:13:18 +00:00
Rimo
9dea1aac7e download from zip 2024-01-26 16:00:57 +00:00
Rimo
fdb656e148 support install without config 2024-01-26 14:27:47 +00:00
dependabot[bot]
59fe15c39c Bump @actions/github from 5.1.1 to 6.0.0 (#46)
* Bump @actions/github from 5.1.1 to 6.0.0

Bumps [@actions/github](https://github.com/actions/toolkit/tree/HEAD/packages/github) from 5.1.1 to 6.0.0.
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/github/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/github)

---
updated-dependencies:
- dependency-name: "@actions/github"
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* update dist

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Rimo <4203620+yizhoumo@users.noreply.github.com>
2024-01-26 01:23:28 +08:00
Rimo
865e26ae28 update README 2024-01-25 16:47:57 +00:00
Rimo
27dbb86e47 fix action.yml 2024-01-25 16:16:54 +00:00
Rimo
4191da5daf sync with upstream 2024-01-25 15:46:42 +00:00
dependabot[bot]
89a583bcb4 Bump actions/checkout from 3 to 4 (#39)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-15 00:20:00 +08:00
Rimo
7de480550b Update README.md 2023-03-03 21:29:02 +08:00
Rimo
6666bbeb34 Update build.yml 2023-03-03 21:24:09 +08:00
Rimo
f0d5c67ae8 Update build.yml 2023-03-03 21:10:20 +08:00
Rimo
a27182c923 Update and rename test.yml to functional.yml 2023-03-03 21:07:12 +08:00
dependabot[bot]
fe25da5c69 Bump actions/dependency-review-action from 2 to 3 (#33)
Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 2 to 3.
- [Release notes](https://github.com/actions/dependency-review-action/releases)
- [Commits](https://github.com/actions/dependency-review-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/dependency-review-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-24 21:07:44 +08:00
dependabot[bot]
da0dd6f825 Bump json5 from 1.0.1 to 1.0.2 (#35)
Bumps [json5](https://github.com/json5/json5) from 1.0.1 to 1.0.2.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v1.0.1...v1.0.2)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-24 21:04:46 +08:00
Rimo
e3a6534c61 Update README.md 2022-09-29 20:08:25 +08:00
Rimo
121c208740 Fix Windows build download link (#32)
* fix windows download

* update test.yml: add version matrix

* update dist
2022-09-29 03:01:00 +08:00
Yizhou Mo
1d32a34314 split build and test pipeline 2022-09-29 01:35:35 +08:00
Rimo
9dba6ec80f Call GitHub API to get the latest version info (#31)
* call github api to get the latest version info

* remove latest case from installer.tests

* update dist
2022-09-29 01:08:14 +08:00
Rimo
7771e4ad5d 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
2022-09-28 22:49:06 +08:00
dependabot[bot]
0677c3a661 Bump actions/upload-artifact from 2 to 3 (#28) 2022-08-24 12:08:35 +00:00
Yizhou Mo
8b71dde9cc merge check-dist.yml into test.yml 2022-08-20 22:35:48 +08:00
Rimo
3c902f37b8 Update dependabot.yml 2022-08-20 22:21:32 +08:00
dependabot[bot]
32ae336e72 Bump actions/upload-artifact from 2 to 3 (#23) 2022-08-20 13:58:13 +00:00
dependabot[bot]
8acd1073f5 Bump actions/setup-node from 2.5.1 to 3.4.1 (#22) 2022-08-20 13:54:17 +00:00
Rimo
23656db23a Support latest version of ossutil (#17)
* support latest version
* bump up version to 1.1.0
2022-08-20 21:11:31 +08:00
Rimo
3d11e1d509 Create codeql.yml 2022-08-20 19:41:16 +08:00
Rimo
dba3303d7a Create dependency-review.yml 2022-08-20 19:40:37 +08:00
Rimo
fd6fbb7c82 Upgrade default version of ossutil to 1.7.0 2020-12-22 01:07:58 +08:00
Rimo
fdc36f3165 Bump version to 1.0.2 2020-12-22 00:30:37 +08:00
Rimo
8cd5012746 update package-lock.json 2020-12-22 00:24:00 +08:00
Rimo
817e6913f6 rebuild 2020-12-22 00:21:53 +08:00
Rimo
c0bdf31f7f update template 2020-12-22 00:21:43 +08:00
Rimo
3f8b34f4cd rebuild dist 2020-12-22 00:06:55 +08:00
Rimo
7730354c83 Merge pull request #4 from yizhoumo/dependabot/npm_and_yarn/actions/core-1.2.6
Bump @actions/core from 1.2.0 to 1.2.6
2020-12-21 23:38:15 +08:00
dependabot[bot]
8ec4e4eac1 Bump @actions/core from 1.2.0 to 1.2.6
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.0 to 1.2.6.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-01 17:28:31 +00:00
Rimo
dcc6f1cca2 Merge pull request #3 from yizhoumo/dependabot/npm_and_yarn/lodash-4.17.19
Bump lodash from 4.17.15 to 4.17.19
2020-07-19 16:37:16 +08:00
dependabot[bot]
07bd03fad5 Bump lodash from 4.17.15 to 4.17.19
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-19 07:19:29 +00:00
Rimo
297280acad Merge pull request #2 from yizhoumo/dependabot/npm_and_yarn/actions/http-client-1.0.8
Bump @actions/http-client from 1.0.1 to 1.0.8
2020-04-30 16:38:02 +08:00
dependabot[bot]
d280ef3f81 Bump @actions/http-client from 1.0.1 to 1.0.8
Bumps [@actions/http-client](https://github.com/actions/http-client) from 1.0.1 to 1.0.8.
- [Release notes](https://github.com/actions/http-client/releases)
- [Changelog](https://github.com/actions/http-client/blob/master/RELEASES.md)
- [Commits](https://github.com/actions/http-client/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2020-04-29 18:00:44 +00:00
Rimo
334892c424 Hide output of ossutil in CI 2020-04-22 18:02:06 +08:00
33 changed files with 36107 additions and 7978 deletions

View File

@@ -1,3 +1,4 @@
dist/
lib/
dist/
node_modules/
coverage/

View File

@@ -1,58 +0,0 @@
{
"plugins": ["jest", "@typescript-eslint"],
"extends": ["plugin:github/es6"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-ignore": "error",
"camelcase": "off",
"@typescript-eslint/camelcase": "error",
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/generic-type-naming": ["error", "^[A-Z][A-Za-z]*$"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-object-literal-type-assertion": "error",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-interface": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"semi": "off",
"@typescript-eslint/semi": ["error", "never"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error"
},
"env": {
"node": true,
"es6": true,
"jest/globals": true
}
}

3
.gitattributes vendored Normal file
View File

@@ -0,0 +1,3 @@
* text=auto eol=lf
dist/** -diff linguist-generated=true

26
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
groups:
actions-minor:
update-types:
- minor
- patch
- package-ecosystem: npm
directory: /
schedule:
interval: weekly
groups:
npm-development:
dependency-type: development
update-types:
- minor
- patch
npm-production:
dependency-type: production
update-types:
- patch

83
.github/linters/.eslintrc.yml vendored Normal file
View File

@@ -0,0 +1,83 @@
env:
node: true
es6: true
jest: true
globals:
Atomics: readonly
SharedArrayBuffer: readonly
ignorePatterns:
- '!.*'
- '**/node_modules/.*'
- '**/dist/.*'
- '**/coverage/.*'
- '*.json'
parser: '@typescript-eslint/parser'
parserOptions:
ecmaVersion: 2023
sourceType: module
project:
- './.github/linters/tsconfig.json'
- './tsconfig.json'
plugins:
- jest
- '@typescript-eslint'
extends:
- eslint:recommended
- plugin:@typescript-eslint/eslint-recommended
- plugin:@typescript-eslint/recommended
- plugin:github/recommended
- plugin:jest/recommended
rules:
{
'camelcase': 'off',
'eslint-comments/no-use': 'off',
'eslint-comments/no-unused-disable': 'off',
'i18n-text/no-en': 'off',
'import/no-namespace': 'off',
'no-console': 'off',
'no-unused-vars': 'off',
'prettier/prettier': 'error',
'semi': 'off',
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/explicit-member-accessibility':
['error', { 'accessibility': 'no-public' }],
'@typescript-eslint/explicit-function-return-type':
['error', { 'allowExpressions': true }],
'@typescript-eslint/func-call-spacing': ['error', 'never'],
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/prefer-for-of': 'warn',
'@typescript-eslint/prefer-function-type': 'warn',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/semi': ['error', 'never'],
'@typescript-eslint/space-before-function-paren': 'off',
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/unbound-method': 'error'
}

7
.github/linters/.markdown-lint.yml vendored Normal file
View File

@@ -0,0 +1,7 @@
# Unordered list style
MD004:
style: dash
# Ordered list item prefix
MD029:
style: one

10
.github/linters/.yaml-lint.yml vendored Normal file
View File

@@ -0,0 +1,10 @@
rules:
document-end: disable
document-start:
level: warning
present: false
line-length:
level: warning
max: 80
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: true

9
.github/linters/tsconfig.json vendored Normal file
View File

@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../tsconfig.json",
"compilerOptions": {
"noEmit": true
},
"include": ["../../__tests__/**/*", "../../src/**/*"],
"exclude": ["../../dist", "../../node_modules", "../../coverage", "*.json"]
}

64
.github/workflows/check-dist.yml vendored Normal file
View File

@@ -0,0 +1,64 @@
# In TypeScript actions, `dist/` is a special directory. When you reference
# an action with the `uses:` property, `dist/index.js` is the code that will be
# run. For this project, the `dist/index.js` file is transpiled from other
# source files. This workflow ensures the `dist/` directory contains the
# expected transpiled code.
#
# If this workflow is run from a feature branch, it will act as an additional CI
# check and fail if the checked-in `dist/` directory does not match what is
# expected from the build.
name: Check Transpiled JavaScript
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
jobs:
check-dist:
name: Check dist/
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- name: Install Dependencies
id: install
run: npm ci
- name: Build dist/ Directory
id: build
run: npm run bundle
# This will fail the workflow if the PR wasn't created by Dependabot.
- name: Compare Directories
id: diff
run: |
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff --ignore-space-at-eol --text dist/
exit 1
fi
# If `dist/` was different than expected, and this was not a Dependabot
# PR, upload the expected version as a workflow artifact.
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
name: Upload Artifact
id: upload
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

69
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,69 @@
name: Continuous Integration
on:
pull_request:
push:
branches:
- main
permissions:
contents: read
jobs:
test-typescript:
name: TypeScript Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- name: Install Dependencies
id: npm-ci
run: npm ci
- name: Check Format
id: npm-format-check
run: npm run format:check
- name: Lint
id: npm-lint
run: npm run lint
- name: Test
id: npm-ci-test
run: npm run ci-test
test-action:
name: GitHub Actions Test
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
version: [1.7.15, latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Test Local Action
id: test-action
uses: ./
with:
ossutil-version: ${{ matrix.version }}
endpoint: ${{ secrets.OSS_ENDPOINT }}
access-key-id: ${{ secrets.OSS_ACCESS_KEY_ID }}
access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }}
- run: ossutil -v
- run: ossutil ls > /dev/null
shell: bash

48
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@@ -0,0 +1,48 @@
name: CodeQL
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '31 7 * * 3'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
checks: write
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language:
- TypeScript
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Initialize CodeQL
id: initialize
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
source-root: src
- name: Autobuild
id: autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
id: analyze
uses: github/codeql-action/analyze@v3

22
.github/workflows/functional.yml vendored Normal file
View File

@@ -0,0 +1,22 @@
name: "functional"
on:
schedule:
- cron: '0 2 * * 6'
jobs:
functional:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
version: [1.7.0, 1.7.14, latest]
runs-on: ${{ matrix.os }}
steps:
- uses: yizhoumo/setup-ossutil@v1
with:
ossutil-version: ${{ matrix.version }}
endpoint: ${{ secrets.OSS_ENDPOINT }}
access-key-id: ${{ secrets.OSS_ACCESS_KEY_ID }}
access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }}
- run: ossutil -v
- run: ossutil ls > /dev/null
shell: bash

45
.github/workflows/linter.yml vendored Normal file
View File

@@ -0,0 +1,45 @@
name: Lint Codebase
on:
pull_request:
push:
branches:
- main
permissions:
contents: read
packages: read
statuses: write
jobs:
lint:
name: Lint Codebase
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- name: Install Dependencies
id: install
run: npm ci
- name: Lint Codebase
id: super-linter
uses: super-linter/super-linter/slim@v5
env:
DEFAULT_BRANCH: main
FILTER_REGEX_EXCLUDE: dist/**/*
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TYPESCRIPT_DEFAULT_STYLE: prettier
VALIDATE_ALL_CODEBASE: true
VALIDATE_JAVASCRIPT_STANDARD: false
VALIDATE_JSCPD: false

View File

@@ -1,30 +0,0 @@
name: "build-test"
on: # rebuild any PRs and main branch changes
pull_request:
push:
branches:
- master
- 'releases/*'
jobs:
build: # make sure build/ci work properly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: npm ci
- run: npm run all
test: # make sure the action works on a clean machine without building
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- uses: ./
with:
endpoint: ${{ secrets.OSS_ENDPOINT }}
access-key-id: ${{ secrets.OSS_ACCESS_KEY_ID }}
access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }}
- run: ossutil -v
- run: ossutil ls

6
.gitignore vendored
View File

@@ -96,4 +96,8 @@ Thumbs.db
# Ignore built ts files
__tests__/runner/*
lib/**/*
# IDE files
.idea
.vscode
*.code-workspace

1
.node-version Normal file
View File

@@ -0,0 +1 @@
20.6.0

View File

@@ -1,3 +1,3 @@
dist/
lib/
node_modules/
coverage/

View File

@@ -4,8 +4,13 @@
"useTabs": false,
"semi": false,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "none",
"bracketSpacing": false,
"bracketSpacing": true,
"bracketSameLine": true,
"arrowParens": "avoid",
"parser": "typescript"
"proseWrap": "always",
"htmlWhitespaceSensitivity": "css",
"endOfLine": "lf"
}

13
LICENSE
View File

@@ -1,7 +1,6 @@
MIT License
The MIT License (MIT)
Copyright (c) 2018 GitHub, Inc. and contributors
Copyright 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
@@ -10,13 +9,13 @@ 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.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,11 +1,13 @@
# setup-ossutil
[![GitHub Actions status](https://github.com/yizhoumo/setup-ossutil/workflows/build-test/badge.svg)](https://github.com/yizhoumo/setup-ossutil/actions)
[![Continuous Integration](https://github.com/yizhoumo/setup-ossutil/actions/workflows/ci.yml/badge.svg)](https://github.com/yizhoumo/setup-ossutil/actions/workflows/ci.yml)
[![Functional](https://github.com/yizhoumo/setup-ossutil/actions/workflows/functional.yml/badge.svg)](https://github.com/yizhoumo/setup-ossutil/actions/workflows/functional.yml)
This action sets up [Alibaba Cloud OSSUTIL](https://github.com/aliyun/ossutil) for use in actions by:
This action provides the following functionality for GitHub Actions users:
- downloading and caching ossutil by version and adding to PATH
- configuring ossutil with your credentials
- Downloading and caching distribution of the requested [Alibaba Cloud OSSUTIL](https://github.com/aliyun/ossutil)
version, and adding it to the PATH
- Optionally configuring ossutil with the provided credential
## Usage
@@ -13,13 +15,21 @@ See [action.yml](action.yml)
```yaml
steps:
- uses: actions/checkout@v1
- uses: yizhoumo/setup-ossutil@v1
- uses: yizhoumo/setup-ossutil@v2
with:
ossutil-version: '1.6.11' # Optional, default to '1.6.11'
## The version to download and use, or 'latest' for the latest version.
ossutil-version: '1.7.18'
# The following parameters are (optionally) used to config the credential.
## The endpoint of the region in which the bucket is located.
endpoint: ${{ secrets.OSS_ENDPOINT }}
## The AccessKey ID of the credential.
access-key-id: ${{ secrets.OSS_ACCESS_KEY_ID }}
## The AccessKey Secret of the credential.
access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }}
## The STS Token of the credential. Only required for temporary access.
sts-token: ${{ secrets.OSS_STS_TOKEN }}
- run: ossutil cp -f file-to-upload.txt oss://your-bucket/path
```

View File

@@ -1,51 +1,30 @@
import * as path from 'path'
import * as io from '@actions/io'
import * as installer from '../src/installer'
const TOOL_DIR = path.join(__dirname, 'runner', 'tools')
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.6.11', async () => {
const version = '1.6.11'
await installer.getOssutil(version)
const versions = ['1.7.15', 'latest']
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)
it.each(versions)('install ossutil %s', async version => {
await installer.installOssutil(version)
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)
})
})

View File

@@ -1,26 +1,34 @@
name: 'Setup OSSUTIL environment'
description: 'Download and config Alibaba Cloud OSSUTIL'
author: 'Rimo'
inputs:
ossutil-version:
description: 'The OSSUTIL version to download and use'
required: false
default: '1.6.11'
endpoint:
description: 'The endpoint of your bucket'
required: true
access-key-id:
description: 'The AccessKeyID of the credentials'
required: true
access-key-secret:
description: 'The AccessKeySecret of the credentials'
required: true
sts-token:
description: 'The STS Token of the credentials'
required: false
runs:
using: 'node12'
main: 'dist/index.js'
# Add your action's branding here. This will appear on the GitHub Marketplace.
branding:
icon: 'download-cloud'
color: 'orange'
# Define your inputs here.
inputs:
ossutil-version:
description: 'The OSSUTIL version to download and use, or "latest" for the latest version.'
required: true
default: '1.7.18'
endpoint:
description: 'The endpoint of the region in which the bucket is located.'
required: false
access-key-id:
description: 'The AccessKey ID of the credential.'
required: false
access-key-secret:
description: 'The AccessKey Secret of the credential.'
required: false
sts-token:
description: 'The STS Token of the credential. Only required for STS temporary access credential.'
required: false
# Define your outputs here.
outputs: {}
runs:
using: node20
main: dist/index.js

30216
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

175
dist/licenses.txt generated vendored Normal file
View File

@@ -0,0 +1,175 @@
@actions/core
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/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
Actions Http Client for Node.js
Copyright (c) GitHub, Inc.
All rights reserved.
MIT License
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/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.
@fastify/busboy
MIT
Copyright Brian White. All rights reserved.
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
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
tunnel
MIT
The MIT License (MIT)
Copyright (c) 2012 Koichi Kobayashi
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.
undici
MIT
MIT License
Copyright (c) Matteo Collina and Undici 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:
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.
uuid
MIT
The MIT License (MIT)
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:
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.

View File

@@ -1,11 +0,0 @@
module.exports = {
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
transform: {
'^.+\\.ts$': 'ts-jest'
},
verbose: true
}

12219
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,46 +1,91 @@
{
"name": "setup-ossutil",
"version": "1.0.0",
"description": "Set up your GitHub Actions workflow with a specific version of ossutil.",
"version": "2.0.0",
"author": "Rimo",
"private": true,
"description": "setup ossutil action",
"main": "lib/setup-ossutil.js",
"scripts": {
"build": "tsc",
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
"lint": "eslint src/**/*.ts",
"pack": "ncc build",
"test": "jest",
"all": "npm run build && npm run format && npm run lint && npm run pack && npm test"
},
"homepage": "https://github.com/yizhoumo/setup-ossutil",
"repository": {
"type": "git",
"url": "git+https://github.com/yizhoumo/setup-ossutil.git"
},
"bugs": {
"url": "https://github.com/yizhoumo/setup-ossutil/issues"
},
"keywords": [
"actions",
"ossutil",
"setup"
],
"author": "Rimo",
"exports": {
".": "./dist/index.js"
},
"engines": {
"node": ">=20"
},
"scripts": {
"bundle": "npm run format:write && npm run package",
"ci-test": "jest",
"coverage": "make-coverage-badge --output-path ./badges/coverage.svg",
"format:write": "prettier --write **/*.ts",
"format:check": "prettier --check **/*.ts",
"lint": "npx eslint . -c ./.github/linters/.eslintrc.yml",
"package": "ncc build src/index.ts --license licenses.txt",
"package:watch": "npm run package -- --watch",
"test": "jest",
"all": "npm run format:write && npm run lint && npm run test && npm run coverage && npm run package"
},
"license": "MIT",
"jest": {
"preset": "ts-jest",
"verbose": true,
"clearMocks": true,
"testEnvironment": "node",
"moduleFileExtensions": [
"js",
"ts"
],
"testMatch": [
"**/*.test.ts"
],
"testPathIgnorePatterns": [
"/node_modules/",
"/dist/"
],
"transform": {
"^.+\\.ts$": "ts-jest"
},
"coverageReporters": [
"json-summary",
"text",
"lcov"
],
"collectCoverage": true,
"collectCoverageFrom": [
"./src/**"
]
},
"dependencies": {
"@actions/core": "^1.2.0",
"@actions/tool-cache": "^1.3.0"
"@actions/core": "^1.10.1",
"@actions/http-client": "^2.2.0",
"@actions/tool-cache": "^2.0.1"
},
"devDependencies": {
"@types/jest": "^24.0.23",
"@types/node": "^12.7.12",
"@typescript-eslint/parser": "^2.8.0",
"@zeit/ncc": "^0.20.5",
"eslint": "^5.16.0",
"eslint-plugin-github": "^2.0.0",
"eslint-plugin-jest": "^22.21.0",
"jest": "^24.9.0",
"jest-circus": "^24.9.0",
"js-yaml": "^3.13.1",
"prettier": "^1.19.1",
"ts-jest": "^24.2.0",
"typescript": "^3.6.4"
"@types/jest": "^29.5.11",
"@types/node": "^20.11.5",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"@vercel/ncc": "^0.38.1",
"eslint": "^8.56.0",
"eslint-plugin-github": "^4.10.1",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-jsonc": "^2.12.2",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.7.0",
"make-coverage-badge": "^1.2.0",
"prettier": "^3.2.4",
"prettier-eslint": "^16.3.0",
"ts-jest": "^29.1.1",
"typescript": "^5.3.3"
}
}

47
script/release Executable file
View File

@@ -0,0 +1,47 @@
#!/bin/bash
# About:
# This is a helper script to tag and push a new release.
# GitHub Actions use release tags to allow users to select a specific version of the action to use.
# This script will do the following:
# 1. Get the latest release tag
# 2. Prompt the user for a new release tag (while displaying the latest release tag, and a regex to validate the new tag)
# 3. Tag the new release
# 4. Push the new tag to the remote
# Usage:
# script/release
# COLORS
OFF='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
# if the latest_tag is empty, then there are no tags - let the user know
if [[ -z "$latest_tag" ]]; then
echo -e "No tags found (yet) - continue to create your first tag and push it"
latest_tag="[unknown]"
fi
echo -e "The latest release tag is: ${BLUE}${latest_tag}${OFF}"
read -r -p 'New Release Tag (vX.X.X format): ' new_tag
tag_regex='v[0-9]+\.[0-9]+\.[0-9]+$'
if echo "$new_tag" | grep -q -E "$tag_regex"; then
echo -e "Tag: ${BLUE}$new_tag${OFF} is valid"
else
echo -e "Tag: ${BLUE}$new_tag${OFF} is ${RED}not valid${OFF} (must be in vX.X.X format)"
exit 1
fi
git tag -a "$new_tag" -m "$new_tag Release"
echo -e "${GREEN}OK${OFF} - Tagged: $new_tag"
git push --tags
echo -e "${GREEN}OK${OFF} - Tags pushed to remote!"
echo -e "${GREEN}DONE${OFF}"

7
src/index.ts Normal file
View File

@@ -0,0 +1,7 @@
/**
* The entrypoint for the action.
*/
import { run } from './main'
// eslint-disable-next-line @typescript-eslint/no-floating-promises
run()

View File

@@ -1,80 +1,154 @@
import * as core from '@actions/core'
import * as io from '@actions/io'
import * as tc from '@actions/tool-cache'
import * as path from 'path'
import * as fs from 'fs'
import * as path from 'path'
import { HttpClient } from '@actions/http-client'
const TOOL_NAME = 'ossutil'
const ToolName = 'ossutil'
const DownloadEndpoint = 'https://gosspublic.alicdn.com/ossutil'
const IS_WINDOWS = process.platform === 'win32'
/**
* Get ossutil ready for use
* Install ossutil to PATH
* @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)
export async function installOssutil(version: string): Promise<void> {
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
const zipFileName = getZipFileName(version)
let downloadedFile: string
try {
const downloadUrl = getDownloadUrl(version)
const downloadUrl = `${DownloadEndpoint}/${version}/${zipFileName}.zip`
core.info(`Downloading ossutil from: ${downloadUrl}`)
downloadFile = await tc.downloadTool(downloadUrl)
downloadedFile = 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.info(`ossutil downloaded to: ${downloadedFile}`)
// 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}`)
// extract
const zipFile = `${downloadedFile}.zip`
await io.mv(downloadedFile, zipFile)
const extractFolder = await tc.extractZip(zipFile)
const toolFileName = getToolFileName()
const toolFile = path.join(extractFolder, zipFileName, toolFileName)
if (fs.existsSync(toolFile)) {
core.info(`ossutil extracted to: ${toolFile}`)
} else {
throw new Error('Unrecognized zip file structure')
}
// 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)
core.debug(`ossutil cached to: ${toolPath}`)
const cacheFileName = IS_WINDOWS ? `${ToolName}.exe` : ToolName
const toolPath = await tc.cacheFile(
toolFile,
cacheFileName,
ToolName,
version
)
core.info(`ossutil installed to: ${toolPath}`)
return toolPath
}
/**
* Get the URL of the specific version of ossutil
* Get the zip file name of the specific version of ossutil
* @param version the version of ossutil to download
* @returns the URL
* @returns the zip file name (e.g., ossutil-v1.7.19-linux-amd64)
*/
function getDownloadUrl(version: string): string {
let downloadUrl = `http://gosspublic.alicdn.com/ossutil/${version}/`
function getZipFileName(version: string): string {
let platform = ''
switch (process.platform) {
case 'linux':
downloadUrl += 'ossutil64'
platform = 'linux'
break
case 'win32':
downloadUrl += 'ossutil64.zip'
platform = 'windows'
break
case 'darwin':
downloadUrl += 'ossutilmac64'
platform = 'mac'
break
default:
throw new Error(`Unknown platform ${process.platform}`)
throw new Error(`Unsupported platform: ${process.platform}`)
}
return downloadUrl
let arch = ''
switch (process.arch) {
case 'arm64':
arch = 'arm64'
break
case 'x64':
arch = 'amd64'
break
default:
throw new Error(`Unsupported arch: ${process.arch}`)
}
return `ossutil-v${version}-${platform}-${arch}`
}
/**
* Get the file name of ossutil
* @returns the file name (e.g., ossutil64)
*/
function getToolFileName(): string {
let filename = 'ossutil'
switch (process.platform) {
case 'linux':
filename += '64'
break
case 'win32':
filename += '64.exe'
break
case 'darwin':
filename += 'mac64'
break
default:
throw new Error(`Unsupported platform: ${process.platform}`)
}
return filename
}
/**
* Get the latest version of ossutil
* @returns the latest version
*/
async function getLatestVersion(): Promise<string> {
const http = new HttpClient('setup-ossutil', [], {
allowRetries: true,
maxRetries: 5
})
const versionFileUrl = `${DownloadEndpoint}/version.txt`
const response = await http.get(versionFileUrl)
const content = await response.readBody()
const versionFilePrefix = 'ossutil version: v'
if (content.startsWith(versionFilePrefix)) {
return content.substring(versionFilePrefix.length).trim()
} else {
throw new Error(`Unrecognized version file content: ${content}`)
}
}

54
src/main.ts Normal file
View File

@@ -0,0 +1,54 @@
import * as core from '@actions/core'
import * as exec from '@actions/exec'
import * as installer from './installer'
/**
* The main function for the action.
* @returns {Promise<void>} Resolves when the action is complete.
*/
export async function run(): Promise<void> {
try {
await install()
await config()
} catch (error) {
// Fail the workflow run if an error occurs
if (error instanceof Error) core.setFailed(error.message)
}
}
async function install(): Promise<void> {
const version = core.getInput('ossutil-version', { required: true })
await installer.installOssutil(version)
core.info('ossutil is successfully installed')
}
async function config(): Promise<void> {
const endpoint = core.getInput('endpoint')
if (endpoint.length === 0) {
core.info('ossutil config is skipped')
return
}
const accessKeyId = core.getInput('access-key-id', { required: true })
const accessKeySecret = core.getInput('access-key-secret', { required: true })
const args = [
'config',
'--endpoint',
endpoint,
'--access-key-id',
accessKeyId,
'--access-key-secret',
accessKeySecret
]
const stsToken = core.getInput('sts-token')
if (stsToken) {
args.push('--sts-token', stsToken)
}
const exitCode = await exec.exec('ossutil', args)
if (exitCode === 0) {
core.info('ossutil config is done')
} else {
core.error(`ossutil config is failed with exit code: ${exitCode}`)
}
}

View File

@@ -1,39 +0,0 @@
import * as core from '@actions/core'
import * as exec from '@actions/exec'
import * as installer from './installer'
async function run(): Promise<void> {
try {
// download
const version = core.getInput('ossutil-version')
await installer.getOssutil(version)
core.info('ossutil is successfully installed')
// config
const inputOptions: core.InputOptions = {required: true}
const endpoint = core.getInput('endpoint', inputOptions)
const accessKeyId = core.getInput('access-key-id', inputOptions)
const accessKeySecret = core.getInput('access-key-secret', inputOptions)
const stsToken = core.getInput('sts-token')
const args = [
'config',
'--endpoint',
endpoint,
'--access-key-id',
accessKeyId,
'--access-key-secret',
accessKeySecret
]
if (stsToken) {
args.push('--sts-token', stsToken)
}
const exitCode = await exec.exec('ossutil', args)
if (exitCode === 0) {
core.info('ossutil config is done')
}
} catch (error) {
core.setFailed(error.message)
}
}
run()

View File

@@ -1,12 +1,19 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"outDir": "./lib", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"target": "ES2022",
"module": "NodeNext",
"rootDir": "./src",
"moduleResolution": "NodeNext",
"baseUrl": "./",
"sourceMap": true,
"outDir": "./dist",
"noImplicitAny": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"newLine": "lf"
},
"exclude": ["node_modules", "**/*.test.ts"]
"exclude": ["./dist", "./node_modules", "./__tests__", "./coverage"]
}