-
Notifications
You must be signed in to change notification settings - Fork 11
ADFA-3269 Share nightly release build with private Telegram channel #1073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hal-eisen-adfa
merged 2 commits into
stage
from
ADFA-3269-Share-nightly-release-to-private-Telegram
Mar 13, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| #!/usr/bin/env python3 | ||
| """Upload a file (e.g. APK) to Cloudflare R2. Credentials via env: CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_KEY_ID, CLOUDFLARE_SECRET_ACCESS_KEY.""" | ||
| import sys | ||
| import os | ||
| import boto3 | ||
| from botocore.config import Config | ||
|
|
||
| REQUIRED_ENV = ( | ||
| "CLOUDFLARE_ACCOUNT_ID", | ||
| "CLOUDFLARE_KEY_ID", | ||
| "CLOUDFLARE_SECRET_ACCESS_KEY", | ||
| ) | ||
|
|
||
| for name in REQUIRED_ENV: | ||
| if not os.environ.get(name): | ||
| print(f"ERROR: {name} environment variable is not set.", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| CLOUDFLARE_ACCOUNT_ID = os.environ["CLOUDFLARE_ACCOUNT_ID"] | ||
| CLOUDFLARE_KEY_ID = os.environ["CLOUDFLARE_KEY_ID"] | ||
| CLOUDFLARE_SECRET_ACCESS_KEY = os.environ["CLOUDFLARE_SECRET_ACCESS_KEY"] | ||
| BUCKET_NAME = "apk-repo" | ||
|
|
||
| R2_ENDPOINT_URL = f"https://{CLOUDFLARE_ACCOUNT_ID}.r2.cloudflarestorage.com" | ||
|
|
||
| config = Config( | ||
| read_timeout=300, | ||
| connect_timeout=60, | ||
| retries={"max_attempts": 10}, | ||
| ) | ||
|
|
||
| s3 = boto3.client( | ||
| service_name="s3", | ||
| endpoint_url=R2_ENDPOINT_URL, | ||
| aws_access_key_id=CLOUDFLARE_KEY_ID, | ||
| aws_secret_access_key=CLOUDFLARE_SECRET_ACCESS_KEY, | ||
| region_name="auto", | ||
| config=config, | ||
| ) | ||
|
|
||
| if len(sys.argv) < 3: | ||
| print("Usage: cloudflare-r2-upload.py <file_path> <variant>", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| file_path = sys.argv[1] | ||
| variant = sys.argv[2] | ||
| file_size = os.path.getsize(file_path) | ||
| base_name = os.path.basename(file_path) | ||
| # Inject variant into filename before .apk so v7 and v8 upload to distinct R2 keys | ||
| name_root, ext = os.path.splitext(base_name) | ||
| file_name = f"{name_root}-{variant}{ext}" | ||
hal-eisen-adfa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| extra_args = {} | ||
| if file_name.lower().endswith(".apk"): | ||
| extra_args["ContentType"] = "application/vnd.android.package-archive" | ||
|
|
||
| # Progress callback: print new lines at 10% intervals for CI-friendly logs (bytes_amount is incremental per call) | ||
| _seen_so_far = [0] | ||
| _last_printed_pct = [-1] | ||
|
|
||
| def progress_callback(bytes_amount): | ||
| _seen_so_far[0] += bytes_amount | ||
| if file_size <= 0: | ||
| return | ||
| pct = int(100 * _seen_so_far[0] / file_size) | ||
| if pct >= _last_printed_pct[0] + 10 or pct == 100: | ||
| _last_printed_pct[0] = pct | ||
| mb = _seen_so_far[0] / (1024 * 1024) | ||
| total_mb = file_size / (1024 * 1024) | ||
| print(f"Upload progress: {pct}% ({mb:.1f} MB / {total_mb:.1f} MB)", flush=True) | ||
|
|
||
|
|
||
| upload_kwargs = {"Callback": progress_callback} | ||
| if extra_args: | ||
| upload_kwargs["ExtraArgs"] = extra_args | ||
|
|
||
| print(f"Uploading {file_name} ({file_size / (1024*1024):.1f} MB) to R2...", flush=True) | ||
| s3.upload_file(file_path, BUCKET_NAME, file_name, **upload_kwargs) | ||
| print("Upload complete.", flush=True) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.