semantic-release-major-tag
Version:
Create and update major version tags during release
36 lines (35 loc) • 1.54 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_child_process_1 = require("node:child_process");
const prepareTags_1 = __importDefault(require("../helpers/prepareTags"));
const skipForPrerelease_1 = __importDefault(require("../helpers/skipForPrerelease"));
const preparePluginConfig_1 = __importDefault(require("../helpers/preparePluginConfig"));
const success = (pluginConfigBare, context) => {
const { options, nextRelease, logger, branch } = context;
// Prepare config with defaults
const pluginConfig = (0, preparePluginConfig_1.default)(pluginConfigBare);
if ((0, skipForPrerelease_1.default)(branch, pluginConfig)) {
logger.info('Not publishing any tags on a prerelease!');
return;
}
if (!options) {
logger.error('Missing options from context!');
return;
}
if (!nextRelease) {
logger.error('Missing nextRelease from context!');
return;
}
const { repositoryUrl } = options;
const { version } = nextRelease;
const newTags = (0, prepareTags_1.default)(version, pluginConfig);
for (const tag of newTags) {
logger.info(`Pushing version tag '${tag}' to git.`);
(0, node_child_process_1.execSync)(`git tag --force ${tag}`);
}
(0, node_child_process_1.execSync)(`git push ${repositoryUrl} --force --tags`);
};
exports.default = success;