Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b31480bec |
+3
-3
@@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "i-want-to-heal",
|
"name": "i-want-to-heal",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.1.12",
|
"version": "0.1.13",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"predev": "pnpm assets:sync-basis-transcoder",
|
"predev": "node scripts/sync_basis_transcoder.mjs",
|
||||||
"dev": "vite --host 0.0.0.0",
|
"dev": "vite --host 0.0.0.0",
|
||||||
"dev:api": "HOST=127.0.0.1 PORT=4174 node server/production.mjs",
|
"dev:api": "HOST=127.0.0.1 PORT=4174 node server/production.mjs",
|
||||||
"db:backup": "node scripts/backup-db.mjs",
|
"db:backup": "node scripts/backup-db.mjs",
|
||||||
"db:init": "node scripts/init-db.mjs",
|
"db:init": "node scripts/init-db.mjs",
|
||||||
"prebuild": "pnpm assets:sync-basis-transcoder",
|
"prebuild": "node scripts/sync_basis_transcoder.mjs",
|
||||||
"build": "tsc -b && vite build",
|
"build": "tsc -b && vite build",
|
||||||
"android:sync": "pnpm run build && cap sync android",
|
"android:sync": "pnpm run build && cap sync android",
|
||||||
"android:sync:truenas": "VITE_API_BASE_URL=https://iwanttoheal.phenomrom.com pnpm run android:sync",
|
"android:sync:truenas": "VITE_API_BASE_URL=https://iwanttoheal.phenomrom.com pnpm run android:sync",
|
||||||
|
|||||||
+39
-20
@@ -8,7 +8,6 @@ import hashlib
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import secrets
|
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
@@ -339,17 +338,6 @@ def create_release(tag: str, commit: str, message: str, token: str) -> dict[str,
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def multipart_asset(path: Path, media_type: str) -> tuple[bytes, str]:
|
|
||||||
boundary = f"----iwanttoheal{secrets.token_hex(12)}"
|
|
||||||
prefix = (
|
|
||||||
f"--{boundary}\r\n"
|
|
||||||
f'Content-Disposition: form-data; name="attachment"; filename="{path.name}"\r\n'
|
|
||||||
f"Content-Type: {media_type}\r\n\r\n"
|
|
||||||
).encode()
|
|
||||||
body = prefix + path.read_bytes() + f"\r\n--{boundary}--\r\n".encode()
|
|
||||||
return body, f"multipart/form-data; boundary={boundary}"
|
|
||||||
|
|
||||||
|
|
||||||
def upload_release_asset(
|
def upload_release_asset(
|
||||||
release_id: int,
|
release_id: int,
|
||||||
path: Path,
|
path: Path,
|
||||||
@@ -357,14 +345,45 @@ def upload_release_asset(
|
|||||||
media_type: str,
|
media_type: str,
|
||||||
token: str,
|
token: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
body, content_type = multipart_asset(path, media_type)
|
curl = shutil.which("curl")
|
||||||
gitea_request(
|
if not curl:
|
||||||
f"/repos/{GITEA_OWNER}/{GITEA_REPO}/releases/{release_id}/assets"
|
raise SystemExit("curl is required to upload Gitea release assets")
|
||||||
f"?name={urllib.parse.quote(path.name)}",
|
|
||||||
token=token,
|
url = (
|
||||||
method="POST",
|
f"{GITEA_API}/repos/{GITEA_OWNER}/{GITEA_REPO}/releases/{release_id}/assets"
|
||||||
body=body,
|
f"?name={urllib.parse.quote(path.name)}"
|
||||||
content_type=content_type,
|
)
|
||||||
|
headers = (
|
||||||
|
"Accept: application/json\n"
|
||||||
|
f"Authorization: token {token}\n"
|
||||||
|
"Expect: 100-continue\n"
|
||||||
|
)
|
||||||
|
result = subprocess.run(
|
||||||
|
[
|
||||||
|
curl,
|
||||||
|
"--silent",
|
||||||
|
"--show-error",
|
||||||
|
"--fail-with-body",
|
||||||
|
"--connect-timeout",
|
||||||
|
"30",
|
||||||
|
"--max-time",
|
||||||
|
"300",
|
||||||
|
"--header",
|
||||||
|
"@-",
|
||||||
|
"--form",
|
||||||
|
f"attachment=@{path};type={media_type}",
|
||||||
|
url,
|
||||||
|
],
|
||||||
|
cwd=REPO_ROOT,
|
||||||
|
input=headers,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
check=False,
|
||||||
|
)
|
||||||
|
if result.returncode:
|
||||||
|
details = result.stdout.strip() or result.stderr.strip()
|
||||||
|
raise SystemExit(
|
||||||
|
f"Gitea release asset upload failed (curl {result.returncode}): {details}"
|
||||||
)
|
)
|
||||||
print(f"Release asset uploaded: {path.name}")
|
print(f"Release asset uploaded: {path.name}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user