As of April 2021, it will no longer be an LTS release, and thus us supporting it will increase maintenance burdens. Also switch CI to use 18.04, so as to test what we currently support. Closes #4505
52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
#!/usr/bin/env python2.7
|
|
import os
|
|
import requests
|
|
import shutil
|
|
import subprocess
|
|
from requests.auth import HTTPBasicAuth
|
|
|
|
PACKAGECLOUD_TOKEN = os.getenv('DOKKU_PACKAGECLOUD_TOKEN')
|
|
|
|
|
|
def download_file(filename, url):
|
|
r = requests.get(url, stream=True)
|
|
with open(filename, 'wb') as f:
|
|
shutil.copyfileobj(r.raw, f)
|
|
|
|
|
|
def upload_file(filename):
|
|
versions = [
|
|
"focal"
|
|
]
|
|
cmd_template = "package_cloud push dokku/dokku/ubuntu/{0} {1}"
|
|
for version in versions:
|
|
cmd = cmd_template.format(version, filename)
|
|
subprocess.call(cmd, shell=True)
|
|
|
|
|
|
def main():
|
|
auth = HTTPBasicAuth(PACKAGECLOUD_TOKEN, '')
|
|
base = requests.get('https://packagecloud.io/api/v1/repos/dokku/dokku/packages/deb/ubuntu/bionic.json',
|
|
auth=auth)
|
|
data = base.json()
|
|
urls = []
|
|
for package in data:
|
|
urls.append(package['versions_url'])
|
|
|
|
download_urls = {}
|
|
for url in urls:
|
|
base = requests.get('https://packagecloud.io{0}'.format(url),
|
|
auth=auth)
|
|
data = base.json()
|
|
for version in data:
|
|
download_urls['downloads/' + version['filename']] = version['download_url']
|
|
|
|
for filename, download_url in download_urls.items():
|
|
print("downloading {0}".format(filename))
|
|
download_file(filename, download_url)
|
|
upload_file(filename)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|