Skip to content

Commit

Permalink
fix(version): create release when using custom tag-version-separator (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
briananstett committed Apr 1, 2024
1 parent 0cbf857 commit cbe01ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 5 additions & 1 deletion libs/commands/version/src/index.ts
Expand Up @@ -389,7 +389,11 @@ class VersionCommand extends Command {
tasks.push(() =>
createRelease(
this.releaseClient,
{ tags: this.tags, releaseNotes: this.releaseNotes },
{
tags: this.tags,
tagVersionSeparator: this.options.tagVersionSeparator || "@",
releaseNotes: this.releaseNotes,
},
{ gitRemote: this.options.gitRemote, execOpts: this.execOpts }
)
);
Expand Down
11 changes: 8 additions & 3 deletions libs/commands/version/src/lib/create-release.ts
Expand Up @@ -16,21 +16,26 @@ export function createReleaseClient(type: "github" | "gitlab") {

export function createRelease(
client: ReturnType<typeof createReleaseClient>,
{ tags, releaseNotes }: { tags: string[]; releaseNotes: { name: string; notes: string }[] },
{
tags,
releaseNotes,
tagVersionSeparator,
}: { tags: string[]; tagVersionSeparator: string; releaseNotes: { name: string; notes: string }[] },
{ gitRemote, execOpts }: { gitRemote: string; execOpts: ExecOptions }
) {
const repo = parseGitRepo(gitRemote, execOpts);

return Promise.all(
releaseNotes.map(({ notes, name }) => {
const tag = name === "fixed" ? tags[0] : tags.find((t) => t.startsWith(`${name}@`));
const tag =
name === "fixed" ? tags[0] : tags.find((t) => t.startsWith(`${name}${tagVersionSeparator}`));

/* istanbul ignore if */
if (!tag) {
return Promise.resolve();
}

const prereleaseParts = semver.prerelease(tag.replace(`${name}@`, "")) || [];
const prereleaseParts = semver.prerelease(tag.replace(`${name}${tagVersionSeparator}`, "")) || [];

return client.repos.createRelease({
owner: repo.owner,
Expand Down

0 comments on commit cbe01ba

Please sign in to comment.