|
34 | 34 | import urllib3
|
35 | 35 | from github3 import login
|
36 | 36 | from requests.auth import HTTPBasicAuth
|
37 |
| -from requests import post, get |
| 37 | +from requests import post, get, head |
38 | 38 | from build_server import output, run_command, error, truncate, zulip_upload_log, get_release, upload, \
|
39 | 39 | errors_detected, log, version_info, parse_version_info
|
40 | 40 |
|
41 | 41 | PATH = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) # Primary openshot folder
|
42 | 42 | RELEASE_NAME_REGEX = re.compile(r'^OpenShot-v.*?(-.*?)-x86[_64]*')
|
| 43 | +DOWNLOAD_PAGE_URLS = re.compile(r'"(//github.com/OpenShot/openshot-qt/releases/download/v.*?/OpenShot-.*?)"', |
| 44 | + re.MULTILINE) |
43 | 45 |
|
44 | 46 | # Access info class (for version info)
|
45 | 47 | sys.path.append(os.path.join(PATH, 'src', 'classes'))
|
|
266 | 268 | (r.status_code, os.getenv('OPENSHOT_ORG_USER'),
|
267 | 269 | r.json().get('message', 'no error message found')))
|
268 | 270 | else:
|
| 271 | + # Verify download links on openshot.org are correct (and include the new release version) |
| 272 | + r = get("https://www.openshot.org/download/") |
| 273 | + if r.ok: |
| 274 | + # Find all release download URLs on openshot.org |
| 275 | + urls = DOWNLOAD_PAGE_URLS.findall(r.content.decode('UTF-8')) |
| 276 | + for url in urls: |
| 277 | + # Only GET the header of each URL, to validate it is valid and found |
| 278 | + r = head("https:" + url) |
| 279 | + if r.ok and r.reason == "Found": |
| 280 | + output("Validation of URL successful: %s" % url) |
| 281 | + else: |
| 282 | + raise Exception("Validation of URL FAILED: %s, %s, %s" % (url, r.status_code, r.reason)) |
| 283 | + |
| 284 | + # Validate the current version is found in each URL |
| 285 | + if version_info.get('openshot-qt', {}).get('VERSION', 'N/A') not in url: |
| 286 | + raise Exception("Validation of URL FAILED. Missing version %s: %s, %s, %s" % |
| 287 | + (version_info.get('openshot-qt', {}).get('VERSION', 'N/A'), url, |
| 288 | + r.status_code, r.reason)) |
| 289 | + else: |
| 290 | + raise Exception("Failed to GET openshot.org/download for URL validation: %s" % r.status_code) |
| 291 | + |
269 | 292 | # Publish the release (make new version visible on openshot.org, and make blog post visible)
|
270 | 293 | auth = HTTPBasicAuth(os.getenv('OPENSHOT_ORG_USER'), os.getenv('OPENSHOT_ORG_PASS'))
|
271 | 294 | r = post("https://www.openshot.org/api/release/publish/", auth=auth, data={"version": github_release.tag_name })
|
|
274 | 297 | (r.status_code, os.getenv('OPENSHOT_ORG_USER'),
|
275 | 298 | r.json().get('message', 'no error message found')))
|
276 | 299 |
|
| 300 | + # Publish GitHub Release objects (in all 3 repos) |
277 | 301 | for repo_name in repo_names:
|
278 | 302 | # If NO release is found, create a new one
|
279 | 303 | github_release = releases.get(repo_name)
|
|
0 commit comments