mirror of
https://github.com/dokku/dokku.git
synced 2025-12-28 16:06:40 +01:00
Will still need package releases, but everything should be ready for 0.21.0. Closes #3961
53 lines
1.4 KiB
Python
53 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 = [
|
|
"xenial"
|
|
"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()
|