mirror of
https://github.com/goreleaser/goreleaser-action
synced 2026-06-30 01:37:29 +00:00
feat: support downloading goreleaser pro (#284)
This commit is contained in:
committed by
GitHub
parent
a3b2f49e7c
commit
70eb4e573c
+45
-15
@@ -190,23 +190,30 @@ exports.getRelease = void 0;
|
||||
const httpm = __importStar(__webpack_require__(925));
|
||||
const core = __importStar(__webpack_require__(186));
|
||||
const semver = __importStar(__webpack_require__(911));
|
||||
exports.getRelease = (version) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const resolvedVersion = (yield resolveVersion(version)) || version;
|
||||
const url = `https://github.com/goreleaser/goreleaser/releases/${resolvedVersion}`;
|
||||
const pro = __importStar(__webpack_require__(989));
|
||||
exports.getRelease = (distribution, version) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const resolvedVersion = (yield resolveVersion(distribution, version)) || version;
|
||||
const url = `https://github.com/goreleaser/${distribution}/releases/${resolvedVersion}`;
|
||||
const http = new httpm.HttpClient('goreleaser-action');
|
||||
return (yield http.getJson(url)).result;
|
||||
});
|
||||
const resolveVersion = (version) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const allTags = yield getAllTags();
|
||||
const resolveVersion = (distribution, version) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const allTags = yield getAllTags(distribution);
|
||||
if (!allTags) {
|
||||
throw new Error(`Cannot find GoReleaser tags`);
|
||||
}
|
||||
core.debug(`Found ${allTags.length} tags in total`);
|
||||
return semver.maxSatisfying(allTags, version);
|
||||
if (version === 'latest' || !pro.isPro(distribution)) {
|
||||
return semver.maxSatisfying(allTags, version);
|
||||
}
|
||||
const cleanTags = allTags.map(tag => cleanTag(tag));
|
||||
const cleanVersion = cleanTag(version);
|
||||
return semver.maxSatisfying(cleanTags, cleanVersion) + pro.suffix(distribution);
|
||||
});
|
||||
const getAllTags = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const getAllTags = (distribution) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const http = new httpm.HttpClient('goreleaser-action');
|
||||
const url = `https://goreleaser.com/static/releases.json`;
|
||||
const suffix = pro.suffix(distribution);
|
||||
const url = `https://goreleaser.com/static/releases${suffix}.json`;
|
||||
const getTags = http.getJson(url);
|
||||
return getTags.then(response => {
|
||||
if (response.result == null) {
|
||||
@@ -215,6 +222,9 @@ const getAllTags = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
return response.result.map(obj => obj.tag_name);
|
||||
});
|
||||
});
|
||||
const cleanTag = (tag) => {
|
||||
return tag.replace(/-pro$/, '');
|
||||
};
|
||||
//# sourceMappingURL=github.js.map
|
||||
|
||||
/***/ }),
|
||||
@@ -258,19 +268,20 @@ const os = __importStar(__webpack_require__(87));
|
||||
const path = __importStar(__webpack_require__(622));
|
||||
const util = __importStar(__webpack_require__(669));
|
||||
const github = __importStar(__webpack_require__(928));
|
||||
const pro = __importStar(__webpack_require__(989));
|
||||
const core = __importStar(__webpack_require__(186));
|
||||
const tc = __importStar(__webpack_require__(784));
|
||||
const osPlat = os.platform();
|
||||
const osArch = os.arch();
|
||||
function getGoReleaser(version) {
|
||||
function getGoReleaser(distribution, version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const release = yield github.getRelease(version);
|
||||
const release = yield github.getRelease(distribution, version);
|
||||
if (!release) {
|
||||
throw new Error(`Cannot find GoReleaser ${version} release`);
|
||||
}
|
||||
core.info(`✅ GoReleaser version found: ${release.tag_name}`);
|
||||
const filename = getFilename();
|
||||
const downloadUrl = util.format('https://github.com/goreleaser/goreleaser/releases/download/%s/%s', release.tag_name, filename);
|
||||
const filename = getFilename(distribution);
|
||||
const downloadUrl = util.format('https://github.com/goreleaser/%s/releases/download/%s/%s', distribution, release.tag_name, filename);
|
||||
core.info(`⬇️ Downloading ${downloadUrl}...`);
|
||||
const downloadPath = yield tc.downloadTool(downloadUrl);
|
||||
core.debug(`Downloaded to ${downloadPath}`);
|
||||
@@ -291,11 +302,12 @@ function getGoReleaser(version) {
|
||||
});
|
||||
}
|
||||
exports.getGoReleaser = getGoReleaser;
|
||||
const getFilename = () => {
|
||||
const getFilename = (distribution) => {
|
||||
const platform = osPlat == 'win32' ? 'Windows' : osPlat == 'darwin' ? 'Darwin' : 'Linux';
|
||||
const arch = osArch == 'x64' ? 'x86_64' : 'i386';
|
||||
const ext = osPlat == 'win32' ? 'zip' : 'tar.gz';
|
||||
return util.format('goreleaser_%s_%s.%s', platform, arch, ext);
|
||||
const suffix = pro.suffix(distribution);
|
||||
return util.format('goreleaser%s_%s_%s.%s', suffix, platform, arch, ext);
|
||||
};
|
||||
//# sourceMappingURL=installer.js.map
|
||||
|
||||
@@ -343,11 +355,12 @@ const path_1 = __webpack_require__(622);
|
||||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const distribution = core.getInput('distribution') || 'goreleaser';
|
||||
const version = core.getInput('version') || 'latest';
|
||||
const args = core.getInput('args');
|
||||
const workdir = core.getInput('workdir') || '.';
|
||||
const isInstallOnly = /^true$/i.test(core.getInput('install-only'));
|
||||
const goreleaser = yield installer.getGoReleaser(version);
|
||||
const goreleaser = yield installer.getGoReleaser(distribution, version);
|
||||
core.info(`✅ GoReleaser installed successfully`);
|
||||
if (isInstallOnly) {
|
||||
const goreleaserDir = path_1.dirname(goreleaser);
|
||||
@@ -393,6 +406,23 @@ run();
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 989:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.isPro = exports.suffix = void 0;
|
||||
exports.suffix = (distribution) => {
|
||||
return exports.isPro(distribution) ? '-pro' : '';
|
||||
};
|
||||
exports.isPro = (distribution) => {
|
||||
return distribution === 'goreleaser-pro';
|
||||
};
|
||||
//# sourceMappingURL=pro.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 241:
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user