Skip to content

Commit

Permalink
Build
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrisbin committed Dec 2, 2024
1 parent 08d140c commit a342a0b
Showing 1 changed file with 56 additions and 132 deletions.
188 changes: 56 additions & 132 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.findReleaseAsset = findReleaseAsset;
exports.getLatestRelease = getLatestRelease;
var core = __importStar(__nccwpck_require__(7484));
var github = __importStar(__nccwpck_require__(3228));
var github_asset_url_1 = __nccwpck_require__(7100);
Expand Down Expand Up @@ -152,119 +153,58 @@ function findReleaseAsset(url, githubToken) {
});
});
}
function getLatestRelease(url, githubToken) {
return __awaiter(this, void 0, void 0, function () {
var assetUrl, owner, repo, client, data, version;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
assetUrl = (0, github_asset_url_1.toGitHubAssetUrl)(url);
if (!assetUrl) {
throw new Error("URL is not a GitHub release asset, version cannot be omitted");
}
core.info("Parsed as asset-url, ".concat(assetUrl.owner, "/").concat(assetUrl.repo, " ").concat(assetUrl.tag, " ").concat(assetUrl.name));
owner = assetUrl.owner, repo = assetUrl.repo;
core.info("URL is to a GitHub Asset in ".concat(owner, "/").concat(repo));
client = github.getOctokit(githubToken);
return [4, client.rest.repos.getLatestRelease({ owner: owner, repo: repo })];
case 1:
data = (_a.sent()).data;
version = data.tag_name;
core.debug("Latest release: ".concat(JSON.stringify(data)));
core.info("Using version: ".concat(version));
return [2, version];
}
});
});
}


/***/ }),

/***/ 6107:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
/***/ ((__unused_webpack_module, exports) => {

"use strict";

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getInputs = getInputs;
var github = __importStar(__nccwpck_require__(3228));
var github_asset_url_1 = __nccwpck_require__(7100);
function getInputs(platform, osArch, core) {
return __awaiter(this, void 0, void 0, function () {
var url, version, _a;
var _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
url = requireInput(core, specifiedInputs(platform, osArch, "url"));
if (!((_b = optionalInput(core, ["version"])) !== null && _b !== void 0)) return [3, 1];
_a = _b;
return [3, 3];
case 1: return [4, inferVersionInput(core, url)];
case 2:
_a = (_c.sent());
_c.label = 3;
case 3:
version = _a;
return [2, {
name: requireInput(core, ["name"]),
version: version,
url: url,
subdir: optionalInput(core, specifiedInputs(platform, osArch, "subdir")),
os: optionalInputDefault(core, specifiedInputs(platform, osArch, "os"), platform),
arch: optionalInputDefault(core, specifiedInputs(platform, osArch, "arch"), osArch),
ext: optionalInputDefault(core, specifiedInputs(platform, osArch, "ext"), inferExtension(platform)),
noExtract: core.getInput("no-extract", { required: false }) === "true",
githubToken: core.getInput("github-token", { required: false }),
}];
}
});
});
return {
name: requireInput(core, ["name"]),
version: optionalInput(core, ["version"]) || "",
url: requireInput(core, specifiedInputs(platform, osArch, "url")),
subdir: optionalInput(core, specifiedInputs(platform, osArch, "subdir")),
os: optionalInputDefault(core, specifiedInputs(platform, osArch, "os"), platform),
arch: optionalInputDefault(core, specifiedInputs(platform, osArch, "arch"), osArch),
ext: optionalInputDefault(core, specifiedInputs(platform, osArch, "ext"), inferExtension(platform)),
noExtract: core.getInput("no-extract", { required: false }) === "true",
githubToken: core.getInput("github-token", { required: false }),
githubTokenForLatest: requireInput(core, [
"github-token",
"github-token-for-latest",
]),
};
}
function specifiedInputs(platform, arch, input) {
return [
Expand All @@ -277,7 +217,10 @@ function specifiedInputs(platform, arch, input) {
function requireInput(core, inputs) {
var value = inputs.map(function (x) { return core.getInput(x); }).find(function (x) { return x; });
if (!value) {
throw new Error("You must supply one of ".concat(inputs, " as an input"));
var message = inputs.length === 1
? "You must supply the ".concat(inputs[0], " input")
: "You must supply one of ".concat(inputs, " as an input");
throw new Error(message);
}
return value;
}
Expand All @@ -297,33 +240,6 @@ function inferExtension(platform) {
return "tar.gz";
}
}
function inferVersionInput(core, url) {
return __awaiter(this, void 0, void 0, function () {
var assetUrl, owner, repo, token, client, data, version;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
assetUrl = (0, github_asset_url_1.toGitHubAssetUrl)(url);
if (!assetUrl) return [3, 2];
owner = assetUrl.owner, repo = assetUrl.repo;
core.info("URL is to a GitHub Asset in ".concat(owner, "/").concat(repo));
token = requireInput(core, [
"github-token",
"github-token-for-latest",
]);
client = github.getOctokit(token);
return [4, client.rest.repos.getLatestRelease({ owner: owner, repo: repo })];
case 1:
data = (_a.sent()).data;
version = data.tag_name;
core.debug("Latest release: ".concat(JSON.stringify(data)));
core.debug("Using version: ".concat(version));
return [2, version];
case 2: throw new Error("URL is not a GitHub release asset, version cannot be omitted");
}
});
});
}


/***/ }),
Expand Down Expand Up @@ -443,14 +359,22 @@ function getExtract(ext) {
}
function mkReleaseConfig(platform, osArch) {
return __awaiter(this, void 0, void 0, function () {
var _a, name, version, urlTemplate, subdirTemplate, os, arch, ext, noExtract, githubToken, templateVars, url, subdir;
var _a, name, version, urlTemplate, subdirTemplate, os, arch, ext, noExtract, githubToken, githubTokenForLatest, templateVars, url, latest, subdir;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4, (0, inputs_1.getInputs)(platform, osArch, core)];
case 1:
_a = _b.sent(), name = _a.name, version = _a.version, urlTemplate = _a.url, subdirTemplate = _a.subdir, os = _a.os, arch = _a.arch, ext = _a.ext, noExtract = _a.noExtract, githubToken = _a.githubToken;
_a = _b.sent(), name = _a.name, version = _a.version, urlTemplate = _a.url, subdirTemplate = _a.subdir, os = _a.os, arch = _a.arch, ext = _a.ext, noExtract = _a.noExtract, githubToken = _a.githubToken, githubTokenForLatest = _a.githubTokenForLatest;
templateVars = { name: name, version: version, os: os, arch: arch, ext: ext };
url = (0, interpolate_1.interpolate)(urlTemplate, templateVars);
if (!(version === "")) return [3, 3];
return [4, github.getLatestRelease(url, githubTokenForLatest)];
case 2:
latest = _b.sent();
templateVars = { name: name, version: latest, os: os, arch: arch, ext: ext };
url = (0, interpolate_1.interpolate)(urlTemplate, templateVars);
_b.label = 3;
case 3:
subdir = subdirTemplate
? (0, interpolate_1.interpolate)(subdirTemplate, templateVars)
: null;
Expand Down

0 comments on commit a342a0b

Please sign in to comment.