download-github-releases 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- download_github_releases-1.0.0/PKG-INFO +36 -0
- download_github_releases-1.0.0/README.md +27 -0
- download_github_releases-1.0.0/download_github_releases/__init__.py +21 -0
- download_github_releases-1.0.0/download_github_releases/__main__.py +35 -0
- download_github_releases-1.0.0/download_github_releases/download_github_releases.py +294 -0
- download_github_releases-1.0.0/download_github_releases.egg-info/PKG-INFO +36 -0
- download_github_releases-1.0.0/download_github_releases.egg-info/SOURCES.txt +12 -0
- download_github_releases-1.0.0/download_github_releases.egg-info/dependency_links.txt +1 -0
- download_github_releases-1.0.0/download_github_releases.egg-info/entry_points.txt +2 -0
- download_github_releases-1.0.0/download_github_releases.egg-info/requires.txt +1 -0
- download_github_releases-1.0.0/download_github_releases.egg-info/top_level.txt +1 -0
- download_github_releases-1.0.0/pyproject.toml +19 -0
- download_github_releases-1.0.0/setup.cfg +4 -0
- download_github_releases-1.0.0/setup.py +28 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: download-github-releases
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Download (and keep in sync) the releases from a set of GitHub projects
|
|
5
|
+
Author-email: Jason Morley <hello@jbmorley.co.uk>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: requests
|
|
9
|
+
|
|
10
|
+
# download-github-releases
|
|
11
|
+
|
|
12
|
+
Script to download all the releases for GitHub projects
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```plaintext
|
|
17
|
+
usage: download-github-releases [-h] [--verbose] [--download-source]
|
|
18
|
+
--output OUTPUT
|
|
19
|
+
repository [repository ...]
|
|
20
|
+
|
|
21
|
+
Download (and keep in sync) the releases from a set of GitHub projects.
|
|
22
|
+
|
|
23
|
+
positional arguments:
|
|
24
|
+
repository GitHub repository to fetch releases from
|
|
25
|
+
|
|
26
|
+
options:
|
|
27
|
+
-h, --help show this help message and exit
|
|
28
|
+
--verbose, -v show verbose output
|
|
29
|
+
--download-source, -s
|
|
30
|
+
also download source for each release
|
|
31
|
+
--output OUTPUT output directory
|
|
32
|
+
|
|
33
|
+
Set the GITHUB_TOKEN environment variable to use token-based authentication.
|
|
34
|
+
This is required for accessing private repositories and can help with API rate
|
|
35
|
+
limits.
|
|
36
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# download-github-releases
|
|
2
|
+
|
|
3
|
+
Script to download all the releases for GitHub projects
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```plaintext
|
|
8
|
+
usage: download-github-releases [-h] [--verbose] [--download-source]
|
|
9
|
+
--output OUTPUT
|
|
10
|
+
repository [repository ...]
|
|
11
|
+
|
|
12
|
+
Download (and keep in sync) the releases from a set of GitHub projects.
|
|
13
|
+
|
|
14
|
+
positional arguments:
|
|
15
|
+
repository GitHub repository to fetch releases from
|
|
16
|
+
|
|
17
|
+
options:
|
|
18
|
+
-h, --help show this help message and exit
|
|
19
|
+
--verbose, -v show verbose output
|
|
20
|
+
--download-source, -s
|
|
21
|
+
also download source for each release
|
|
22
|
+
--output OUTPUT output directory
|
|
23
|
+
|
|
24
|
+
Set the GITHUB_TOKEN environment variable to use token-based authentication.
|
|
25
|
+
This is required for accessing private repositories and can help with API rate
|
|
26
|
+
limits.
|
|
27
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Copyright (c) 2021-2026 Jason Morley
|
|
2
|
+
#
|
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
# furnished to do so, subject to the following conditions:
|
|
9
|
+
#
|
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
# copies or substantial portions of the Software.
|
|
12
|
+
#
|
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
# SOFTWARE.
|
|
20
|
+
|
|
21
|
+
from . import *
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2021-2026 Jason Morley
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
import os
|
|
24
|
+
import sys
|
|
25
|
+
|
|
26
|
+
if not __package__:
|
|
27
|
+
# Make CLI runnable from source tree with
|
|
28
|
+
# python src/package
|
|
29
|
+
package_source_path = os.path.dirname(os.path.dirname(__file__))
|
|
30
|
+
sys.path.insert(0, package_source_path)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
if __name__ == "__main__":
|
|
34
|
+
from download_github_releases.download_github_releases import main
|
|
35
|
+
main()
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2021-2026 Jason Morley
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
import argparse
|
|
24
|
+
import contextlib
|
|
25
|
+
import gzip
|
|
26
|
+
import hashlib
|
|
27
|
+
import http
|
|
28
|
+
import json
|
|
29
|
+
import logging
|
|
30
|
+
import os
|
|
31
|
+
import shutil
|
|
32
|
+
import subprocess
|
|
33
|
+
import sys
|
|
34
|
+
import tarfile
|
|
35
|
+
import tempfile
|
|
36
|
+
import time
|
|
37
|
+
import urllib.parse
|
|
38
|
+
|
|
39
|
+
from email.message import Message
|
|
40
|
+
|
|
41
|
+
import requests
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
ACCEPT_JSON = "application/vnd.github+json"
|
|
45
|
+
ACCEPT_STREAM = "application/octet-stream"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def download_file(url, path, accept=ACCEPT_STREAM):
|
|
49
|
+
logging.info("Downloading '%s'...", url)
|
|
50
|
+
filename = os.path.basename(path)
|
|
51
|
+
with tempfile.TemporaryDirectory() as directory:
|
|
52
|
+
temporary_path = os.path.join(directory, filename)
|
|
53
|
+
response = perform_with_backoff(requests.get, url, accept, stream=True)
|
|
54
|
+
response.raise_for_status()
|
|
55
|
+
with open(temporary_path, 'wb') as f:
|
|
56
|
+
for chunk in response.iter_content(chunk_size=1024):
|
|
57
|
+
if chunk:
|
|
58
|
+
f.write(chunk)
|
|
59
|
+
shutil.move(temporary_path, path)
|
|
60
|
+
return path
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@contextlib.contextmanager
|
|
64
|
+
def chdir(path):
|
|
65
|
+
try:
|
|
66
|
+
pwd = os.getcwd()
|
|
67
|
+
os.chdir(path)
|
|
68
|
+
yield
|
|
69
|
+
finally:
|
|
70
|
+
os.chdir(pwd)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def makedirs(path):
|
|
74
|
+
if not os.path.isdir(path):
|
|
75
|
+
os.makedirs(path)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def shasum(path):
|
|
79
|
+
sha256 = hashlib.sha256()
|
|
80
|
+
if os.path.isdir(path):
|
|
81
|
+
for f in sorted(listdir(path, include_hidden=False)):
|
|
82
|
+
sha256.update(shasum(os.path.join(path, f)).encode('utf-8'))
|
|
83
|
+
else:
|
|
84
|
+
with open(path, 'rb') as f:
|
|
85
|
+
while True:
|
|
86
|
+
data = f.read(65536)
|
|
87
|
+
if not data:
|
|
88
|
+
break
|
|
89
|
+
sha256.update(data)
|
|
90
|
+
return sha256.hexdigest()
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def shasum_string(string):
|
|
94
|
+
sha256 = hashlib.sha256()
|
|
95
|
+
sha256.update(string.encode('utf-8'))
|
|
96
|
+
return sha256.hexdigest()
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def spinning_cursor():
|
|
100
|
+
while True:
|
|
101
|
+
for cursor in ["zzzz", "Zzzz", "zZzz", "zzZz", "zzzZ"]:
|
|
102
|
+
yield cursor
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class Sleeper:
|
|
106
|
+
|
|
107
|
+
def __init__(self):
|
|
108
|
+
self.polling_duration = 0.2
|
|
109
|
+
self.duration = 0
|
|
110
|
+
self.did_sleep = False
|
|
111
|
+
self.spinner = spinning_cursor()
|
|
112
|
+
self.is_interactive = sys.stdout.isatty()
|
|
113
|
+
|
|
114
|
+
def sleep(self, duration):
|
|
115
|
+
self.did_sleep = True
|
|
116
|
+
self.duration = duration
|
|
117
|
+
while self.duration > 0:
|
|
118
|
+
if self.is_interactive:
|
|
119
|
+
print("\r", end="")
|
|
120
|
+
print(next(self.spinner), end="")
|
|
121
|
+
time.sleep(self.polling_duration)
|
|
122
|
+
self.duration = self.duration - self.polling_duration
|
|
123
|
+
|
|
124
|
+
def finalize(self):
|
|
125
|
+
if self.did_sleep and self.is_interactive:
|
|
126
|
+
print("\r", end="")
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def perform_with_backoff(fn, url, accept, *args, **kwargs):
|
|
130
|
+
if "headers" not in kwargs:
|
|
131
|
+
kwargs["headers"] = {}
|
|
132
|
+
kwargs["headers"]["Accept"] = accept
|
|
133
|
+
kwargs["headers"]["X-GitHub-Api-Version"] = "2022-11-28"
|
|
134
|
+
if "GITHUB_TOKEN" in os.environ:
|
|
135
|
+
kwargs["headers"]["Authorization"] = f"Bearer {os.environ["GITHUB_TOKEN"]}"
|
|
136
|
+
kwargs["allow_redirects"] = True
|
|
137
|
+
sleeper = Sleeper()
|
|
138
|
+
duration = 8
|
|
139
|
+
while True:
|
|
140
|
+
logging.debug(f"GET {url}")
|
|
141
|
+
try:
|
|
142
|
+
response = fn(url, *args, **kwargs)
|
|
143
|
+
if not response.status_code in [403, 429, 502, 504]:
|
|
144
|
+
break
|
|
145
|
+
except http.client.RemoteDisconnected:
|
|
146
|
+
pass
|
|
147
|
+
did_wait = True
|
|
148
|
+
sleeper.sleep(duration)
|
|
149
|
+
duration = min(duration * 2, 60)
|
|
150
|
+
response.raise_for_status()
|
|
151
|
+
sleeper.finalize()
|
|
152
|
+
return response
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def gh_release_assets(url, filter=lambda x: True):
|
|
156
|
+
assets = perform_with_backoff(requests.get, url, ACCEPT_JSON).json()["assets"]
|
|
157
|
+
urls = [asset["browser_download_url"] for asset in assets if filter(asset["name"])]
|
|
158
|
+
return urls
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def gh_releases(repository):
|
|
162
|
+
return get_paginated(f"https://api.github.com/repos/{repository}/releases", params={
|
|
163
|
+
"per_page": 100,
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def get_paginated(url, *args, **kwargs):
|
|
168
|
+
response = perform_with_backoff(requests.get, url, ACCEPT_JSON, *args, **kwargs)
|
|
169
|
+
while True:
|
|
170
|
+
for item in response.json():
|
|
171
|
+
yield item
|
|
172
|
+
if not "next" in response.links:
|
|
173
|
+
return
|
|
174
|
+
response = perform_with_backoff(requests.get, response.links["next"]["url"], ACCEPT_JSON, *args, **kwargs)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def configure_logging():
|
|
178
|
+
verbose = '--verbose' in sys.argv[1:] or '-v' in sys.argv[1:]
|
|
179
|
+
|
|
180
|
+
logger = logging.getLogger()
|
|
181
|
+
logger.setLevel(level=logging.DEBUG if verbose else logging.INFO)
|
|
182
|
+
|
|
183
|
+
formatter = logging.Formatter("[%(levelname)s] %(message)s")
|
|
184
|
+
|
|
185
|
+
handler_out = logging.StreamHandler(sys.stdout)
|
|
186
|
+
handler_out.setLevel(logging.DEBUG)
|
|
187
|
+
handler_out.addFilter(lambda r: r.levelno <= logging.INFO)
|
|
188
|
+
handler_out.setFormatter(formatter)
|
|
189
|
+
logger.addHandler(handler_out)
|
|
190
|
+
|
|
191
|
+
handler_err = logging.StreamHandler(sys.stderr)
|
|
192
|
+
handler_err.setLevel(logging.WARNING)
|
|
193
|
+
handler_err.setFormatter(formatter)
|
|
194
|
+
logger.addHandler(handler_err)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def main():
|
|
198
|
+
configure_logging()
|
|
199
|
+
parser = argparse.ArgumentParser(
|
|
200
|
+
prog="download-github-releases",
|
|
201
|
+
description="Download (and keep in sync) the releases from a set of GitHub projects.",
|
|
202
|
+
epilog="Set the GITHUB_TOKEN environment variable to use token-based authentication. This is required for accessing private repositories and can help with API rate limits."
|
|
203
|
+
)
|
|
204
|
+
parser.add_argument('--verbose', '-v', action='store_true', default=False, help="show verbose output")
|
|
205
|
+
parser.add_argument('--download-source', '-s', action='store_true', default=False, help="also download source for each release")
|
|
206
|
+
parser.add_argument("--output", required=True, help="output directory")
|
|
207
|
+
parser.add_argument("repository", nargs="+", help="GitHub repository to fetch releases from")
|
|
208
|
+
options = parser.parse_args()
|
|
209
|
+
|
|
210
|
+
output_directory = os.path.abspath(options.output)
|
|
211
|
+
|
|
212
|
+
for repository in options.repository:
|
|
213
|
+
repository_directory = os.path.join(output_directory, repository)
|
|
214
|
+
os.makedirs(repository_directory, exist_ok=True)
|
|
215
|
+
|
|
216
|
+
logging.info("Updating '%s'...", repository)
|
|
217
|
+
for release in gh_releases(repository):
|
|
218
|
+
logging.info("Checking '%s'...", release["tag_name"])
|
|
219
|
+
release_directory = os.path.join(repository_directory, release["tag_name"])
|
|
220
|
+
os.makedirs(release_directory, exist_ok=True)
|
|
221
|
+
|
|
222
|
+
# Remove `download_count` from the assets as this isn't stable.
|
|
223
|
+
for asset in release["assets"]:
|
|
224
|
+
asset.pop("download_count", None)
|
|
225
|
+
|
|
226
|
+
release_json = f"{json.dumps(release, sort_keys=True, indent=4)}\n"
|
|
227
|
+
release_json_path = os.path.join(release_directory, "_release.json")
|
|
228
|
+
if not os.path.exists(release_json_path) or shasum(release_json_path) != shasum_string(release_json):
|
|
229
|
+
logging.info("Updating JSON...")
|
|
230
|
+
with open(release_json_path, "w") as fh:
|
|
231
|
+
fh.write(release_json)
|
|
232
|
+
|
|
233
|
+
description = f"# {release["name"]}\n\n{release["body"]}\n"
|
|
234
|
+
description_path = os.path.join(release_directory, "_description.md")
|
|
235
|
+
if not os.path.exists(description_path) or shasum(description_path) != shasum_string(description):
|
|
236
|
+
logging.info("Updating description...")
|
|
237
|
+
with open(description_path, "w") as fh:
|
|
238
|
+
fh.write(description)
|
|
239
|
+
|
|
240
|
+
# Download the source if requested.
|
|
241
|
+
if options.download_source:
|
|
242
|
+
# N.B. The GitHub API rejects application/octet-stream for this particular file end-point, so we say we
|
|
243
|
+
# accept JSON...
|
|
244
|
+
# Unfortunately GitHub makes our lives fairly difficult here by apparently not offering us any clear
|
|
245
|
+
# lightweight way to determine if the source has changed (e.g., if our tag now points to a different
|
|
246
|
+
# sha). With that in mind, we get the head for the file and trust GitHub to continue tagging the
|
|
247
|
+
# source downloads with the git sha (files appear to be of the form
|
|
248
|
+
# inseven-reporter-0.1.7-0-gf63690a.tar.gz).
|
|
249
|
+
# Even more of a mess is the fact that the release JSON doesn't always contain a valid tarball URL, so
|
|
250
|
+
# we do our best to construct one in this scenario.
|
|
251
|
+
tarball_url = release["tarball_url"]
|
|
252
|
+
if tarball_url is None:
|
|
253
|
+
logging.info("Missing source URL for '%s'; guessing...", release["tag_name"])
|
|
254
|
+
tarball_url = f"https://api.github.com/repos/{repository}/tarball/{release["tag_name"]}"
|
|
255
|
+
response = perform_with_backoff(requests.head, tarball_url, ACCEPT_JSON)
|
|
256
|
+
message = Message()
|
|
257
|
+
message['content-disposition'] = response.headers['content-disposition']
|
|
258
|
+
source_filename = message.get_filename()
|
|
259
|
+
source_path = os.path.join(release_directory, source_filename)
|
|
260
|
+
if not os.path.exists(source_path):
|
|
261
|
+
logging.info("Downloading source '%s'...", source_filename)
|
|
262
|
+
download_file(tarball_url, source_path, accept=ACCEPT_JSON)
|
|
263
|
+
|
|
264
|
+
for asset in release["assets"]:
|
|
265
|
+
asset_url = asset["url"]
|
|
266
|
+
asset_path = os.path.join(release_directory, asset["name"])
|
|
267
|
+
|
|
268
|
+
# Check to see if a local copy exists, using the digest if available.
|
|
269
|
+
if "digest" in asset and asset["digest"] is not None:
|
|
270
|
+
digest_kind, digest_value = asset["digest"].split(":")
|
|
271
|
+
if digest_kind != "sha256":
|
|
272
|
+
logging.error("Unsupported digest kind '%s'.", digest_kind)
|
|
273
|
+
if os.path.exists(asset_path):
|
|
274
|
+
sha256 = shasum(asset_path)
|
|
275
|
+
if sha256 == digest_value:
|
|
276
|
+
logging.debug("Skipping '%s' (matching digests)...", asset_url)
|
|
277
|
+
continue
|
|
278
|
+
else:
|
|
279
|
+
logging.warning("Re-downloading '%s' to '%s' (digests differ)...", asset_url, asset_path)
|
|
280
|
+
else:
|
|
281
|
+
if os.path.exists(asset_path):
|
|
282
|
+
logging.info("Asset is missing a digest, relying on file size...")
|
|
283
|
+
size = os.path.getsize(asset_path)
|
|
284
|
+
if size == asset["size"]:
|
|
285
|
+
logging.debug("Skipping '%s' (matching sizes)...", asset_url)
|
|
286
|
+
continue
|
|
287
|
+
else:
|
|
288
|
+
logging.warning("Re-downloading '%s' to '%s' (sizes differ)...", asset_url, asset_path)
|
|
289
|
+
|
|
290
|
+
download_file(asset_url, asset_path)
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
if __name__ == "__main__":
|
|
294
|
+
main()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: download-github-releases
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Download (and keep in sync) the releases from a set of GitHub projects
|
|
5
|
+
Author-email: Jason Morley <hello@jbmorley.co.uk>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: requests
|
|
9
|
+
|
|
10
|
+
# download-github-releases
|
|
11
|
+
|
|
12
|
+
Script to download all the releases for GitHub projects
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```plaintext
|
|
17
|
+
usage: download-github-releases [-h] [--verbose] [--download-source]
|
|
18
|
+
--output OUTPUT
|
|
19
|
+
repository [repository ...]
|
|
20
|
+
|
|
21
|
+
Download (and keep in sync) the releases from a set of GitHub projects.
|
|
22
|
+
|
|
23
|
+
positional arguments:
|
|
24
|
+
repository GitHub repository to fetch releases from
|
|
25
|
+
|
|
26
|
+
options:
|
|
27
|
+
-h, --help show this help message and exit
|
|
28
|
+
--verbose, -v show verbose output
|
|
29
|
+
--download-source, -s
|
|
30
|
+
also download source for each release
|
|
31
|
+
--output OUTPUT output directory
|
|
32
|
+
|
|
33
|
+
Set the GITHUB_TOKEN environment variable to use token-based authentication.
|
|
34
|
+
This is required for accessing private repositories and can help with API rate
|
|
35
|
+
limits.
|
|
36
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
setup.py
|
|
4
|
+
download_github_releases/__init__.py
|
|
5
|
+
download_github_releases/__main__.py
|
|
6
|
+
download_github_releases/download_github_releases.py
|
|
7
|
+
download_github_releases.egg-info/PKG-INFO
|
|
8
|
+
download_github_releases.egg-info/SOURCES.txt
|
|
9
|
+
download_github_releases.egg-info/dependency_links.txt
|
|
10
|
+
download_github_releases.egg-info/entry_points.txt
|
|
11
|
+
download_github_releases.egg-info/requires.txt
|
|
12
|
+
download_github_releases.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
download_github_releases
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta:__legacy__"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "download-github-releases"
|
|
7
|
+
description = "Download (and keep in sync) the releases from a set of GitHub projects"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
license = "MIT"
|
|
10
|
+
authors = [
|
|
11
|
+
{name = "Jason Morley", email = "hello@jbmorley.co.uk"}
|
|
12
|
+
]
|
|
13
|
+
dependencies = [
|
|
14
|
+
"requests",
|
|
15
|
+
]
|
|
16
|
+
dynamic = ["version"]
|
|
17
|
+
|
|
18
|
+
[project.scripts]
|
|
19
|
+
download-github-releases = "download_github_releases.download_github_releases:main"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2021-2026 Jason Morley
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
import os
|
|
24
|
+
|
|
25
|
+
from setuptools import setup
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
setup(version=os.environ["VERSION"] if "VERSION" in os.environ else "0.0.0")
|