Use releases instead of tags in update check, ignore prereleases/drafts
parent
f8d53741e4
commit
958db5135d
|
@ -42,7 +42,7 @@ async function refreshVersions() {
|
||||||
https.get(
|
https.get(
|
||||||
{
|
{
|
||||||
hostname: "api.github.com",
|
hostname: "api.github.com",
|
||||||
path: `/repos/${owner}/${repo}/tags`,
|
path: `/repos/${owner}/${repo}/releases`,
|
||||||
headers: {
|
headers: {
|
||||||
"User-Agent": `Modmail Bot (https://github.com/${owner}/${repo}) (${packageJson.version})`
|
"User-Agent": `Modmail Bot (https://github.com/${owner}/${repo}) (${packageJson.version})`
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,10 @@ async function refreshVersions() {
|
||||||
const parsed = JSON.parse(data);
|
const parsed = JSON.parse(data);
|
||||||
if (! Array.isArray(parsed) || parsed.length === 0) return;
|
if (! Array.isArray(parsed) || parsed.length === 0) return;
|
||||||
|
|
||||||
const latestVersion = parsed[0].name;
|
const latestStableRelease = parsed.find(r => ! r.prerelease && ! r.draft);
|
||||||
|
if (! latestStableRelease) return;
|
||||||
|
|
||||||
|
const latestVersion = latestStableRelease.name;
|
||||||
await knex("updates").update({
|
await knex("updates").update({
|
||||||
available_version: latestVersion,
|
available_version: latestVersion,
|
||||||
last_checked: moment.utc().format("YYYY-MM-DD HH:mm:ss")
|
last_checked: moment.utc().format("YYYY-MM-DD HH:mm:ss")
|
||||||
|
|
Loading…
Reference in New Issue