@@ -34,9 +34,10 @@ def fetch_with_retry(url, headers, max_retries=3, timeout=10):
3434
3535
3636ppktstore_repo = "monarch-initiative/phenopacket-store"
37+ hpo_repo = "obophenotype/human-phenotype-ontology"
3738this_repo = os .environ ["GITHUB_REPOSITORY" ]
3839token = os .environ ["GH_TOKEN" ]
39- var_name = "LAST_RUN_RELEASE"
40+ ppkt_last_run_version = "LAST_RUN_RELEASE"
4041
4142# Get phenopacket-store latest version
4243latest = fetch_with_retry (
@@ -45,41 +46,54 @@ def fetch_with_retry(url, headers, max_retries=3, timeout=10):
4546).json ().get ("tag_name" )
4647
4748if not latest :
48- print ("Error: Could not fetch latest release tag!" )
49+ print ("Error: Could not fetch latest phenopacket-store release tag!" )
4950 sys .exit (1 )
50-
51+
52+ # Get HPO latest version
53+ latest_hpo = fetch_with_retry (
54+ f"https://api.github.com/repos/{ hpo_repo } /releases/latest" ,
55+ headers = {"Accept" : "application/vnd.github+json" }
56+ ).json ().get ("tag_name" )
57+
58+ if not latest_hpo :
59+ print ("Error: Could not fetch latest HPO release tag!" )
60+ sys .exit (1 )
61+
5162# Get last version of phenopacket-store that ppkt2prompt ran
5263r = fetch_with_retry (
53- f"https://api.github.com/repos/{ this_repo } /actions/variables/{ var_name } " ,
64+ f"https://api.github.com/repos/{ this_repo } /actions/variables/{ ppkt_last_run_version } " ,
5465 headers = {
5566 "Authorization" : f"token { token } " ,
5667 "Accept" : "application/vnd.github+json"
5768 }
5869)
5970
6071if r .status_code != 200 :
61- print (f"Error: Could not fetch repository variable '{ var_name } '! Status code: { r .status_code } " )
72+ print (f"Error: Could not fetch repository variable '{ ppkt_last_run_version } '! Status code: { r .status_code } " )
6273 sys .exit (1 )
6374
6475stored = r .json ().get ("value" )
6576if stored is None :
66- print (f"Error: Repository variable '{ var_name } ' returned no value." )
77+ print (f"Error: Repository variable '{ ppkt_last_run_version } ' returned no value." )
6778 sys .exit (1 )
6879
6980latest = latest .strip ()
7081stored = stored .strip ()
82+ latest_hpo = latest_hpo .strip ()
83+
7184new_release = (latest != stored )
7285
7386with open (os .environ ["GITHUB_OUTPUT" ], "a" ) as gh_out :
74- gh_out .write (f"latest_tag={ latest } \n " )
7587 gh_out .write (f"new_release={ str (new_release ).lower ()} \n " )
88+ gh_out .write (f"latest_store_tag={ latest } \n " )
89+ gh_out .write (f"latest_hpo_tag={ latest_hpo } \n " )
7690
7791
7892# Update variable if needed
7993if new_release :
80- payload = {"name" : var_name , "value" : latest }
94+ payload = {"name" : ppkt_last_run_version , "value" : latest }
8195 res = requests .patch (
82- f"https://api.github.com/repos/{ this_repo } /actions/variables/{ var_name } " ,
96+ f"https://api.github.com/repos/{ this_repo } /actions/variables/{ ppkt_last_run_version } " ,
8397 headers = {"Authorization" : f"token { token } " ,
8498 "Accept" : "application/vnd.github+json" },
8599 json = payload ,
0 commit comments