Files
furbo-vpn-edition/create_release.py
StreamPlayer Bot a9da5a3b8e fix: Update domains to streamtp10.com and implement robust DNS fallback
- Update all channel URLs and event endpoint to streamtp10.com
- Create NetworkUtils for centralized OkHttpClient configuration
- Implement DNS fallback: Google (Primary) -> AdGuard (Secondary) -> System (Tertiary)
- Migrate EventRepository to use NetworkUtils client instead of HttpURLConnection
- Fix Referer header in StreamUrlResolver
2026-02-09 22:37:20 -03:00

78 lines
2.6 KiB
Python

import json
import urllib.request
import urllib.parse
import urllib.error
import os
import sys
# Configuration
GITEA_URL = "https://gitea.cbcren.online/api/v1"
REPO_OWNER = "renato97"
REPO_NAME = "app"
TOKEN = "efeed2af00597883adb04da70bd6a7c2993ae92d"
TAG_NAME = "v10.1.7"
RELEASE_NAME = "StreamPlayer v10.1.7"
CHANGELOG_FILE = "CHANGELOG-v10.1.7.md"
APK_FILE = "StreamPlayer-10.1.7-debug.apk"
def create_release():
try:
with open(CHANGELOG_FILE, 'r') as f:
body = f.read()
except FileNotFoundError:
print(f"Error: {CHANGELOG_FILE} not found.")
sys.exit(1)
url = f"{GITEA_URL}/repos/{REPO_OWNER}/{REPO_NAME}/releases"
headers = {
"Authorization": f"token {TOKEN}",
"Content-Type": "application/json",
"Accept": "application/json"
}
data = {
"tag_name": TAG_NAME,
"target_commitish": "main",
"name": RELEASE_NAME,
"body": body,
"draft": False,
"prerelease": False
}
req = urllib.request.Request(url, data=json.dumps(data).encode('utf-8'), headers=headers, method='POST')
try:
with urllib.request.urlopen(req) as response:
result = json.loads(response.read().decode('utf-8'))
print(f"Release created successfully. ID: {result['id']}")
return result['id']
except urllib.error.HTTPError as e:
print(f"HTTP Error creating release: {e.code} {e.reason}")
print(e.read().decode('utf-8'))
sys.exit(1)
except Exception as e:
print(f"Error creating release: {e}")
sys.exit(1)
def upload_asset(release_id):
if not os.path.exists(APK_FILE):
print(f"Error: APK file {APK_FILE} not found.")
sys.exit(1)
url = f"{GITEA_URL}/repos/{REPO_OWNER}/{REPO_NAME}/releases/{release_id}/assets"
# Simple multipart upload via python is tricky without requests library.
# However, Gitea API usually accepts raw binary in body if Content-Type is set,
# but Gitea's API for assets usually requires multipart/form-data.
# Let's check Gitea API docs...
# The standard Gitea API uses POST /repos/{owner}/{repo}/releases/{id}/assets with name query parameter and file content in body
# Wait, looking at Gitea API docs (swagger usually available at /api/swagger),
# POST /repos/{owner}/{repo}/releases/{id}/assets takes 'attachment' as form-data.
# Implementing multipart/form-data with urllib is painful.
# Instead, I will use curl to upload the asset, using the release ID obtained from Python.
return release_id
if __name__ == "__main__":
release_id = create_release()
print(f"RELEASE_ID={release_id}")