Compare commits
62 Commits
v1.0.0
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3713a032c6 | ||
|
|
05b8ab586b | ||
|
|
8151732169 | ||
|
|
0c7edb5265 | ||
|
|
914f86730e | ||
|
|
dd928bb78a | ||
|
|
b46896c92b | ||
|
|
207f87da14 | ||
|
|
85020be43f | ||
|
|
84bddb7f82 | ||
|
|
2115c80e82 | ||
|
|
a7826c3d9e | ||
|
|
50a593740d | ||
|
|
80f4dc3682 | ||
|
|
60c150d787 | ||
|
|
2081cee43c | ||
|
|
9dea1aac7e | ||
|
|
fdb656e148 | ||
|
|
59fe15c39c | ||
|
|
865e26ae28 | ||
|
|
27dbb86e47 | ||
|
|
4191da5daf | ||
|
|
89a583bcb4 | ||
|
|
7de480550b | ||
|
|
6666bbeb34 | ||
|
|
f0d5c67ae8 | ||
|
|
a27182c923 | ||
|
|
fe25da5c69 | ||
|
|
da0dd6f825 | ||
|
|
e3a6534c61 | ||
|
|
121c208740 | ||
|
|
1d32a34314 | ||
|
|
9dba6ec80f | ||
|
|
7771e4ad5d | ||
|
|
0677c3a661 | ||
|
|
8b71dde9cc | ||
|
|
3c902f37b8 | ||
|
|
32ae336e72 | ||
|
|
8acd1073f5 | ||
|
|
23656db23a | ||
|
|
3d11e1d509 | ||
|
|
dba3303d7a | ||
|
|
fd6fbb7c82 | ||
|
|
fdc36f3165 | ||
|
|
8cd5012746 | ||
|
|
817e6913f6 | ||
|
|
c0bdf31f7f | ||
|
|
3f8b34f4cd | ||
|
|
7730354c83 | ||
|
|
8ec4e4eac1 | ||
|
|
dcc6f1cca2 | ||
|
|
07bd03fad5 | ||
|
|
297280acad | ||
|
|
d280ef3f81 | ||
|
|
334892c424 | ||
|
|
759c72b231 | ||
|
|
eb92a3a4ec | ||
|
|
293ab80724 | ||
|
|
2b8aa63435 | ||
|
|
cb4c7704d8 | ||
|
|
9b4c67bad2 | ||
|
|
bb1421de6e |
@@ -1,3 +1,4 @@
|
||||
dist/
|
||||
lib/
|
||||
node_modules/
|
||||
dist/
|
||||
node_modules/
|
||||
coverage/
|
||||
|
||||
@@ -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
3
.gitattributes
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
* text=auto eol=lf
|
||||
|
||||
dist/** -diff linguist-generated=true
|
||||
26
.github/dependabot.yml
vendored
Normal file
26
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: github-actions
|
||||
directory: /
|
||||
schedule:
|
||||
interval: monthly
|
||||
groups:
|
||||
actions-minor:
|
||||
update-types:
|
||||
- minor
|
||||
- patch
|
||||
|
||||
- package-ecosystem: npm
|
||||
directory: /
|
||||
schedule:
|
||||
interval: monthly
|
||||
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
83
.github/linters/.eslintrc.yml
vendored
Normal 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'
|
||||
}
|
||||
9
.github/linters/tsconfig.json
vendored
Normal file
9
.github/linters/tsconfig.json
vendored
Normal 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"]
|
||||
}
|
||||
83
.github/workflows/check-dist.yml
vendored
Normal file
83
.github/workflows/check-dist.yml
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
# 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/
|
||||
|
||||
push-dist:
|
||||
name: Push dist/
|
||||
needs: check-dist
|
||||
if: ${{ failure() }}
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
- uses: actions/download-artifact@v4
|
||||
- run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git add dist
|
||||
git commit -m "Generate dist"
|
||||
git push
|
||||
69
.github/workflows/ci.yml
vendored
Normal file
69
.github/workflows/ci.yml
vendored
Normal 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
|
||||
24
.github/workflows/functional.yml
vendored
Normal file
24
.github/workflows/functional.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
name: Functional
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 2 * * 6'
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
functional:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
version: [1.7.15, latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: yizhoumo/setup-ossutil@v2
|
||||
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
|
||||
30
.github/workflows/test.yml
vendored
30
.github/workflows/test.yml
vendored
@@ -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
6
.gitignore
vendored
@@ -96,4 +96,8 @@ Thumbs.db
|
||||
|
||||
# Ignore built ts files
|
||||
__tests__/runner/*
|
||||
lib/**/*
|
||||
|
||||
# IDE files
|
||||
.idea
|
||||
.vscode
|
||||
*.code-workspace
|
||||
|
||||
1
.node-version
Normal file
1
.node-version
Normal file
@@ -0,0 +1 @@
|
||||
20.6.0
|
||||
@@ -1,3 +1,3 @@
|
||||
dist/
|
||||
lib/
|
||||
node_modules/
|
||||
node_modules/
|
||||
coverage/
|
||||
|
||||
@@ -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
13
LICENSE
@@ -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.
|
||||
24
README.md
24
README.md
@@ -1,11 +1,13 @@
|
||||
# setup-ossutil
|
||||
|
||||
[](https://github.com/yizhoumo/setup-ossutil/actions)
|
||||
[](https://github.com/yizhoumo/setup-ossutil/actions/workflows/ci.yml)
|
||||
[](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.10' # Optional
|
||||
## 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
|
||||
```
|
||||
|
||||
|
||||
@@ -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.10', async () => {
|
||||
const version = '1.6.10'
|
||||
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)
|
||||
})
|
||||
})
|
||||
|
||||
41
action.yml
41
action.yml
@@ -1,23 +1,34 @@
|
||||
name: 'Setup OSSUTIL environment'
|
||||
description: 'Download and config Alibaba Cloud OSSUTIL'
|
||||
author: 'Rimo'
|
||||
|
||||
# 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'
|
||||
required: false
|
||||
default: '1.6.10'
|
||||
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 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'
|
||||
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: 'node12'
|
||||
main: 'dist/index.js'
|
||||
using: node20
|
||||
main: dist/index.js
|
||||
|
||||
30678
dist/index.js
generated
vendored
30678
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
175
dist/licenses.txt
generated
vendored
Normal file
175
dist/licenses.txt
generated
vendored
Normal 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.
|
||||
@@ -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
|
||||
}
|
||||
12602
package-lock.json
generated
12602
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
101
package.json
101
package.json
@@ -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.1",
|
||||
"@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.12",
|
||||
"@types/node": "^20.12.7",
|
||||
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
||||
"@typescript-eslint/parser": "^6.19.0",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-plugin-github": "^4.10.2",
|
||||
"eslint-plugin-jest": "^28.5.0",
|
||||
"eslint-plugin-jsonc": "^2.15.1",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"jest": "^29.7.0",
|
||||
"make-coverage-badge": "^1.2.0",
|
||||
"prettier": "^3.2.5",
|
||||
"prettier-eslint": "^16.3.0",
|
||||
"ts-jest": "^29.1.1",
|
||||
"typescript": "^5.4.5"
|
||||
}
|
||||
}
|
||||
|
||||
47
script/release
Executable file
47
script/release
Executable 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
7
src/index.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* The entrypoint for the action.
|
||||
*/
|
||||
import { run } from './main'
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
run()
|
||||
148
src/installer.ts
148
src/installer.ts
@@ -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
54
src/main.ts
Normal 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}`)
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
@@ -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"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user