164 |
165 |
166 | 🙏 Praise 🙏 be 🙏 to 🙏 Wharton 🙏
167 |
168 |
169 |
170 |
--------------------------------------------------------------------------------
/entrypoint.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | import os
3 | import re
4 | import subprocess
5 | import requests
6 | import json
7 | import uuid
8 | import zipfile
9 | import stat
10 | from itertools import zip_longest
11 |
12 |
13 | def find_tool_coordinates():
14 | input_lib_version = os.getenv("INPUT_LIB_VERSION", "").strip()
15 | diffuse_repo = os.getenv("INPUT_DIFFUSE_REPO", "").strip()
16 | if not diffuse_repo:
17 | raise RuntimeError("You must provide valid `diffuse-repo` input")
18 | if not input_lib_version:
19 | raise RuntimeError("You must provide valid `lib-version` input")
20 |
21 | if input_lib_version == "latest":
22 | request_url = "https://api.github.com/repos/{0}/releases/latest".format(diffuse_repo)
23 | else:
24 | request_url = "https://api.github.com/repos/{0}/releases/tags/{1}".format(diffuse_repo, input_lib_version)
25 |
26 | response = requests.get(
27 | request_url,
28 | headers={
29 | "Content-Type": "application/vnd.github.v3+json",
30 | "Authorization": "token {0}".format(os.getenv("INPUT_GITHUB_TOKEN", ""))
31 | }
32 | )
33 |
34 | if is_debug():
35 | print("X-RateLimit-Limit: {0}".format(response.headers["X-RateLimit-Limit"]))
36 | print("X-RateLimit-Used: {0}".format(response.headers["X-RateLimit-Used"]))
37 | print("X-RateLimit-Remaining: {0}".format(response.headers["X-RateLimit-Remaining"]))
38 |
39 | parsed = json.loads(response.content)
40 |
41 | return parsed["assets"][0]["browser_download_url"], parsed["tag_name"]
42 |
43 |
44 | def is_debug():
45 | return os.getenv("INPUT_DEBUG", "false").casefold() == "true".casefold()
46 |
47 |
48 | def is_windows():
49 | return os.name == "nt"
50 |
51 |
52 | def github_output(key, message):
53 | delimiter = str(uuid.uuid4())
54 | with open(os.environ['GITHUB_OUTPUT'], mode='a', encoding='UTF-8') as fh:
55 | print(f'{key}<<${delimiter}', file=fh)
56 | print(message, file=fh)
57 | print(f'${delimiter}', file=fh)
58 |
59 |
60 | def section(_title, _content):
61 | return f"""
62 |