MCPcopy Create free account
hub / github.com/anus-dev/ANUS / getLatestGitHubRelease

Function getLatestGitHubRelease

packages/cli/src/utils/gitUtils.ts:56–92  ·  view source on GitHub ↗
(
  proxy?: string,
)

Source from the content-addressed store, hash-verified

54 * @returns string of the release tag (e.g. "v1.2.3").
55 */
56export const getLatestGitHubRelease = async (
57 proxy?: string,
58): Promise<string> => {
59 try {
60 const controller = new AbortController();
61
62 const endpoint = `https://api.github.com/repos/google-github-actions/run-anus-cli/releases/latest`;
63
64 const response = await fetch(endpoint, {
65 method: 'GET',
66 headers: {
67 Accept: 'application/vnd.github+json',
68 'Content-Type': 'application/json',
69 'X-GitHub-Api-Version': '2022-11-28',
70 },
71 dispatcher: proxy ? new ProxyAgent(proxy) : undefined,
72 signal: AbortSignal.any([AbortSignal.timeout(30_000), controller.signal]),
73 } as RequestInit);
74
75 if (!response.ok) {
76 throw new Error(
77 `Invalid response code: ${response.status} - ${response.statusText}`,
78 );
79 }
80
81 const releaseTag = (await response.json()).tag_name;
82 if (!releaseTag) {
83 throw new Error(`Response did not include tag_name field`);
84 }
85 return releaseTag;
86 } catch (_error) {
87 console.debug(`Failed to determine latest run-anus-cli release:`, _error);
88 throw new Error(
89 `Unable to determine the latest run-anus-cli release on GitHub.`,
90 );
91 }
92};
93
94/**
95 * getGitHubRepoInfo returns the owner and repository for a GitHub repo.

Callers 2

gitUtils.test.tsFile · 0.85

Calls 1

debugMethod · 0.80

Tested by

no test coverage detected