Add custom upload for ipa

This commit is contained in:
2024-02-06 16:56:58 +08:00
parent 06b8a26177
commit 2fab2f56d8
2 changed files with 32 additions and 0 deletions

View File

@@ -59,3 +59,12 @@ jobs:
with: with:
name: app name: app
path: build/ios/iphoneos/app.ipa path: build/ios/iphoneos/app.ipa
- name: Upload to site
env:
BASE_URL: ${{ secrets.IPA_BASE_URL }}
USERNAME: ${{ secrets.IPA_USERNAME }}
PASSWORD: ${{ secrets.IPA_PASSWORD }}
continue-on-error: true
run: |
python3 -m pip install requests
python3 scripts/upload_ipa.py "${BASE_URL}" build/ios/iphoneos/app.ipa "${USERNAME}" "${PASSWORD}"

23
scripts/upload_ipa.py Normal file
View File

@@ -0,0 +1,23 @@
import argparse
import requests
from requests.auth import HTTPBasicAuth
import os
def upload_ipa(baseurl: str, file_path: str, username: str, password: str):
url = f"{baseurl}/api/upload"
basic = HTTPBasicAuth(username, password)
re = requests.post(url, files={"file": open(file_path, "rb")}, auth=basic, timeout=60)
json = re.json()
if "err" in json and json["err"]:
raise Exception(f"Error uploading file: {json['err']}")
print("Uploaded file successfully")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Upload an IPA file to the server")
parser.add_argument("baseurl", help="The base URL of the server")
parser.add_argument("file", help="The IPA file to upload")
parser.add_argument("username", help="The username to authenticate with")
parser.add_argument("password", help="The password to authenticate with")
args = parser.parse_args()
upload_ipa(args.baseurl, args.file, args.username, args.password)