Skip to content

Commit 29e3241

Browse files
committed
Add time-created info to download_gha_artifacts.py
1 parent 215996b commit 29e3241

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

ci/download_gha_artifacts.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
"""Use the GitHub API to download built artifacts."""
55

6+
import datetime
67
import os
78
import os.path
9+
import time
810
import zipfile
911

1012
import requests
@@ -25,6 +27,14 @@ def unpack_zipfile(filename):
2527
print(f" extracting {name}")
2628
z.extract(name)
2729

30+
def utc2local(timestring):
31+
dt = datetime.datetime
32+
utc = dt.fromisoformat(timestring.rstrip("Z"))
33+
epoch = time.mktime(utc.timetuple())
34+
offset = dt.fromtimestamp(epoch) - dt.utcfromtimestamp(epoch)
35+
local = utc + offset
36+
return local.strftime("%Y-%m-%d %H:%M:%S")
37+
2838
dest = "dist"
2939
repo_owner = "nedbat/coveragepy"
3040
temp_zip = "artifacts.zip"
@@ -35,6 +45,8 @@ def unpack_zipfile(filename):
3545

3646
r = requests.get(f"https://api.github.com/repos/{repo_owner}/actions/artifacts")
3747
latest = max(r.json()["artifacts"], key=lambda a: a["created_at"])
48+
49+
print(f"Artifacts created at {utc2local(latest['created_at'])}")
3850
download_url(latest["archive_download_url"], temp_zip)
3951
unpack_zipfile(temp_zip)
4052
os.remove(temp_zip)

0 commit comments

Comments
 (0)