diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index a2204c7..883ae93 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -59,3 +59,12 @@ jobs: with: name: app 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}" diff --git a/scripts/upload_ipa.py b/scripts/upload_ipa.py new file mode 100644 index 0000000..1324b2d --- /dev/null +++ b/scripts/upload_ipa.py @@ -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)