@@ -3,7 +3,9 @@ package utils
3
3
import (
4
4
"encoding/json"
5
5
"fmt"
6
+ "io"
6
7
"net/http"
8
+ "strings"
7
9
"time"
8
10
)
9
11
@@ -56,3 +58,46 @@ func MakeGetRequest(network, endpoint, additionalPath string, params map[string]
56
58
57
59
return nil
58
60
}
61
+
62
+ type InitiaRelease struct {
63
+ TagName string `json:"tag_name"`
64
+ Assets []struct {
65
+ BrowserDownloadURL string `json:"browser_download_url"`
66
+ } `json:"assets"`
67
+ }
68
+
69
+ func ListInitiaReleases (os , arch string ) error {
70
+ url := "https://api.github.com/repos/initia-labs/initia/releases"
71
+ resp , err := http .Get (url )
72
+ if err != nil {
73
+ return fmt .Errorf ("failed to fetch releases: %v" , err )
74
+ }
75
+ defer resp .Body .Close ()
76
+
77
+ if resp .StatusCode != http .StatusOK {
78
+ return fmt .Errorf ("unexpected status code: %d" , resp .StatusCode )
79
+ }
80
+
81
+ body , err := io .ReadAll (resp .Body )
82
+ if err != nil {
83
+ return fmt .Errorf ("failed to read response body: %v" , err )
84
+ }
85
+
86
+ var releases []InitiaRelease
87
+ if err := json .Unmarshal (body , & releases ); err != nil {
88
+ return fmt .Errorf ("failed to unmarshal JSON: %v" , err )
89
+ }
90
+
91
+ searchString := fmt .Sprintf ("%s_%s.tar.gz" , os , arch )
92
+
93
+ for _ , release := range releases {
94
+ for _ , asset := range release .Assets {
95
+ if strings .Contains (asset .BrowserDownloadURL , searchString ) {
96
+ fmt .Printf ("Release: %s contains a prebuilt binary for %s_%s\n " , release .TagName , os , arch )
97
+ fmt .Printf ("Download URL: %s\n " , asset .BrowserDownloadURL )
98
+ }
99
+ }
100
+ }
101
+
102
+ return nil
103
+ }
0 commit comments