Merge pull request #192 from crazy-max/fix-dl

check latest and tagged releases using releases-json
This commit is contained in:
CrazyMax authored and GitHub committed 2023-01-29 16:06:38 +01:00
commit 76c12355bd
6 files changed
+51 -37

No files matched your search

-16
View File
@@ -1,16 +0,0 @@
import {describe, expect, it} from '@jest/globals';
import * as github from '../src/github';
describe('github', () => {
it('returns latest UPX GitHub release', async () => {
const release = await github.getRelease('latest');
expect(release).not.toBeNull();
expect(release?.tag_name).not.toEqual('');
});
it('returns v3.96 GoReleaser GitHub release', async () => {
const release = await github.getRelease('v3.96');
expect(release).not.toBeNull();
expect(release?.tag_name).toEqual('v3.96');
});
});
+24
View File
@@ -2,6 +2,30 @@ import {describe, expect, it} from '@jest/globals';
import * as fs from 'fs';
import * as installer from '../src/installer';
describe('getRelease', () => {
it('returns latest UPX GitHub release', async () => {
const release = await installer.getRelease('latest');
expect(release).not.toBeNull();
expect(release?.tag_name).not.toEqual('');
});
it('returns v3.95 UPX GitHub release', async () => {
const release = await installer.getRelease('v3.95');
expect(release).not.toBeNull();
expect(release?.id).toEqual(12577195);
expect(release?.tag_name).toEqual('v3.95');
expect(release?.html_url).toEqual('https://github.com/upx/upx/releases/tag/v3.95');
});
it('unknown release', async () => {
await expect(installer.getRelease('foo')).rejects.toThrowError(
new Error(
'Cannot find UPX release foo in https://raw.githubusercontent.com/crazy-max/ghaction-upx/master/.github/upx-releases.json'
)
);
});
});
describe('installer', () => {
it('acquires v3.95 version of UPX', async () => {
const upx = await installer.getUPX('v3.95');
Generated Vendored
+1 -1
View File
@@ -1,2 +1,2 @@
require('./sourcemap-register.js');(()=>{var e={7351:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;Object.defineProperty(e,n,{enumerable:true,get:function(){return t[r]}})}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(r!=="default"&&Object.hasOwnProperty.call(e,r))n(t,e,r);i(t,e);return t};Object.defineProperty(t,"__esModule",{value:true});t.issue=t.issueCommand=void 0;const s=o(r(2037));const a=r(5278);function issueCommand(e,t,r){const n=new Command(e,t,r);process.stdout.write(n.toString()+s.EOL)}t.issueCommand=issueCommand;function issue(e,t=""){issueCommand(e,{},t)}t.issue=issue;const c="::";class Command{constructor(e,t,r){if(!e){e="missing.command"}this.command=e;this.properties=t;this.message=r}toString(){let e=c+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";let t=true;for(const r in this.properties){if(this.properties.hasOwnProperty(r)){const n=this.properties[r];if(n){if(t){t=false}else{e+=","}e+=`${r}=${escapeProperty(n)}`}}}}e+=`${c}${escapeData(this.message)}`;return e}}function escapeData(e){return a.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escapeProperty(e){return a.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}},2186:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;Object.defineProperty(e,n,{enumerable:true,get:function(){return t[r]}})}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(r!=="default"&&Object.hasOwnProperty.call(e,r))n(t,e,r);i(t,e);return t};var s=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:true});t.getIDToken=t.getState=t.saveState=t.group=t.endGroup=t.startGroup=t.info=t.notice=t.warning=t.error=t.debug=t.isDebug=t.setFailed=t.setCommandEcho=t.setOutput=t.getBooleanInput=t.getMultilineInput=t.getInput=t.addPath=t.setSecret=t.exportVariable=t.ExitCode=void 0;const a=r(7351);const c=r(717);const u=r(5278);const l=o(r(2037));const h=o(r(1017));const d=r(8041);var p;(function(e){e[e["Success"]=0]="Success";e[e["Failure"]=1]="Failure"})(p=t.ExitCode||(t.ExitCode={}));function exportVariable(e,t){const r=u.toCommandValue(t);process.env[e]=r;const n=process.env["GITHUB_ENV"]||"";if(n){return c.issueFileCommand("ENV",c.prepareKeyValueMessage(e,t))}a.issueCommand("set-env",{name:e},r)}t.exportVariable=exportVariable;function setSecret(e){a.issueCommand("add-mask",{},e)}t.setSecret=setSecret;function addPath(e){const t=process.env["GITHUB_PATH"]||"";if(t){c.issueFileCommand("PATH",e)}else{a.issueCommand("add-path",{},e)}process.env["PATH"]=`${e}${h.delimiter}${process.env["PATH"]}`}t.addPath=addPath;function getInput(e,t){const r=process.env[`INPUT_${e.replace(/ /g,"_").toUpperCase()}`]||"";if(t&&t.required&&!r){throw new Error(`Input required and not supplied: ${e}`)}if(t&&t.trimWhitespace===false){return r}return r.trim()}t.getInput=getInput;function getMultilineInput(e,t){const r=getInput(e,t).split("\n").filter((e=>e!==""));if(t&&t.trimWhitespace===false){return r}return r.map((e=>e.trim()))}t.getMultilineInput=getMultilineInput;function getBooleanInput(e,t){const r=["true","True","TRUE"];const n=["false","False","FALSE"];const i=getInput(e,t);if(r.includes(i))return true;if(n.includes(i))return false;throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${e}\n`+`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``)}t.getBooleanInput=getBooleanInput;function setOutput(e,t){const r=process.env["GITHUB_OUTPUT"]||"";if(r){return c.issueFileCommand("OUTPUT",c.prepareKeyValueMessage(e,t))}process.stdout.write(l.EOL);a.issueCommand("set-output",{name:e},u.toCommandValue(t))}t.setOutput=setOutput;function setCommandEcho(e){a.issue("echo",e?"on":"off")}t.setCommandEcho=setCommandEcho;function setFailed(e){process.exitCode=p.Failure;error(e)}t.setFailed=setFailed;function isDebug(){return process.env["RUNNER_DEBUG"]==="1"}t.isDebug=isDebug;functiLine truncated
require('./sourcemap-register.js');(()=>{var e={7351:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;Object.defineProperty(e,n,{enumerable:true,get:function(){return t[r]}})}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(r!=="default"&&Object.hasOwnProperty.call(e,r))n(t,e,r);i(t,e);return t};Object.defineProperty(t,"__esModule",{value:true});t.issue=t.issueCommand=void 0;const s=o(r(2037));const a=r(5278);function issueCommand(e,t,r){const n=new Command(e,t,r);process.stdout.write(n.toString()+s.EOL)}t.issueCommand=issueCommand;function issue(e,t=""){issueCommand(e,{},t)}t.issue=issue;const c="::";class Command{constructor(e,t,r){if(!e){e="missing.command"}this.command=e;this.properties=t;this.message=r}toString(){let e=c+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";let t=true;for(const r in this.properties){if(this.properties.hasOwnProperty(r)){const n=this.properties[r];if(n){if(t){t=false}else{e+=","}e+=`${r}=${escapeProperty(n)}`}}}}e+=`${c}${escapeData(this.message)}`;return e}}function escapeData(e){return a.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escapeProperty(e){return a.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}},2186:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;Object.defineProperty(e,n,{enumerable:true,get:function(){return t[r]}})}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(r!=="default"&&Object.hasOwnProperty.call(e,r))n(t,e,r);i(t,e);return t};var s=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:true});t.getIDToken=t.getState=t.saveState=t.group=t.endGroup=t.startGroup=t.info=t.notice=t.warning=t.error=t.debug=t.isDebug=t.setFailed=t.setCommandEcho=t.setOutput=t.getBooleanInput=t.getMultilineInput=t.getInput=t.addPath=t.setSecret=t.exportVariable=t.ExitCode=void 0;const a=r(7351);const c=r(717);const u=r(5278);const l=o(r(2037));const h=o(r(1017));const d=r(8041);var p;(function(e){e[e["Success"]=0]="Success";e[e["Failure"]=1]="Failure"})(p=t.ExitCode||(t.ExitCode={}));function exportVariable(e,t){const r=u.toCommandValue(t);process.env[e]=r;const n=process.env["GITHUB_ENV"]||"";if(n){return c.issueFileCommand("ENV",c.prepareKeyValueMessage(e,t))}a.issueCommand("set-env",{name:e},r)}t.exportVariable=exportVariable;function setSecret(e){a.issueCommand("add-mask",{},e)}t.setSecret=setSecret;function addPath(e){const t=process.env["GITHUB_PATH"]||"";if(t){c.issueFileCommand("PATH",e)}else{a.issueCommand("add-path",{},e)}process.env["PATH"]=`${e}${h.delimiter}${process.env["PATH"]}`}t.addPath=addPath;function getInput(e,t){const r=process.env[`INPUT_${e.replace(/ /g,"_").toUpperCase()}`]||"";if(t&&t.required&&!r){throw new Error(`Input required and not supplied: ${e}`)}if(t&&t.trimWhitespace===false){return r}return r.trim()}t.getInput=getInput;function getMultilineInput(e,t){const r=getInput(e,t).split("\n").filter((e=>e!==""));if(t&&t.trimWhitespace===false){return r}return r.map((e=>e.trim()))}t.getMultilineInput=getMultilineInput;function getBooleanInput(e,t){const r=["true","True","TRUE"];const n=["false","False","FALSE"];const i=getInput(e,t);if(r.includes(i))return true;if(n.includes(i))return false;throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${e}\n`+`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``)}t.getBooleanInput=getBooleanInput;function setOutput(e,t){const r=process.env["GITHUB_OUTPUT"]||"";if(r){return c.issueFileCommand("OUTPUT",c.prepareKeyValueMessage(e,t))}process.stdout.write(l.EOL);a.issueCommand("set-output",{name:e},u.toCommandValue(t))}t.setOutput=setOutput;function setCommandEcho(e){a.issue("echo",e?"on":"off")}t.setCommandEcho=setCommandEcho;function setFailed(e){process.exitCode=p.Failure;error(e)}t.setFailed=setFailed;function isDebug(){return process.env["RUNNER_DEBUG"]==="1"}t.isDebug=isDebug;functiLine truncated
//# sourceMappingURL=index.js.map
Generated Vendored
+1 -1
View File
@@ -1 +1 @@
{"version":3,"sources":["../webpack:/upx-github-action/node_modules/@actions/core/lib/command.js","../webpack:/upx-github-action/node_modules/@actions/core/lib/core.js","../webpack:/upx-github-action/node_modules/@actions/core/lib/file-command.js","../webpack:/upx-github-action/node_modules/@actions/core/lib/oidc-utils.js","../webpack:/upx-github-action/node_modules/@actions/core/lib/path-utils.js","../webpack:/upx-github-action/node_modules/@actions/core/lib/summary.js","../webpack:/upx-github-action/node_modules/@actions/core/lib/utils.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/index.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/md5.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/nil.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/parse.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/regex.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/rng.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/sha1.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/stringify.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/v1.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/v3.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/v35.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/v4.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/v5.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/validate.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/version.js","../webpack:/upx-github-action/node_modules/@actions/exec/lib/exec.js","../webpack:/upx-github-action/node_modules/@actions/exec/lib/toolrunner.js","../webpack:/upx-github-action/node_modules/@actions/http-client/lib/auth.js","../webpack:/upx-github-action/node_modules/@actions/http-client/lib/index.js","../webpack:/upx-github-action/node_modules/@actions/http-client/lib/proxy.js","../webpack:/upx-github-action/node_modules/@actions/io/lib/io-util.js","../webpack:/upx-github-action/node_modules/@actions/io/lib/io.js","../webpack:/upx-github-action/node_modules/@actions/tool-cache/lib/manifest.js","../webpack:/upx-github-action/node_modules/@actions/tool-cache/lib/retry-helper.js","../webpack:/upx-github-action/node_modules/@actions/tool-cache/lib/tool-cache.js","../webpack:/upx-github-action/node_modules/balanced-match/index.js","../webpack:/upx-github-action/node_modules/brace-expansion/index.js","../webpack:/upx-github-action/node_modules/concat-map/index.js","../webpack:/upx-github-action/node_modules/fs.realpath/index.js","../webpack:/upx-github-action/node_modules/fs.realpath/old.js","../webpack:/upx-github-action/node_modules/glob/common.js","../webpack:/upx-github-action/node_modules/glob/glob.js","../webpack:/upx-github-action/node_modules/glob/sync.js","../webpack:/upx-github-action/node_modules/inflight/inflight.js","../webpack:/upx-github-action/node_modules/inherits/inherits.js","../webpack:/upx-github-action/node_modules/inherits/inherits_browser.js","../webpack:/upx-github-action/node_modules/minimatch/minimatch.js","../webpack:/upx-github-action/node_modules/once/once.js","../webpack:/upx-github-action/node_modules/path-is-absolute/index.js","../webpack:/upx-github-action/node_modules/semver/semver.js","../webpack:/upx-github-action/node_modules/tunnel/index.js","../webpack:/upx-github-action/node_modules/tunnel/lib/tunnel.js","../webpack:/upx-github-action/node_modules/uuid/lib/bytesToUuid.js","../webpack:/upx-github-action/node_modules/uuid/lib/rng.js","../webpack:/upx-github-action/node_modules/uuid/v4.js","../webpack:/upx-github-action/node_modules/wrappy/wrappy.js","../webpack:/upx-github-action/src/context.ts","../webpack:/upx-github-action/src/github.ts","../webpack:/upx-github-action/src/installer.ts","../webpack:/upx-github-action/src/main.ts","../webpack:/upx-github-action/external node-commonjs \"assert\"","../webpack:/upx-github-action/external node-commonjs \"child_process\"","../webpack:/upx-github-action/external node-commonjs \"crypto\"","../webpack:/upx-github-action/external node-commonjs \"events\"","../webpack:/upx-github-action/external node-commonjs \"fs\"","../webpack:/upx-github-action/external node-commonjs \"http\"","../webpack:/upx-github-action/external node-commonjs \"https\"","../webpack:/upx-github-action/external node-commonjs \"net\"","../webpack:/upx-github-action/external node-commonjs \"os\"","../webpack:/upx-github-action/external node-commonjs \"path\"","../webpack:/upx-github-action/external node-commonjs \"stream\"","../webpack:/upx-github-action/external node-commonjs \"string_decoder\""Line truncated
{"version":3,"sources":["../webpack:/upx-github-action/node_modules/@actions/core/lib/command.js","../webpack:/upx-github-action/node_modules/@actions/core/lib/core.js","../webpack:/upx-github-action/node_modules/@actions/core/lib/file-command.js","../webpack:/upx-github-action/node_modules/@actions/core/lib/oidc-utils.js","../webpack:/upx-github-action/node_modules/@actions/core/lib/path-utils.js","../webpack:/upx-github-action/node_modules/@actions/core/lib/summary.js","../webpack:/upx-github-action/node_modules/@actions/core/lib/utils.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/index.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/md5.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/nil.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/parse.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/regex.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/rng.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/sha1.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/stringify.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/v1.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/v3.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/v35.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/v4.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/v5.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/validate.js","../webpack:/upx-github-action/node_modules/@actions/core/node_modules/uuid/dist/version.js","../webpack:/upx-github-action/node_modules/@actions/exec/lib/exec.js","../webpack:/upx-github-action/node_modules/@actions/exec/lib/toolrunner.js","../webpack:/upx-github-action/node_modules/@actions/http-client/lib/auth.js","../webpack:/upx-github-action/node_modules/@actions/http-client/lib/index.js","../webpack:/upx-github-action/node_modules/@actions/http-client/lib/proxy.js","../webpack:/upx-github-action/node_modules/@actions/io/lib/io-util.js","../webpack:/upx-github-action/node_modules/@actions/io/lib/io.js","../webpack:/upx-github-action/node_modules/@actions/tool-cache/lib/manifest.js","../webpack:/upx-github-action/node_modules/@actions/tool-cache/lib/retry-helper.js","../webpack:/upx-github-action/node_modules/@actions/tool-cache/lib/tool-cache.js","../webpack:/upx-github-action/node_modules/balanced-match/index.js","../webpack:/upx-github-action/node_modules/brace-expansion/index.js","../webpack:/upx-github-action/node_modules/concat-map/index.js","../webpack:/upx-github-action/node_modules/fs.realpath/index.js","../webpack:/upx-github-action/node_modules/fs.realpath/old.js","../webpack:/upx-github-action/node_modules/glob/common.js","../webpack:/upx-github-action/node_modules/glob/glob.js","../webpack:/upx-github-action/node_modules/glob/sync.js","../webpack:/upx-github-action/node_modules/inflight/inflight.js","../webpack:/upx-github-action/node_modules/inherits/inherits.js","../webpack:/upx-github-action/node_modules/inherits/inherits_browser.js","../webpack:/upx-github-action/node_modules/minimatch/minimatch.js","../webpack:/upx-github-action/node_modules/once/once.js","../webpack:/upx-github-action/node_modules/path-is-absolute/index.js","../webpack:/upx-github-action/node_modules/semver/semver.js","../webpack:/upx-github-action/node_modules/tunnel/index.js","../webpack:/upx-github-action/node_modules/tunnel/lib/tunnel.js","../webpack:/upx-github-action/node_modules/uuid/lib/bytesToUuid.js","../webpack:/upx-github-action/node_modules/uuid/lib/rng.js","../webpack:/upx-github-action/node_modules/uuid/v4.js","../webpack:/upx-github-action/node_modules/wrappy/wrappy.js","../webpack:/upx-github-action/src/context.ts","../webpack:/upx-github-action/src/installer.ts","../webpack:/upx-github-action/src/main.ts","../webpack:/upx-github-action/external node-commonjs \"assert\"","../webpack:/upx-github-action/external node-commonjs \"child_process\"","../webpack:/upx-github-action/external node-commonjs \"crypto\"","../webpack:/upx-github-action/external node-commonjs \"events\"","../webpack:/upx-github-action/external node-commonjs \"fs\"","../webpack:/upx-github-action/external node-commonjs \"http\"","../webpack:/upx-github-action/external node-commonjs \"https\"","../webpack:/upx-github-action/external node-commonjs \"net\"","../webpack:/upx-github-action/external node-commonjs \"os\"","../webpack:/upx-github-action/external node-commonjs \"path\"","../webpack:/upx-github-action/external node-commonjs \"stream\"","../webpack:/upx-github-action/external node-commonjs \"string_decoder\"","../webpack:/upx-github-action/external node-Line truncated
-12
View File
@@ -1,12 +0,0 @@
import * as httpm from '@actions/http-client';
export interface GitHubRelease {
id: number;
tag_name: string;
}
export const getRelease = async (version: string): Promise<GitHubRelease | null> => {
const url = `https://github.com/upx/upx/releases/${version}`;
const http: httpm.HttpClient = new httpm.HttpClient('ghaction-upx');
return (await http.getJson<GitHubRelease>(url)).result;
};
+25 -7
View File
@@ -1,22 +1,40 @@
import * as os from 'os';
import * as path from 'path';
import * as util from 'util';
import * as github from './github';
import * as core from '@actions/core';
import * as httpm from '@actions/http-client';
import * as tc from '@actions/tool-cache';
const osPlat: string = os.platform();
const osArch: string = os.arch();
export async function getUPX(version: string): Promise<string> {
core.startGroup(`Checking UPX ${version} release...`);
const release: github.GitHubRelease | null = await github.getRelease(version);
if (!release) {
throw new Error(`Cannot find UPX ${version} release`);
export interface GitHubRelease {
id: number;
tag_name: string;
html_url: string;
assets: Array<string>;
}
export const getRelease = async (version: string): Promise<GitHubRelease> => {
const url = `https://raw.githubusercontent.com/crazy-max/ghaction-upx/master/.github/upx-releases.json`;
const http: httpm.HttpClient = new httpm.HttpClient('ghaction-upx');
const resp: httpm.HttpClientResponse = await http.get(url);
const body = await resp.readBody();
const statusCode = resp.message.statusCode || 500;
if (statusCode >= 400) {
throw new Error(`Failed to get UPX release ${version} from ${url} with status code ${statusCode}: ${body}`);
}
const releases = <Record<string, GitHubRelease>>JSON.parse(body);
if (!releases[version]) {
throw new Error(`Cannot find UPX release ${version} in ${url}`);
}
return releases[version];
};
export async function getUPX(version: string): Promise<string> {
const release: GitHubRelease = await getRelease(version);
const semver: string = release.tag_name.replace(/^v/, '');
core.info(`UPX ${semver} found`);
core.endGroup();
const filename = util.format('%s.%s', getName(semver), osPlat == 'win32' ? 'zip' : 'tar.xz');
const downloadUrl = util.format('https://github.com/upx/upx/releases/download/v%s/%s', semver, filename);