Skip to content

Commit

Permalink
ci: configure publishing github releases
Browse files Browse the repository at this point in the history
  • Loading branch information
Wroud committed Sep 9, 2024
1 parent 20f4265 commit f169bcc
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
Binary file not shown.
3 changes: 1 addition & 2 deletions packages/ci-github-release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"conventional-changelog": "^6",
"conventional-changelog-conventionalcommits": "^8",
"git-semver-tags": "^8",
"semver": "^7",
"semver-regex": "^4"
"semver": "^7"
}
}
4 changes: 2 additions & 2 deletions packages/ci-github-release/src/github-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function githubRelease<
const octokit = new Octokit({ auth: auth.token });

changelogOpts = {
transform,
transform: transform.bind(null, changelogOpts.tagPrefix ?? "v") as any,
releaseCount: 1,
...changelogOpts,
};
Expand Down Expand Up @@ -106,7 +106,7 @@ export async function githubRelease<
const options = {
owner,
repo: repository,
tag_name: version,
tag_name: chunk.keyCommit["tag"],
name: version,
body: chunk.log,
draft: false,
Expand Down
6 changes: 6 additions & 0 deletions packages/ci-github-release/src/semverRegex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export function semverRegex(prefix = "v") {
return new RegExp(
`(?<=^${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))?(?!\\+)`,
"gi",
);
}
10 changes: 8 additions & 2 deletions packages/ci-github-release/src/transform.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import type { Commit } from "conventional-commits-parser";
import type { Options } from "conventional-changelog-core";
import semverRegex from "semver-regex";
import { semverRegex } from "./semverRegex.js";

export function transform<T extends Commit = Commit>(
prefix: string,
chunk: Commit,
cb: Options.Transform.Callback<T>,
) {
chunk = { ...chunk };

const gitTags = chunk["gitTags"];
if (typeof gitTags === "string") {
chunk["version"] = (gitTags.match(semverRegex()) || [])[0];
const tag = /tag:\s([^,)]+)/gi.exec(gitTags)?.[1];

if (tag) {
chunk["tag"] = tag;
chunk["version"] = (tag.match(semverRegex(prefix)) || [])[0];
}
}

if (chunk["committerDate"]) {
Expand Down
8 changes: 0 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3287,7 +3287,6 @@ __metadata:
conventional-changelog-conventionalcommits: "npm:^8"
git-semver-tags: "npm:^8"
semver: "npm:^7"
semver-regex: "npm:^4"
typescript: "npm:^5"
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -8786,13 +8785,6 @@ __metadata:
languageName: node
linkType: hard

"semver-regex@npm:^4":
version: 4.0.5
resolution: "semver-regex@npm:4.0.5"
checksum: 10c0/c270eda133691dfaab90318df995e96222e4c26c47b17f7c8bd5e5fe88b81ed67b59695fe27546e0314b0f0423c7faed1f93379ad9db47c816df2ddf770918ff
languageName: node
linkType: hard

"semver@npm:^5.6.0":
version: 5.7.2
resolution: "semver@npm:5.7.2"
Expand Down

0 comments on commit f169bcc

Please sign in to comment.