feat: migrate all downloads to R2 CDN with race_download
- Remove update.hwdns.net proxy, add dl.dbxio.com R2 CDN - Remove deprecated race_github_proxies, replace with race_download - Update Tauri updater endpoints to prioritize R2 - Migrate update check, JDBC plugin download to race_download - Add R2 upload job to publish-packages workflow
This commit is contained in:
@@ -215,3 +215,43 @@ jobs:
|
||||
git push
|
||||
echo "::notice::Scoop manifest updated to ${VERSION}"
|
||||
fi
|
||||
|
||||
upload-r2:
|
||||
name: Upload to R2
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event_name == 'workflow_dispatch' || (!github.event.release.draft && !github.event.release.prerelease) }}
|
||||
steps:
|
||||
- name: Extract version from tag
|
||||
id: version
|
||||
run: |
|
||||
TAG="${{ github.event.release.tag_name || github.event.inputs.tag }}"
|
||||
TAG="$(echo "${TAG}" | xargs)"
|
||||
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Download release assets
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
mkdir -p assets
|
||||
gh release download "${{ steps.version.outputs.tag }}" \
|
||||
--repo "${{ github.repository }}" \
|
||||
--dir assets \
|
||||
--clobber
|
||||
ls -lh assets/
|
||||
|
||||
- name: Upload to R2 (versioned)
|
||||
run: |
|
||||
aws s3 sync ./assets "s3://${{ secrets.R2_BUCKET_NAME }}/releases/${{ steps.version.outputs.tag }}/" \
|
||||
--endpoint-url "https://${{ secrets.R2_ACCOUNT_ID }}.r2.cloudflarestorage.com"
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
||||
|
||||
- name: Upload to R2 (latest)
|
||||
run: |
|
||||
aws s3 sync ./assets "s3://${{ secrets.R2_BUCKET_NAME }}/releases/latest/" \
|
||||
--endpoint-url "https://${{ secrets.R2_ACCOUNT_ID }}.r2.cloudflarestorage.com" \
|
||||
--delete
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
||||
|
||||
@@ -26,40 +26,6 @@ pub const R2_CDN_BASE: &str = "https://dl.dbxio.com/";
|
||||
|
||||
pub const GITHUB_PROXIES: &[&str] = &["https://gh-proxy.org/", ""];
|
||||
|
||||
pub async fn race_github_proxies(
|
||||
client: &reqwest::Client,
|
||||
github_url: &str,
|
||||
user_agent: &str,
|
||||
) -> Result<reqwest::Response, String> {
|
||||
use futures::future::select_ok;
|
||||
use std::pin::Pin;
|
||||
|
||||
let futs: Vec<Pin<Box<dyn std::future::Future<Output = Result<reqwest::Response, String>> + Send>>> =
|
||||
GITHUB_PROXIES
|
||||
.iter()
|
||||
.map(|proxy| {
|
||||
let url = format!("{proxy}{github_url}");
|
||||
let client = client.clone();
|
||||
let ua = user_agent.to_string();
|
||||
Box::pin(async move {
|
||||
client
|
||||
.get(&url)
|
||||
.header(reqwest::header::USER_AGENT, ua)
|
||||
.send()
|
||||
.await
|
||||
.and_then(|r| r.error_for_status())
|
||||
.map_err(|e| format!("{e}"))
|
||||
})
|
||||
as Pin<Box<dyn std::future::Future<Output = Result<reqwest::Response, String>> + Send>>
|
||||
})
|
||||
.collect();
|
||||
|
||||
match select_ok(futs).await {
|
||||
Ok((resp, _)) => Ok(resp),
|
||||
Err(last_err) => Err(last_err),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn race_download(
|
||||
client: &reqwest::Client,
|
||||
github_url: &str,
|
||||
|
||||
@@ -7,6 +7,7 @@ use serde::Serialize;
|
||||
use super::connection::AppState;
|
||||
|
||||
const JDBC_PLUGIN_DOWNLOAD_URL: &str = "https://github.com/t8y2/dbx/releases/latest/download/dbx-jdbc-plugin-0.1.0.zip";
|
||||
const JDBC_PLUGIN_R2_PATH: &str = "releases/latest/dbx-jdbc-plugin-0.1.0.zip";
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn list_plugins(state: State<'_, Arc<AppState>>) -> Result<Vec<InstalledPlugin>, String> {
|
||||
@@ -152,9 +153,10 @@ async fn download_jdbc_plugin_zip() -> Result<Vec<u8>, String> {
|
||||
.build()
|
||||
.map_err(|err| err.to_string())?;
|
||||
|
||||
let resp = dbx_core::race_github_proxies(&client, JDBC_PLUGIN_DOWNLOAD_URL, "dbx-jdbc-plugin-installer")
|
||||
.await
|
||||
.map_err(|err| format!("Failed to download JDBC plugin: {err}"))?;
|
||||
let resp =
|
||||
dbx_core::race_download(&client, JDBC_PLUGIN_DOWNLOAD_URL, JDBC_PLUGIN_R2_PATH, "dbx-jdbc-plugin-installer")
|
||||
.await
|
||||
.map_err(|err| format!("Failed to download JDBC plugin: {err}"))?;
|
||||
|
||||
let bytes = resp.bytes().await.map_err(|err| err.to_string())?;
|
||||
Ok(bytes.to_vec())
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
"updater": {
|
||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDkxNEYyMzE3QkJCNkM3REYKUldUZng3YTdGeU5Qa1NnTUZCRVhJVkxsOWZKQWFPVCtacUgySlNlcjRDU2RmZElCQnphd25pYUMK",
|
||||
"endpoints": [
|
||||
"https://update.hwdns.net/https://github.com/t8y2/dbx/releases/latest/download/latest.json",
|
||||
"https://dl.dbxio.com/releases/latest/latest.json",
|
||||
"https://gh-proxy.org/https://github.com/t8y2/dbx/releases/latest/download/latest.json",
|
||||
"https://github.com/t8y2/dbx/releases/latest/download/latest.json"
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user