-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.js
47 lines (37 loc) · 1.29 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* eslint require-atomic-updates: off */
const {defaultTo, castArray} = require('lodash');
const verifyGitea = require('./lib/verify');
const addChannelGitea = require('./lib/add-channel');
const publishGitea = require('./lib/publish');
let verified;
async function verifyConditions(pluginConfig, context) {
const {options} = context;
// If the Gitea publish plugin is used and has `assets`, `labels` or `assignees` configured, validate it now in order to prevent any release if the configuration is wrong
if (options.publish) {
const publishPlugin =
castArray(options.publish).find(
(config) => config.path && config.path === '@saithodev/semantic-release-gitea'
) || {};
pluginConfig.assets = defaultTo(
pluginConfig.assets,
publishPlugin.assets
);
}
await verifyGitea(pluginConfig, context);
verified = true;
}
async function publish(pluginConfig, context) {
if (!verified) {
await verifyGitea(pluginConfig, context);
verified = true;
}
return publishGitea(pluginConfig, context);
}
async function addChannel(pluginConfig, context) {
if (!verified) {
await verifyGitea(pluginConfig, context);
verified = true;
}
return addChannelGitea(pluginConfig, context);
}
module.exports = {verifyConditions, addChannel, publish};