Upload source
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
# Editor configuration, see https://editorconfig.org
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.{js, ts}]
|
||||||
|
indent_size = 4
|
||||||
|
quote_type = single
|
||||||
|
ij_javascript_use_double_quotes = false
|
||||||
|
ij_typescript_use_double_quotes = false
|
||||||
|
ij_javascript_import_sort_members = true
|
||||||
|
ij_javascript_import_sort_module_name = true
|
||||||
|
ij_typescript_import_sort_members = true
|
||||||
|
ij_typescript_import_sort_module_name = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
max_line_length = off
|
||||||
|
trim_trailing_whitespace = false
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
env:
|
||||||
|
node: true
|
||||||
|
jest: true
|
||||||
|
es2021: true
|
||||||
|
extends:
|
||||||
|
- eslint:recommended
|
||||||
|
- plugin:@typescript-eslint/eslint-recommended
|
||||||
|
- plugin:@typescript-eslint/recommended
|
||||||
|
- plugin:import/errors
|
||||||
|
- plugin:import/warnings
|
||||||
|
- plugin:import/typescript
|
||||||
|
parser: '@typescript-eslint/parser'
|
||||||
|
parserOptions:
|
||||||
|
ecmaVersion: 12
|
||||||
|
sourceType: module
|
||||||
|
plugins:
|
||||||
|
- '@typescript-eslint'
|
||||||
|
- jest
|
||||||
|
ignorePatterns:
|
||||||
|
- node_modules
|
||||||
|
- action
|
||||||
|
rules:
|
||||||
+53
@@ -21,6 +21,7 @@ lib-cov
|
|||||||
# Coverage directory used by tools like istanbul
|
# Coverage directory used by tools like istanbul
|
||||||
coverage
|
coverage
|
||||||
*.lcov
|
*.lcov
|
||||||
|
/coverage
|
||||||
|
|
||||||
# nyc test coverage
|
# nyc test coverage
|
||||||
.nyc_output
|
.nyc_output
|
||||||
@@ -37,9 +38,20 @@ bower_components
|
|||||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
build/Release
|
build/Release
|
||||||
|
|
||||||
|
# production
|
||||||
|
/build
|
||||||
|
|
||||||
# Dependency directories
|
# Dependency directories
|
||||||
node_modules/
|
node_modules/
|
||||||
|
/node_modules
|
||||||
jspm_packages/
|
jspm_packages/
|
||||||
|
/.pnp
|
||||||
|
.pnp.js
|
||||||
|
|
||||||
|
# Node lock file
|
||||||
|
package-lock.json
|
||||||
|
yarn.lock
|
||||||
|
pnpm-lock.yaml
|
||||||
|
|
||||||
# TypeScript v1 declaration files
|
# TypeScript v1 declaration files
|
||||||
typings/
|
typings/
|
||||||
@@ -102,3 +114,44 @@ dist
|
|||||||
|
|
||||||
# TernJS port file
|
# TernJS port file
|
||||||
.tern-port
|
.tern-port
|
||||||
|
|
||||||
|
# Only exists if Bazel was run
|
||||||
|
/bazel-out
|
||||||
|
|
||||||
|
# profiling files
|
||||||
|
chrome-profiler-events.json
|
||||||
|
speed-measure-plugin.json
|
||||||
|
|
||||||
|
# IDEs and editors
|
||||||
|
/.idea
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.c9/
|
||||||
|
*.launch
|
||||||
|
.settings/
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
|
# IDE - VSCode
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.history/*
|
||||||
|
|
||||||
|
# misc
|
||||||
|
/.sass-cache
|
||||||
|
/connect.lock
|
||||||
|
/libpeerconnection.log
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
testem.log
|
||||||
|
/typings
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
|
||||||
|
# System Files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
# get-release
|
# get-release
|
||||||
GitHub Action to get release assets
|
|
||||||
|
GitHub Action to get release
|
||||||
|
|||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
name: Get Release
|
||||||
|
description: Get a release by tag, latest or current release
|
||||||
|
author: Giao Ho
|
||||||
|
inputs:
|
||||||
|
tag_name:
|
||||||
|
description: Specify tag instead of using checkout tag.
|
||||||
|
required: false
|
||||||
|
latest:
|
||||||
|
description: Should get latest release?
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
runs:
|
||||||
|
using: node12
|
||||||
|
main: action/index.js
|
||||||
|
branding:
|
||||||
|
icon: tag
|
||||||
|
color: blue
|
||||||
+6201
File diff suppressed because one or more lines are too long
@@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"name": "get-release",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"scripts": {
|
||||||
|
"build": "npm run clean && tsc --project tsconfig.json",
|
||||||
|
"release": "ncc build src/get-release.ts -o action && git add -f action/",
|
||||||
|
"clean": "rimraf -- action",
|
||||||
|
"lint": "eslint **/*.ts"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"actions",
|
||||||
|
"github",
|
||||||
|
"release",
|
||||||
|
"get"
|
||||||
|
],
|
||||||
|
"author": {
|
||||||
|
"name": "Giao Ho",
|
||||||
|
"email": "[email protected]",
|
||||||
|
"url": "https://github.com/joutvhu"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"homepage": "https://github.com/joutvhu/get-release#readme",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/joutvhu/get-release.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/joutvhu/get-release/issues"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/core": "^1.2.6",
|
||||||
|
"@actions/exec": "^1.0.4",
|
||||||
|
"@actions/github": "^4.0.0",
|
||||||
|
"@actions/http-client": "^1.0.11",
|
||||||
|
"tslib": "^2.1.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@octokit/types": "^6.13.0",
|
||||||
|
"@tsconfig/recommended": "^1.0.1",
|
||||||
|
"@types/node": "^14.14.37",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^4.20.0",
|
||||||
|
"@typescript-eslint/parser": "^4.20.0",
|
||||||
|
"@vercel/ncc": "^0.27.0",
|
||||||
|
"eslint": "^7.23.0",
|
||||||
|
"eslint-plugin-import": "^2.22.1",
|
||||||
|
"eslint-plugin-jest": "^24.3.2",
|
||||||
|
"eslint-plugin-node": "^11.1.0",
|
||||||
|
"eslint-plugin-prettier": "^3.3.1",
|
||||||
|
"eslint-plugin-promise": "^4.3.1",
|
||||||
|
"jest": "^26.6.3",
|
||||||
|
"prettier": "^2.2.1",
|
||||||
|
"rimraf": "^3.0.2",
|
||||||
|
"typescript": "^4.2.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
export enum Inputs {
|
||||||
|
TagName = 'tag_name',
|
||||||
|
Latest = 'latest'
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum Outputs {
|
||||||
|
ID = 'id',
|
||||||
|
Url = 'url',
|
||||||
|
HtmlUrl = 'html_url',
|
||||||
|
AssetsUrl = 'assets_url',
|
||||||
|
UploadUrl = 'upload_url',
|
||||||
|
TagName = 'tag_name',
|
||||||
|
Name = 'name',
|
||||||
|
Body = 'body',
|
||||||
|
Draft = 'draft',
|
||||||
|
PreRelease = 'prerelease'
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import * as core from '@actions/core';
|
||||||
|
import {context} from '@actions/github';
|
||||||
|
import {GitHub} from '@actions/github/lib/utils';
|
||||||
|
import {getInputs, ReleaseInputs, setOutputs} from './io-helper';
|
||||||
|
|
||||||
|
(async function run() {
|
||||||
|
try {
|
||||||
|
const inputs: ReleaseInputs = getInputs();
|
||||||
|
// @ts-ignore
|
||||||
|
const github = new GitHub(process.env.GITHUB_TOKEN);
|
||||||
|
// Get owner and repo from context of payload that triggered the action
|
||||||
|
const {owner, repo} = context.repo;
|
||||||
|
|
||||||
|
|
||||||
|
if (!inputs.latest) {
|
||||||
|
// Get a release from the tag name
|
||||||
|
const releaseResponse = await github.repos
|
||||||
|
.getReleaseByTag({owner, repo, tag: inputs.tag});
|
||||||
|
|
||||||
|
core.setOutput('debug', releaseResponse);
|
||||||
|
setOutputs(releaseResponse);
|
||||||
|
} else {
|
||||||
|
const listResponse = await github.repos.listReleases({owner, repo});
|
||||||
|
listResponse.data.find(release => release.tag_name);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
core.setFailed(err.message);
|
||||||
|
}
|
||||||
|
})();
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import * as core from '@actions/core';
|
||||||
|
import {context} from '@actions/github';
|
||||||
|
import {OctokitResponse} from '@octokit/types';
|
||||||
|
import {Inputs, Outputs} from './constants';
|
||||||
|
|
||||||
|
export interface ReleaseInputs {
|
||||||
|
tag: string;
|
||||||
|
|
||||||
|
latest: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper to get all the inputs for the action
|
||||||
|
*/
|
||||||
|
export function getInputs(): ReleaseInputs {
|
||||||
|
const result: ReleaseInputs | any = {
|
||||||
|
latest: false
|
||||||
|
};
|
||||||
|
|
||||||
|
const tag = core.getInput(Inputs.TagName, {required: false});
|
||||||
|
if (tag == null || tag.length === 0) {
|
||||||
|
result.tag = context.ref.replace('refs/tags/', '');
|
||||||
|
|
||||||
|
const latest = core.getInput(Inputs.Latest, {required: false});
|
||||||
|
if (latest != null && latest.length > 0 &&
|
||||||
|
!['n', 'no', 'f', 'false', '0'].includes(latest.toLowerCase()))
|
||||||
|
result.latest = true;
|
||||||
|
} else result.tag = tag;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setOutputs(outputs: OctokitResponse<any>) {
|
||||||
|
// Get the outputs for the created release from the response
|
||||||
|
const {
|
||||||
|
data: {
|
||||||
|
id,
|
||||||
|
url,
|
||||||
|
html_url,
|
||||||
|
upload_url,
|
||||||
|
assets_url,
|
||||||
|
name,
|
||||||
|
tag_name,
|
||||||
|
body,
|
||||||
|
draft,
|
||||||
|
prerelease
|
||||||
|
}
|
||||||
|
} = outputs;
|
||||||
|
|
||||||
|
core.setOutput(Outputs.ID, id.toString());
|
||||||
|
core.setOutput(Outputs.Url, url);
|
||||||
|
core.setOutput(Outputs.HtmlUrl, html_url);
|
||||||
|
core.setOutput(Outputs.UploadUrl, upload_url);
|
||||||
|
core.setOutput(Outputs.AssetsUrl, assets_url);
|
||||||
|
core.setOutput(Outputs.TagName, tag_name);
|
||||||
|
core.setOutput(Outputs.Name, name);
|
||||||
|
core.setOutput(Outputs.Body, body);
|
||||||
|
core.setOutput(Outputs.Draft, draft);
|
||||||
|
core.setOutput(Outputs.PreRelease, prerelease);
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"extends": "@tsconfig/recommended/tsconfig.json",
|
||||||
|
"compileOnSave": false,
|
||||||
|
"compilerOptions": {
|
||||||
|
"baseUrl": ".",
|
||||||
|
"rootDir": "./src",
|
||||||
|
"outDir": "./lib",
|
||||||
|
"strict": true,
|
||||||
|
"declaration": false,
|
||||||
|
"alwaysStrict": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"removeComments": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"strictNullChecks": true,
|
||||||
|
"downlevelIteration": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"target": "es2015",
|
||||||
|
"module": "commonjs",
|
||||||
|
"lib": [
|
||||||
|
"es2016",
|
||||||
|
"es2017",
|
||||||
|
"es2018",
|
||||||
|
"esnext"
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"./src/**/*"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"./node_modules",
|
||||||
|
"src/**/*.spec.ts",
|
||||||
|
"src/**/*.test.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user