Repository: semantic-release/github (js)

Issue:
Improvement of prerelease check
As of https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md?plain=1#L91 the property prerelease can be used to configure a prerelease. If you set this property to false the prerelease is still created if the other conditions are met. With this PR you can set prerelease to false and no prerelease is created.

Fix: https://github.com/semantic-release/github/pull/863

Pull request description:
feat: use branch prerelease property for detection
For the description have a look into the issue: https://github.com/semantic-release/github/issues/864

For a showcase have a look at the video provided by @babblebey in the comment: https://github.com/semantic-release/github/pull/863#issuecomment-2192578725 

Fixes #864 

Patch:
diff --git a/lib/is-prerelease.js b/lib/is-prerelease.js
index 6eb91c1..c04a7ba 100644
--- a/lib/is-prerelease.js
+++ b/lib/is-prerelease.js
@@ -1,3 +1,11 @@
-export default function isPrerelease({ type, main }) {
-  return type === "prerelease" || (type === "release" && !main);
+export default function isPrerelease({ type, main, prerelease }) {
+  if (prerelease === false) {
+    return false;
+  }
+  return (
+    type === "prerelease" ||
+    (type === "release" && !main) ||
+    typeof prerelease == "string" ||
+    prerelease === true
+  );
 }


Test patch:
diff --git a/test/is-prerelease.test.js b/test/is-prerelease.test.js
new file mode 100644
index 0000000..8c2c60f
--- /dev/null
+++ b/test/is-prerelease.test.js
@@ -0,0 +1,52 @@
+import test from "ava";
+import isPrerelease from "../lib/is-prerelease.js";
+
+test("Test for empty object", (t) => {
+  const branch = {};
+  t.is(isPrerelease(branch), false);
+});
+
+test("Test if prerelease true property as boolean is used correctly", (t) => {
+  const branch = {
+    prerelease: true,
+  };
+  t.is(isPrerelease(branch), true);
+});
+
+test("Test if prerelease false property as boolean is used correctly", (t) => {
+  const branch = {
+    prerelease: false,
+  };
+  t.is(isPrerelease(branch), false);
+});
+
+test("Test if prerelease property as string is used correctly", (t) => {
+  const branch = {
+    prerelease: "rc",
+  };
+  t.is(isPrerelease(branch), true);
+});
+
+test("Test if prerelease type is used correctly", (t) => {
+  const branch = {
+    type: "prerelease",
+  };
+  t.is(isPrerelease(branch), true);
+});
+
+test("Test if prerelease type and main is used correctly", (t) => {
+  const branch = {
+    type: "release",
+    main: false,
+  };
+  t.is(isPrerelease(branch), true);
+});
+
+test("Test if prerelease type and main in addition to prerelease is used correctly", (t) => {
+  const branch = {
+    type: "release",
+    main: false,
+    prerelease: false,
+  };
+  t.is(isPrerelease(branch), false);
+});