Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/is-latest-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function isLatestRelease({ type, main }) {
return type === "release" && main;
Copy link

@viceice viceice Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return type === "release" && main;
return type === "release" && main ? "true" : "false";

Otherwise the following error occures.
Invalid request.\n\nFor 'properties/make_latest', true is not a string.

}
2 changes: 2 additions & 0 deletions lib/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import globAssets from "./glob-assets.js";
import resolveConfig from "./resolve-config.js";
import { toOctokitOptions } from "./octokit.js";
import isPrerelease from "./is-prerelease.js";
import isLatestRelease from "./is-latest-release.js";

const debug = debugFactory("semantic-release:github");

Expand Down Expand Up @@ -52,6 +53,7 @@ export default async function publish(pluginConfig, context, { Octokit }) {
name: template(releaseNameTemplate)(context),
body: template(releaseBodyTemplate)(context),
prerelease: isPrerelease(branch),
make_latest: isLatestRelease(branch),
};

debug("release object: %O", release);
Expand Down
31 changes: 31 additions & 0 deletions test/is-latest-release.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import test from "ava";
import isLatestRelease from "../lib/is-latest-release.js";

test("Test for empty object", (t) => {
const branch = {};
t.is(isLatestRelease(branch), false);
});

test("Test if type release and main is used correctly", (t) => {
const branch = {
type: "release",
main: true,
};
t.is(isLatestRelease(branch), true);
});

test("Test if type prerelease is used correctly", (t) => {
const branch = {
type: "prerelease",
main: true,
};
t.is(isLatestRelease(branch), false);
});

test("Test if type main property as boolean is used correctly", (t) => {
const branch = {
type: "release",
main: false,
};
t.is(isLatestRelease(branch), false);
});
17 changes: 16 additions & 1 deletion test/publish.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ test("Publish a release without creating discussion", async (t) => {
name: nextRelease.name,
body: nextRelease.notes,
prerelease: false,
make_latest: true,
},
},
);
Expand Down Expand Up @@ -112,6 +113,7 @@ test("Publish a release and create discussion", async (t) => {
name: nextRelease.name,
body: nextRelease.notes,
prerelease: false,
make_latest: true,
discussion_category_name: pluginConfig.discussionCategoryName,
},
},
Expand Down Expand Up @@ -177,6 +179,7 @@ test("Publish a release on a channel", async (t) => {
name: nextRelease.name,
body: nextRelease.notes,
prerelease: true,
make_latest: false,
},
},
);
Expand Down Expand Up @@ -207,7 +210,7 @@ test("Publish a release on a channel", async (t) => {
t.true(fetch.done());
});

test("Publish a prerelease wihtout creating discussion", async (t) => {
test("Publish a prerelease without creating discussion", async (t) => {
const owner = "test_user";
const repo = "test_repo";
const env = { GITHUB_TOKEN: "github_token" };
Expand Down Expand Up @@ -237,6 +240,7 @@ test("Publish a prerelease wihtout creating discussion", async (t) => {
name: nextRelease.name,
body: nextRelease.notes,
prerelease: true,
make_latest: false,
},
},
);
Expand Down Expand Up @@ -300,6 +304,7 @@ test("Publish a prerelease and create discussion", async (t) => {
name: nextRelease.name,
body: nextRelease.notes,
prerelease: true,
make_latest: false,
discussion_category_name: pluginConfig.discussionCategoryName,
},
},
Expand Down Expand Up @@ -366,6 +371,7 @@ test("Publish a maintenance release", async (t) => {
name: nextRelease.name,
body: nextRelease.notes,
prerelease: false,
make_latest: false,
},
},
);
Expand Down Expand Up @@ -443,6 +449,7 @@ test("Publish a release with one asset", async (t) => {
body: nextRelease.notes,
draft: true,
prerelease: false,
make_latest: true,
},
},
)
Expand Down Expand Up @@ -530,6 +537,7 @@ test("Publish a release with one asset and custom github url", async (t) => {
body: nextRelease.notes,
draft: true,
prerelease: false,
make_latest: true,
},
},
)
Expand Down Expand Up @@ -611,6 +619,7 @@ test("Publish a release with an array of missing assets", async (t) => {
body: nextRelease.notes,
draft: true,
prerelease: false,
make_latest: true,
},
},
)
Expand Down Expand Up @@ -700,6 +709,7 @@ test("Publish a release with asset and create discussion", async (t) => {
body: nextRelease.notes,
draft: true,
prerelease: false,
make_latest: true,
},
},
)
Expand Down Expand Up @@ -785,6 +795,7 @@ test("Publish a draft release", async (t) => {
body: nextRelease.notes,
draft: true,
prerelease: false,
make_latest: true,
},
},
);
Expand Down Expand Up @@ -857,6 +868,7 @@ test("Publish a draft release with one asset", async (t) => {
body: nextRelease.notes,
draft: true,
prerelease: false,
make_latest: true,
},
},
)
Expand Down Expand Up @@ -929,6 +941,7 @@ test("Publish a release when env.GITHUB_URL is set to https://github.com (Defaul
name: nextRelease.name,
body: nextRelease.notes,
prerelease: false,
make_latest: true,
},
},
);
Expand Down Expand Up @@ -992,6 +1005,7 @@ test("Publish a custom release body", async (t) => {
name: nextRelease.name,
body: `To install this run npm install package@${nextRelease.name}\n\n${nextRelease.notes}`,
prerelease: false,
make_latest: true,
},
},
);
Expand Down Expand Up @@ -1055,6 +1069,7 @@ test("Publish a custom release name", async (t) => {
name: `omg its the best release: ${nextRelease.name} 🌈🌈`,
body: nextRelease.notes,
prerelease: false,
make_latest: true,
},
},
);
Expand Down
Loading