Skip to content

Commit d418525

Browse files
authored
Merge pull request #8734 from element-hq/feature/bma/fixRelease
Fix release script which download artifact
2 parents a5df764 + 122018d commit d418525

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Main changes in this version: add Mobile Device Managament and functional members support.
1+
Main changes in this version: add Mobile Device Management and functional members support.
22
Full changelog: https://github.com/element-hq/element-android/releases

tools/release/download_github_artifacts.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
#
1717

1818
import argparse
19-
import hashlib
2019
import json
2120
import os
2221
# Run `pip3 install requests` if not installed yet
2322
import requests
23+
# Run `pip3 install re` if not installed yet
24+
import re
2425

2526
# This script downloads artifacts from GitHub.
2627
# Ref: https://docs.github.com/en/rest/actions/artifacts#get-an-artifact
@@ -65,22 +66,20 @@
6566
print(args)
6667

6768
# Split the artifact URL to get information
68-
# Ex: https://github.com/element-hq/element-android/suites/9293388174/artifacts/435942121
69+
# Ex: https://github.com/element-hq/element-android/actions/runs/7460386865/artifacts/1156548729
6970
artifactUrl = args.artifactUrl
70-
if not artifactUrl.startswith('https://github.com/'):
71-
print("❌ Invalid parameter --artifactUrl %s. Must start with 'https://github.com/'" % artifactUrl)
72-
exit(1)
73-
if "/artifacts/" not in artifactUrl:
74-
print("❌ Invalid parameter --artifactUrl %s. Must contain '/artifacts/'" % artifactUrl)
75-
exit(1)
76-
artifactItems = artifactUrl.split("/")
77-
if len(artifactItems) != 9:
78-
print("❌ Invalid parameter --artifactUrl %s. Please check the format." % (artifactUrl))
71+
72+
url_regex = r"https://github.com/(.+?)/(.+?)/actions/runs/.+?/artifacts/(.+)"
73+
result = re.search(url_regex, artifactUrl)
74+
75+
if result is None:
76+
print(
77+
"❌ Invalid parameter --artifactUrl '%s'. Please check the format.\nIt should be something like: %s" %
78+
(artifactUrl, 'https://github.com/element-hq/element-android/actions/runs/7460386865/artifacts/1156548729')
79+
)
7980
exit(1)
8081

81-
gitHubRepoOwner = artifactItems[3]
82-
gitHubRepo = artifactItems[4]
83-
artifactId = artifactItems[8]
82+
(gitHubRepoOwner, gitHubRepo, artifactId) = result.groups()
8483

8584
if args.verbose:
8685
print("gitHubRepoOwner: %s, gitHubRepo: %s, artifactId: %s" % (gitHubRepoOwner, gitHubRepo, artifactId))

0 commit comments

Comments
 (0)