Skip to content

Commit 186e025

Browse files
committed
fix: add fallback github release to tags
1 parent 3bbf7d5 commit 186e025

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

docs/utils/github-api.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,21 @@ export const getLatestReleaseVersion = async (owner: string, repo: string): Prom
33
`https://api.github.com/repos/${owner}/${repo}/releases/latest`
44
)
55
.then((response) => response.json())
6-
.then((data) => data.tag_name.replace("v", ""));
6+
.then((data) => {
7+
if (data.tag_name) {
8+
return data.tag_name.replace("v", "")
9+
} else {
10+
return fetch(
11+
`https://api.github.com/repos/${owner}/${repo}/tags`
12+
)
13+
.then((response) => response.json())
14+
.then((data) => {
15+
try {
16+
return data[0].name.replace("v", "")
17+
} catch {
18+
return "latest"
19+
}
20+
})
21+
}
22+
})
723
};

0 commit comments

Comments
 (0)