type Github = {
token: string;
};
/**
* Get the latest release
* View the latest published full release for the repository.
The latest release is the most recent non-prerelease, non-draft release, sorted by the `created_at` attribute. The `created_at` attribute is the date of the commit used for the release, and not the date when the release was drafted or published.
*/
export async function main(auth: Github, owner: string, repo: string) {
const url = new URL(
`https://api.github.com/repos/${owner}/${repo}/releases/latest`
);
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 407 days ago