Created
April 11, 2025 19:46
-
-
Save Bradford1040/b5f32108b8d3e39c719b35434bef5029 to your computer and use it in GitHub Desktop.
mainsail include for Happy-Hare
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
import requests | |
import io | |
import zipfile | |
import shutil | |
import os | |
BASE = os.path.expanduser('~') | |
with open(BASE + '/.mainsail-token') as file: | |
TOKEN = file.read().strip() | |
resp = requests.get('https://api.github.com/repos/moggieuk/mainsail-happy-hare-edition/actions/artifacts') | |
json = resp.json() | |
artifact = json['artifacts'][0] | |
zip_url = artifact['archive_download_url'] | |
zip_resp = requests.get(zip_url, headers={'Authorization': 'Bearer '+TOKEN}, stream=True) | |
zip_raw = zip_resp.raw.data | |
zip = zipfile.ZipFile(io.BytesIO(zip_raw)) | |
inner = zip.open('mainsail-latest.zip') | |
innerzip = zipfile.ZipFile(inner) | |
if os.path.exists(BASE + '/mainsail'): | |
shutil.rmtree(BASE + '/mainsail') | |
innerzip.extractall(BASE + '/mainsail') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment