feat(bundler): add TAURI_BUNDLER_TOOLS_GITHUB_MIRRORto specify a GitHub mirror#10866
Conversation
…ler to support GitHub CDN This commit introduces a feature that checks for the presence of an environment variable `GITHUB_CDN` before downloading the webview2 offline installer. If `GITHUB_CDN` is set, the download URL is rewritten to use a specified GitHub CDN, which can improve download speeds for users in regions where direct access to GitHub might be slow or unreliable. This change allows users to benefit from faster downloads without needing to configure proxy servers, particularly beneficial for those in mainland China where alternative CDNs are commonly used.
Package Changes Through 1c42375There are 2 changes which include tauri-bundler with prerelease, tauri-cli with prerelease Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
amrbashir
left a comment
There was a problem hiding this comment.
Thank you, could you also add a change file in .changes directory?
|
|
||
| let agent = ureq::AgentBuilder::new().try_proxy_from_env(true).build(); | ||
| let response = agent.get(url).call().map_err(Box::new)?; | ||
| let (agent, url) = match std::env::var("GITHUB_CDN") { |
There was a problem hiding this comment.
I think GITHUB_CDN is a bit vague, maybe TAURI_BUNDLER_TOOLS_DOWNLOAD_HOST is better here. You also need to document that env var in crates/tauri-cli/ENVIRONEMENT_VARIABLES.md file
There was a problem hiding this comment.
Currently, tauri-bundler downloads files from GitHub, which is why the variable name GITHUB_CDN is used.
If future versions source downloads from other websites, the variable TAURI_BUNDLER_TOOLS_DOWNLOAD_HOST might cause confusion or errors. To avoid this, would it be more appropriate to rename it to TAURI_BUNDLER_TOOLS_DOWNLOAD_GITHUB_CDN or TAURI_BUNDLER_TOOLS_DOWNLOAD_GITHUB_TEMPLATE?
Or is it unlikely that future versions of tauri-bundler will download files from any site other than GitHub?
There was a problem hiding this comment.
webview2, which this pr is about, isn't downloaded from github though?
There was a problem hiding this comment.
In accordance with internet regulations, users in mainland China are unable to directly download files from GitHub. A proxy is typically required. However, some users are not proficient in using proxies. Hence, I desire to add this feature—to facilitate file downloads from GitHub via public reverse proxy servers (CDN).
There was a problem hiding this comment.
Yes, i understood this. I am not against this PR/change. I'm just saying that the GITHUB_CDN variable is used here for files that are not downloaded from github but from microsoft.
There was a problem hiding this comment.
I understand what you mean now, so I should add a source check, prioritizing CDN usage for files coming from GitHub, and for files from other source websites, downloading them based on try_proxy_from_env.
- Renamed the `GITHUB_CDN` environment variable to `TAURI_BUNDLER_TOOLS_DOWNLOAD_GITHUB_CDN` for clarity. - Added error handling for URL parsing in the Windows-specific utility functions. - Updated documentation to reflect the new environment variable.
- Extracted the creation of the HTTP agent and URL into a separate function `create_agent_and_url`. - Ensured that the `TAURI_BUNDLER_TOOLS_DOWNLOAD_GITHUB_CDN` environment variable is used when downloading from GitHub CDN.
Co-authored-by: Amr Bashir <github@amrbashir.me>
Co-authored-by: Amr Bashir <github@amrbashir.me>
Co-authored-by: Amr Bashir <github@amrbashir.me>
Co-authored-by: Amr Bashir <github@amrbashir.me>
TAURI_BUNDLER_TOOLS_GITHUB_MIRRORto specify a GitHub mirror
This feature is designed to facilitate the use of
taurifor developers in Mainland China or other regions where GitHub is not accessible.This commit introduces a feature that checks for the presence of an environment variable
TAURI_BUNDLER_TOOLS_GITHUB_MIRRORbefore downloading the webview2 offline installer. IfTAURI_BUNDLER_TOOLS_GITHUB_MIRRORis set, the download URL is rewritten to use a specified GitHub mirror, which can improve download speeds for users in regions where direct access to GitHub might be slow or unreliable. This change allows users to benefit from faster downloads without needing to configure proxy servers, particularly beneficial for those in mainland China where alternative mirrors are commonly used.This commit helps resolve the issue encountered in #7338.
PowerShell: