Skip to content

Instantly share code, notes, and snippets.

@Bradford1040
Created April 11, 2025 19:46
Show Gist options
  • Save Bradford1040/b5f32108b8d3e39c719b35434bef5029 to your computer and use it in GitHub Desktop.
Save Bradford1040/b5f32108b8d3e39c719b35434bef5029 to your computer and use it in GitHub Desktop.
mainsail include for Happy-Hare
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