Skip to content

Commit

Permalink
Attempting to fix the last two releases action
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaiaeroastro committed Jul 9, 2024
1 parent 3770943 commit b26e6e6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -637,12 +637,12 @@ jobs:
- name: Get latest lib3mf SDK release info from GitHub API
id: get_latest_release
run: |
echo "LATEST_LIB3MF_URL=$(curl -s https://api.github.com/repos/3MFConsortium/lib3mf/releases/latest | grep "browser_download_url.*lib3mf_sdk.zip" | cut -d '"' -f 4 | xargs)" >> $GITHUB_ENV
echo "LATEST_LIB3MF_URL=$(python CI/ci_cd_helper.py 0 --get-url | xargs)" >> $GITHUB_ENV
- name: Get second latest lib3mf SDK release info from GitHub API
id: get_second_latest_release
run: |
echo "SECOND_LATEST_LIB3MF_URL=$(curl -s https://api.github.com/repos/3MFConsortium/lib3mf/releases | grep "browser_download_url.*lib3mf_sdk.zip" | cut -d '"' -f 4 | sed -n '2p' | xargs)" >> $GITHUB_ENV
echo "SECOND_LATEST_LIB3MF_URL=$(python CI/ci_cd_helper.py 1 --get-url | xargs)" >> $GITHUB_ENV
- name: Download latest lib3mf SDK zip
run: |
Expand Down
38 changes: 38 additions & 0 deletions CI/ci_cd_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import argparse
import urllib.request
import json

def get_sdk_url(index):
url = "https://api.github.com/repos/3MFConsortium/lib3mf/releases"

try:
with urllib.request.urlopen(url) as response:
data = response.read().decode('utf-8')

releases = json.loads(data)
selected_release = releases[index] # Select the release by index
for asset in selected_release['assets']:
asset_name = str(asset['name'])
if asset_name.startswith("lib3mf_sdk") and asset_name.endswith(".zip"):
return asset['browser_download_url']
return None
except Exception as e:
print(f"Error fetching the SDK URL: {e}")
return None

def main():
parser = argparse.ArgumentParser(description="Fetch a specific release URL for the 3MFConsortium/lib3mf repository.")
parser.add_argument('index', type=int, help='Index of the release (0 for latest, 1 for second latest, etc.)')
parser.add_argument('--get-url', action='store_true', help='Get the specified release URL')

args = parser.parse_args()

if args.get_url:
url = get_sdk_url(args.index)
if url:
print(url)
else:
print("FAIL")

if __name__ == "__main__":
main()

0 comments on commit b26e6e6

Please sign in to comment.