Skip to content

Commit

Permalink
fix assignment of build to channel
Browse files Browse the repository at this point in the history
  • Loading branch information
bmos committed Feb 26, 2024
1 parent 2068efe commit 2c3be58
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/forge_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,9 @@ def upload_and_publish(self, session: requestium.Session, urls: ForgeURLs, new_f
if channel is ReleaseChannel.NONE:
logging.info("Target channel is set to none, not setting new build to a release channel.")
return
latest_build = max(self.get_item_builds(session, urls), key=lambda build: int(build["build_num"]))
logging.info("Retrieved latest build info: %s", latest_build)
latest_build_id = max(self.get_item_builds(session, urls), key=lambda build: int(build["build_num"]))["id"]
logging.info("Assigning new build to Forge channel: %s: %s", channel, channel.value)
self.set_build_channel(session, urls, latest_build["build_num"], channel)
self.set_build_channel(session, urls, latest_build_id, channel)

def add_build(self, driver: webdriver, new_builds: list[Path]) -> None:
"""Uploads new build(s) to this Forge item via dropzone web element."""
Expand All @@ -142,10 +141,10 @@ def get_item_builds(self, session: requestium.Session, urls: ForgeURLs) -> dict
)
return response.json()["data"]

def set_build_channel(self, session: requestium.Session, urls: ForgeURLs, build_num: str, channel: ReleaseChannel) -> bool:
def set_build_channel(self, session: requestium.Session, urls: ForgeURLs, build_id: str, channel: ReleaseChannel) -> bool:
"""Sets the build channel of this Forge item to the specified value, returning True on 200 OK"""
response = session.post(
f"{urls.API_CRAFTER_ITEMS}/{self.item_id}/builds/{build_num}/channels/{channel.value}",
f"{urls.API_CRAFTER_ITEMS}/{self.item_id}/builds/{build_id}/channels/{channel.value}",
)
return response.status_code == 200

Expand Down

0 comments on commit 2c3be58

Please sign in to comment.