"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = checkLatestTag;
const request_1 = require("./request");
const releaseFilter = /^v\d+\.\d+\.\d+$/;
async function checkLatestTag(repo, prefixFilter) {
    const data = await (0, request_1.getJSON)(`https://api.github.com/repos/${repo}/tags`);
    if (!Array.isArray(data)) {
        return '';
    }
    let tags = data.map(t => t.name);
    if (prefixFilter) {
        tags = tags
            .filter(t => t.match(prefixFilter))
            .map(t => t.replace(prefixFilter, ''));
    }
    tags = tags
        .filter(t => t.match(releaseFilter));
    return tags.length > 0
        ? tags[0].replace(/^v/, '')
        : '';
}
//# sourceMappingURL=checktag.js.map