From 8b2d5ad110e14b53f418c7d54afb631fe97997a4 Mon Sep 17 00:00:00 2001 From: sinspired Date: Wed, 8 Oct 2025 15:04:55 +0800 Subject: [PATCH 1/2] Supports direct download assets through GitHub Proxy --- github_source.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/github_source.go b/github_source.go index dcaf779..741894b 100644 --- a/github_source.go +++ b/github_source.go @@ -6,6 +6,7 @@ import ( "io" "net/http" "os" + "strings" "github.com/google/go-github/v74/github" "golang.org/x/oauth2" @@ -93,6 +94,42 @@ func (s *GitHubSource) DownloadReleaseAsset(ctx context.Context, rel *Release, a if rel == nil { return nil, ErrInvalidRelease } + // Check if the AssetURL contains more than one "https://" + useGithubProxy := strings.Count(rel.AssetURL, "https://") > 1 + // If the AssetURL contains more than 2 "https://", it means it's using a GitHub Proxy service. + // In this case, we should download the asset directly from the AssetURL instead of using the GitHub API. + // This is a workaround for the issue that the GitHub API does not support downloading assets from GitHub Proxy services. + if useGithubProxy { + // Determine download url based on asset id. + var downloadUrl string + if rel.AssetID == assetID { + downloadUrl = rel.AssetURL + } else if rel.ValidationAssetID == assetID { + downloadUrl = rel.ValidationAssetURL + } + if downloadUrl == "" { + return nil, fmt.Errorf("asset ID %d: %w", assetID, ErrAssetNotFound) + } + // Download the asset directly from the AssetURL + req, err := http.NewRequestWithContext(ctx, http.MethodGet, downloadUrl, http.NoBody) + if err != nil { + return nil, fmt.Errorf("failed to create download request:%w", err) + } + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return nil, fmt.Errorf("download failed:%w", err) + } + + // The caller is responsible for closing resp.Body + if resp.StatusCode != http.StatusOK { + defer resp.Body.Close() + return nil, fmt.Errorf("download failed, status code:%d", resp.StatusCode) + } + + return resp.Body, nil + } + // continue with the normal GitHub API download owner, repo, err := rel.repository.GetSlug() if err != nil { return nil, err From 496a584a3580763edf5b0cb10f0de4b21d6283c0 Mon Sep 17 00:00:00 2001 From: sinspired Date: Wed, 8 Oct 2025 15:12:45 +0800 Subject: [PATCH 2/2] Add support for 386 architecture --- arch.go | 3 +++ arch_test.go | 2 ++ 2 files changed, 5 insertions(+) diff --git a/arch.go b/arch.go index e4b1cf8..4f77f91 100644 --- a/arch.go +++ b/arch.go @@ -27,6 +27,9 @@ func getAdditionalArch(arch string, goarm uint8, universalArch string) []string if arch == "amd64" { additionalArch = append(additionalArch, "x86_64") } + if arch == "386" { + additionalArch = append(additionalArch, "i386", "x86", "x86_32") + } if universalArch != "" { additionalArch = append(additionalArch, universalArch) } diff --git a/arch_test.go b/arch_test.go index 8013b42..b68f87c 100644 --- a/arch_test.go +++ b/arch_test.go @@ -23,6 +23,8 @@ func TestAdditionalArch(t *testing.T) { {"arm", 4, "", []string{"arm"}}, // go is not supporting below armv5 {"amd64", 0, "", []string{"amd64", "x86_64"}}, {"amd64", 0, "all", []string{"amd64", "x86_64", "all"}}, + {"386", 0, "", []string{"386", "i386", "x86", "x86_32"}}, + {"386", 0, "all", []string{"386", "i386", "x86", "x86_32", "all"}}, } for _, testItem := range testData {