Skip to content

Commit f169bcc

Browse files
committed
ci: configure publishing github releases
1 parent 20f4265 commit f169bcc

File tree

6 files changed

+17
-14
lines changed

6 files changed

+17
-14
lines changed
Binary file not shown.

packages/ci-github-release/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"conventional-changelog": "^6",
2525
"conventional-changelog-conventionalcommits": "^8",
2626
"git-semver-tags": "^8",
27-
"semver": "^7",
28-
"semver-regex": "^4"
27+
"semver": "^7"
2928
}
3029
}

packages/ci-github-release/src/github-release.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export async function githubRelease<
5555
const octokit = new Octokit({ auth: auth.token });
5656

5757
changelogOpts = {
58-
transform,
58+
transform: transform.bind(null, changelogOpts.tagPrefix ?? "v") as any,
5959
releaseCount: 1,
6060
...changelogOpts,
6161
};
@@ -106,7 +106,7 @@ export async function githubRelease<
106106
const options = {
107107
owner,
108108
repo: repository,
109-
tag_name: version,
109+
tag_name: chunk.keyCommit["tag"],
110110
name: version,
111111
body: chunk.log,
112112
draft: false,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export function semverRegex(prefix = "v") {
2+
return new RegExp(
3+
`(?<=^${prefix}?|\\s${prefix}?)(?:(?:0|[1-9]\\d{0,9}?)\\.){2}(?:0|[1-9]\\d{0,9})(?:-(?:--+)?(?:0|[1-9]\\d*|\\d*[a-z]+\\d*)){0,100}(?=$| |\\+|\\.)(?:(?<=-\\S+)(?:\\.(?:--?|[\\da-z-]*[a-z]\\d*|0|[1-9]\\d*)){1,100}?)?(?!\\.)(?:\\+(?:[\\da-z]\\.?-?){1,100}?(?!\\w))?(?!\\+)`,
4+
"gi",
5+
);
6+
}

packages/ci-github-release/src/transform.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import type { Commit } from "conventional-commits-parser";
22
import type { Options } from "conventional-changelog-core";
3-
import semverRegex from "semver-regex";
3+
import { semverRegex } from "./semverRegex.js";
44

55
export function transform<T extends Commit = Commit>(
6+
prefix: string,
67
chunk: Commit,
78
cb: Options.Transform.Callback<T>,
89
) {
910
chunk = { ...chunk };
1011

1112
const gitTags = chunk["gitTags"];
1213
if (typeof gitTags === "string") {
13-
chunk["version"] = (gitTags.match(semverRegex()) || [])[0];
14+
const tag = /tag:\s([^,)]+)/gi.exec(gitTags)?.[1];
15+
16+
if (tag) {
17+
chunk["tag"] = tag;
18+
chunk["version"] = (tag.match(semverRegex(prefix)) || [])[0];
19+
}
1420
}
1521

1622
if (chunk["committerDate"]) {

yarn.lock

-8
Original file line numberDiff line numberDiff line change
@@ -3287,7 +3287,6 @@ __metadata:
32873287
conventional-changelog-conventionalcommits: "npm:^8"
32883288
git-semver-tags: "npm:^8"
32893289
semver: "npm:^7"
3290-
semver-regex: "npm:^4"
32913290
typescript: "npm:^5"
32923291
languageName: unknown
32933292
linkType: soft
@@ -8786,13 +8785,6 @@ __metadata:
87868785
languageName: node
87878786
linkType: hard
87888787

8789-
"semver-regex@npm:^4":
8790-
version: 4.0.5
8791-
resolution: "semver-regex@npm:4.0.5"
8792-
checksum: 10c0/c270eda133691dfaab90318df995e96222e4c26c47b17f7c8bd5e5fe88b81ed67b59695fe27546e0314b0f0423c7faed1f93379ad9db47c816df2ddf770918ff
8793-
languageName: node
8794-
linkType: hard
8795-
87968788
"semver@npm:^5.6.0":
87978789
version: 5.7.2
87988790
resolution: "semver@npm:5.7.2"

0 commit comments

Comments
 (0)