Skip to content

Commit cb57c05

Browse files
committed
feat: add option to publish to CI catalog
1 parent dcd0ab5 commit cb57c05

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/publish.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ export default async (pluginConfig, context) => {
2222
nextRelease: { gitTag, gitHead, notes, version },
2323
logger,
2424
} = context;
25-
const { gitlabToken, gitlabUrl, gitlabApiUrl, assets, milestones, proxy, retryLimit } = resolveConfig(
26-
pluginConfig,
27-
context
28-
);
25+
const { gitlabToken, gitlabUrl, gitlabApiUrl, assets, milestones, proxy, retryLimit, publishToCatalog } =
26+
resolveConfig(pluginConfig, context);
2927
const assetsList = [];
3028
const { projectPath, projectApiUrl } = getProjectContext(context, gitlabUrl, gitlabApiUrl, repositoryUrl);
3129

@@ -201,5 +199,17 @@ export default async (pluginConfig, context) => {
201199

202200
const releaseUrl = urlJoin(gitlabUrl, projectPath, `/-/releases/${encodedGitTag}`);
203201

202+
if (publishToCatalog) {
203+
try {
204+
await execa("glab", ["repo", "publish", "catalog", gitTag], {
205+
cwd,
206+
timeout: 30 * 1000,
207+
});
208+
} catch (error) {
209+
logger.error("An error occurred while publish tag %s to the CI catalog:\n%O", error);
210+
throw error;
211+
}
212+
}
213+
204214
return { name: RELEASE_NAME, url: releaseUrl };
205215
};

lib/resolve-config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default (
1616
labels,
1717
assignee,
1818
retryLimit,
19+
publishToCatalog,
1920
},
2021
{
2122
envCi: { service } = {},
@@ -67,6 +68,7 @@ export default (
6768
labels: isNil(labels) ? "semantic-release" : labels === false ? false : labels,
6869
assignee,
6970
retryLimit: retryLimit ?? DEFAULT_RETRY_LIMIT,
71+
publishToCatalog: publishToCatalog ?? false,
7072
};
7173
};
7274

0 commit comments

Comments
 (0)