Skip to content

Commit

Permalink
[tda] add code to get latest mobile release from empower repo
Browse files Browse the repository at this point in the history
  • Loading branch information
realkosty committed Nov 3, 2023
1 parent ca9aefb commit 4896594
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Empty file modified tda/latest_github_release.py
100644 → 100755
Empty file.
20 changes: 18 additions & 2 deletions tda/release_version_manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import requests
import os
from datetime import datetime

GITHUB_API_RELEASES_MAX_RESULTS = 30

GITHUB_REPOS = {
# platform: <github repo name>
Expand Down Expand Up @@ -41,5 +44,18 @@ def latest_ios_github_release():

def determine_latest_release_version(platform):
repo_name = GITHUB_REPOS[platform]
react_native_releases = requests.get(f"https://api.github.com/repos/sentry-demos/{repo_name}/releases")
return react_native_releases.json()[0]['tag_name']
releases = requests.get(f"https://api.github.com/repos/sentry-demos/{repo_name}/releases").json()
if repo_name != 'empower':
return releases[0]['tag_name']
else:
# When using <platform>-1.2.3 format GH will order releases alphabetically, i.e. 0.0.21 -> 0.0.3
# We can't use "Latest" because we have multiple latest releasese - one for each platform
if len(releases) >= GITHUB_API_RELEASES_MAX_RESULTS:
raise NotImplementedError(
f"Github /releases API returned maximum number of results (${GITHUB_API_RELEASES_MAX_RESULTS}). " +
"Current implementation is not able to handle pagination. Please delete old releases or implement.")

platform_releases = list(filter(lambda r: r['tag_name'].startswith(platform + '-'), releases))
# Parse the 'published_at' times and sort the releases
platform_releases.sort(key=lambda release: datetime.strptime(release["published_at"], "%Y-%m-%dT%H:%M:%SZ"), reverse=True)
return platform_releases[0]['tag_name']
1 change: 1 addition & 0 deletions tda/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ source env/bin/activate
source .sauce_credentials
export LATEST_REACT_NATIVE_GITHUB_RELEASE=$(python3 latest_github_release.py react_native)
export LATEST_ANDROID_GITHUB_RELEASE=$(python3 latest_github_release.py android)
export LATEST_IOS_GITHUB_RELEASE=$(python3 latest_github_release.py android)

# First run ALL canaries to ensure not a single one fails
for job in jobs/*.sh; do
Expand Down

0 comments on commit 4896594

Please sign in to comment.