26 Commits

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
38 changed files with 28077 additions and 7505 deletions

View File

@@ -1,4 +1,4 @@
dist/
lib/
dist/
node_modules/
jest.config.js
coverage/

View File

@@ -1,55 +0,0 @@
{
"plugins": ["jest", "@typescript-eslint"],
"extends": ["plugin:github/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"i18n-text/no-en": "off",
"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-comment": "error",
"camelcase": "off",
"@typescript-eslint/consistent-type-assertions": "error",
"@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-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-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
}
}

2
.gitattributes vendored
View File

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

View File

@@ -1,6 +0,0 @@
name: "CodeQL config"
queries:
- uses: security-extended
- uses: security-and-quality
paths:
- src

View File

@@ -3,9 +3,24 @@ updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
interval: weekly
groups:
actions-minor:
update-types:
- minor
- patch
- package-ecosystem: npm
directory: /
schedule:
interval: daily
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"]
}

View File

@@ -1,53 +1,64 @@
# `dist/index.js` is a special file in Actions.
# When you reference an action with `uses:` in a workflow,
# `index.js` is the code that will run.
# For our project, we generate this file through a build process from other source files.
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
name: Check dist/
# 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:
- master
paths-ignore:
- '**.md'
- main
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:
permissions:
contents: read
jobs:
check-dist:
name: Check dist/
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Set Node.js 16.x
uses: actions/setup-node@v2.5.1
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version: 16.x
node-version-file: .node-version
cache: npm
- name: Install dependencies
- name: Install Dependencies
id: install
run: npm ci
- name: Rebuild the dist/ directory
run: |
npm run build
npm run package
- name: Build dist/ Directory
id: build
run: npm run bundle
- name: Compare the expected and actual dist/ directories
# 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 dist/ | wc -l)" -gt "0" ]; then
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
git diff --ignore-space-at-eol --text dist/
exit 1
fi
id: diff
# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v2
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
# 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

View File

@@ -1,73 +0,0 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ "master" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
schedule:
- cron: '25 23 * * 6'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'TypeScript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

View File

@@ -1,20 +0,0 @@
# Dependency Review Action
#
# This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging.
#
# Source repository: https://github.com/actions/dependency-review-action
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
name: 'Dependency Review'
on: [pull_request]
permissions:
contents: read
jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v3
- name: 'Dependency Review'
uses: actions/dependency-review-action@v2

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
jobs:
build: # make sure build/ci work properly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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@v3
- 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 > /dev/null
shell: bash

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,7 +4,13 @@
"useTabs": false,
"semi": false,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid"
"bracketSpacing": true,
"bracketSameLine": true,
"arrowParens": "avoid",
"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.7.0' # Optional, default to 'latest'
## 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,13 +1,12 @@
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 io from '@actions/io'
import * as installer from '../src/installer'
jest.setTimeout(60000)
describe('installer tests', () => {
@@ -21,15 +20,11 @@ describe('installer tests', () => {
await io.rmRF(TEMP_DIR)
})
const versions = ['1.7.0', 'latest']
const versions = ['1.7.15', 'latest']
it.each(versions)('install ossutil %s', async version => {
await installer.getOssutil(version)
await installer.installOssutil(version)
expect(await io.which('ossutil', true)).toBeTruthy()
})
it('throw if wrong version', async () => {
await expect(installer.getOssutil('1000.0.0')).rejects.toThrowError()
})
})

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: 'latest'
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: 'node16'
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

24643
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

1
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

47
dist/licenses.txt generated vendored
View File

@@ -71,6 +71,28 @@ The above copyright notice and this permission notice shall be included in all c
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
@@ -115,6 +137,31 @@ 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)

1
dist/sourcemap-register.js generated vendored

File diff suppressed because one or more lines are too long

View File

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

9788
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,45 +1,91 @@
{
"name": "setup-ossutil",
"version": "1.1.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",
"package": "ncc build --source-map --license licenses.txt",
"test": "jest",
"all": "npm run build && npm run format && npm run lint && npm run package && 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.6.0",
"@actions/core": "^1.10.1",
"@actions/http-client": "^2.2.0",
"@actions/tool-cache": "^2.0.1"
},
"devDependencies": {
"@types/jest": "^27.0.0",
"@types/node": "^16.10.5",
"@typescript-eslint/parser": "^5.8.1",
"@vercel/ncc": "^0.31.1",
"eslint": "^8.0.1",
"eslint-plugin-github": "^4.3.2",
"eslint-plugin-jest": "^25.3.2",
"jest": "^27.2.5",
"js-yaml": "^4.1.0",
"prettier": "2.5.1",
"ts-jest": "^27.1.2",
"typescript": "^4.4.4"
"@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,17 +1,19 @@
import * as core from '@actions/core'
import * as io from '@actions/io'
import * as tc from '@actions/tool-cache'
import * as fs from 'fs'
import * as path from 'path'
import { HttpClient } from '@actions/http-client'
const ToolName = 'ossutil'
const UpdateEndpoint =
'https://ossutil-version-update.oss-cn-hangzhou.aliyuncs.com'
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> {
export async function installOssutil(version: string): Promise<void> {
if (version.toLowerCase() === 'latest') {
version = await getLatestVersion()
core.info(`Using the latest version of ossutil: ${version}`)
@@ -32,49 +34,102 @@ export async function getOssutil(version: string): Promise<void> {
*/
async function downloadOssutil(version: string): Promise<string> {
// download
let toolFile: 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}`)
toolFile = await tc.downloadTool(downloadUrl)
downloadedFile = await tc.downloadTool(downloadUrl)
} catch (error) {
core.error('Failed to download ossutil')
throw error
}
core.debug(`ossutil downloaded to: ${toolFile}`)
core.info(`ossutil downloaded to: ${downloadedFile}`)
// 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' ? `${ToolName}.exe` : ToolName
const toolPath = await tc.cacheFile(toolFile, fileName, ToolName, 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 = `${UpdateEndpoint}/${version}/`
function getZipFileName(version: string): string {
let platform = ''
switch (process.platform) {
case 'linux':
downloadUrl += 'ossutil64'
platform = 'linux'
break
case 'win32':
downloadUrl += 'ossutil64.exe'
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
}
/**
@@ -82,8 +137,18 @@ function getDownloadUrl(version: string): string {
* @returns the latest version
*/
async function getLatestVersion(): Promise<string> {
const http = new HttpClient()
const response = await http.get(`${UpdateEndpoint}/ossutilversion`)
const http = new HttpClient('setup-ossutil', [], {
allowRetries: true,
maxRetries: 5
})
const versionFileUrl = `${DownloadEndpoint}/version.txt`
const response = await http.get(versionFileUrl)
const content = await response.readBody()
return content.trim()
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,41 +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) {
if (error instanceof 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"]
}