Skip to content

Commit

Permalink
ci: switch to uv package manager
Browse files Browse the repository at this point in the history
  • Loading branch information
ViRb3 committed Dec 10, 2024
1 parent 582d398 commit 1c45fc7
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 279 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v4
- name: Install uv
uses: astral-sh/setup-uv@v4

- uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: "3.13"

- name: Build
run: |
pip3 install poetry==1.5.1
poetry config virtualenvs.create false
poetry install
python3 main.py
uv run python3 main.py
echo "NEW_TAG=$(cat NEW_TAG.txt)" >> $GITHUB_ENV
- name: Release
if: hashFiles('NEW_TAG.txt') != ''
uses: ncipollo/release-action@v1.10.0
uses: ncipollo/release-action@v1
with:
artifacts: build/*.zip,build/updater.json
tag: "${{ env.NEW_TAG }}"
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/.vscode/
/downloads/
/builds/
/build/
.DS_Store

# Created by https://www.gitignore.io/api/venv,python,visualstudiocode
# Edit at https://www.gitignore.io/?templates=venv,python,visualstudiocode
Expand Down
26 changes: 15 additions & 11 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


def download_file(url: str, path: Path):
file_name = url[url.rfind("/") + 1:]
file_name = url[url.rfind("/") + 1 :]
logger.info(f"Downloading '{file_name}' to '{path}'")

if path.exists():
Expand Down Expand Up @@ -79,7 +79,9 @@ def fill_module(arch: str, frida_tag: str, project_tag: str):
threading.current_thread().setName(arch)
logger.info(f"Filling module for arch '{arch}'")

frida_download_url = f"https://github.com/frida/frida/releases/download/{frida_tag}/"
frida_download_url = (
f"https://github.com/frida/frida/releases/download/{frida_tag}/"
)
frida_server = f"frida-server-{frida_tag}-android-{arch}.xz"
frida_server_path = PATH_DOWNLOADS.joinpath(frida_server)

Expand All @@ -92,15 +94,16 @@ def fill_module(arch: str, frida_tag: str, project_tag: str):
def create_updater_json(project_tag: str):
logger.info("Creating updater.json")

updater ={
updater = {
"version": project_tag,
"versionCode": int(project_tag.replace(".", "").replace("-", "")),
"zipUrl": f"https://github.com/ViRb3/magisk-frida/releases/download/{project_tag}/MagiskFrida-{project_tag}.zip",
"changelog": "https://raw.githubusercontent.com/ViRb3/magisk-frida/master/CHANGELOG.md"
"changelog": "https://raw.githubusercontent.com/ViRb3/magisk-frida/master/CHANGELOG.md",
}

with open(PATH_BUILD.joinpath("updater.json"), "w", newline="\n") as f:
f.write(json.dumps(updater, indent = 4))
f.write(json.dumps(updater, indent=4))


def package_module(project_tag: str):
logger.info("Packaging module")
Expand All @@ -112,8 +115,10 @@ def package_module(project_tag: str):
for file_name in files:
if file_name == "placeholder" or file_name == ".gitkeep":
continue
zf.write(Path(root).joinpath(file_name),
arcname=Path(root).relative_to(PATH_BUILD_TMP).joinpath(file_name))
zf.write(
Path(root).joinpath(file_name),
arcname=Path(root).relative_to(PATH_BUILD_TMP).joinpath(file_name),
)

shutil.rmtree(PATH_BUILD_TMP)

Expand All @@ -126,13 +131,12 @@ def do_build(frida_tag: str, project_tag: str):

archs = ["arm", "arm64", "x86", "x86_64"]
executor = concurrent.futures.ProcessPoolExecutor()
futures = [executor.submit(fill_module, arch, frida_tag, project_tag)
for arch in archs]
futures = [
executor.submit(fill_module, arch, frida_tag, project_tag) for arch in archs
]
for future in concurrent.futures.as_completed(futures):
if future.exception() is not None:
raise future.exception()
# TODO: Causes 'OSError: The handle is invalid' in Python 3.7, revert after update
# executor.shutdown()

package_module(project_tag)
create_updater_json(project_tag)
Expand Down
8 changes: 4 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ def main():
last_commit_tag = util.get_last_commit_tag()
new_project_tag = "0"

if last_frida_tag != util.strip_revision(last_project_tag) \
or (last_frida_tag != util.strip_revision(last_commit_tag)
and util.get_commit_message().lower() == "release"):

if last_frida_tag != util.strip_revision(last_project_tag) or (
last_frida_tag != util.strip_revision(last_commit_tag)
and util.get_commit_message().lower() == "release"
):
new_project_tag = util.get_next_revision(last_frida_tag)
print(f"Update needed to {new_project_tag}")

Expand Down
Loading

0 comments on commit 1c45fc7

Please sign in to comment.