From 43d09314ff15e43cea37deb3eaafdbbb46f0c16f Mon Sep 17 00:00:00 2001 From: Radiquum Date: Sat, 21 Jun 2025 00:02:09 +0500 Subject: [PATCH 1/7] refactor: use shell=True on subproccess call only on nt systems should fix linux usage --- build.py | 8 +++++--- dev.py | 6 ++++-- src/cli.py | 2 ++ src/main.py | 2 ++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/build.py b/build.py index c49ada6..2a02c1c 100644 --- a/build.py +++ b/build.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import subprocess import os import shutil @@ -56,7 +58,7 @@ if __name__ == "__main__": # TODO?: install node deps automatically if not args.no_rebuild: - build = subprocess.call(["bun", "run", "build"], cwd="./gui", shell=True) + build = subprocess.call(["bun", "run", "build"], cwd="./gui", shell=(os.name == "nt")) if build != 0: print("[ERROR] Next.js gui has failed to build") raise @@ -110,7 +112,7 @@ if __name__ == "__main__": "templates:templates", ], cwd="./dist", - shell=True, + shell=(os.name == "nt"), ) if build != 0: print("[ERROR] pyinstaller has failed to build an app") @@ -140,7 +142,7 @@ if __name__ == "__main__": "mc_version.json:.", ], cwd="./dist", - shell=True, + shell=(os.name == "nt"), ) if build != 0: print("[ERROR] pyinstaller has failed to build an app") diff --git a/dev.py b/dev.py index 6289f5b..38f4352 100644 --- a/dev.py +++ b/dev.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import subprocess import time import os @@ -13,10 +15,10 @@ if __name__ == "__main__": # TODO?: install node deps automatically gui_proc = subprocess.Popen( - ["bun", "run", "dev"], cwd="./gui", env=environment, shell=True + ["bun", "run", "dev"], cwd="./gui", env=environment, shell=(os.name == "nt") ) app_proc = subprocess.Popen( - ["python", "main.py"], cwd="./src", env=environment, shell=True + ["python", "main.py"], cwd="./src", env=environment, shell=(os.name == "nt") ) try: diff --git a/src/cli.py b/src/cli.py index 31b1e71..f3c0884 100644 --- a/src/cli.py +++ b/src/cli.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import os from sys import exit diff --git a/src/main.py b/src/main.py index 80b59c8..2a76764 100644 --- a/src/main.py +++ b/src/main.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + from flask import Flask from flask import render_template, send_file, abort from flaskwebgui import FlaskUI # import FlaskUI From dd840208519a11870d22893997fae30f98e334ae Mon Sep 17 00:00:00 2001 From: Radiquum Date: Wed, 25 Jun 2025 15:19:21 +0500 Subject: [PATCH 2/7] feat/ci: add build ci --- .github/workflows/build.yml | 90 +++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..eacca40 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,90 @@ +name: "YAMPD Build" + +on: + push: + branches: + - main + + workflow_dispatch: + +concurrency: + group: "build" + cancel-in-progress: true + +defaults: + run: + shell: bash + +jobs: + build_linux: + name: "linux-build" + runs-on: ubuntu-latest + steps: + - name: "[DEPS/Tool] bun" + uses: oven-sh/setup-bun@v2 + - name: "[DEPS/Tool] python" + uses: actions/setup-python@v5 + with: + python-version: '3.13.2' + - name: "[Preparing] cloning repository" + uses: actions/checkout@v4 + - name: "[DEPS/Build] Backend" + run: | + "pip install -r ./requirements.txt" + "pip install -r ./requirements.dev.txt" + - name: "[DEPS/Build] Frontend" + run: "cd ./gui && bun install && cd .." + - name: "[Build] Building artifact" + run: "python ./build.py --exe" + - name: "[Publish] Upload GUI Artifact" + uses: actions/upload-artifact@v4 + with: + name: "YAMPD-gui" + path: "./dist/gui" + if-no-files-found: warn + retention-days: 14 + - name: "[Publish] Upload CLI Artifact" + uses: actions/upload-artifact@v4 + with: + name: "YAMPD-cli" + path: "./dist/cli" + if-no-files-found: warn + retention-days: 14 + + build_windows: + name: "windows-build" + runs-on: windows-latest + steps: + - name: "[DEPS/Tool] bun" + uses: oven-sh/setup-bun@v2 + - name: "[DEPS/Tool] python" + uses: actions/setup-python@v5 + with: + python-version: '3.13.2' + - name: "[Preparing] cloning repository" + uses: actions/checkout@v4 + - name: "[DEPS/Build] Backend" + run: | + "pip install -r ./requirements.txt" + "pip install -r ./requirements.dev.txt" + - name: "[DEPS/Build] Frontend" + run: | + "cd ./gui" + "bun install" + "cd .." + - name: "[Build] Building artifact" + run: "python ./build.py --exe" + - name: "[Publish] Upload GUI Artifact" + uses: actions/upload-artifact@v4 + with: + name: "YAMPD-gui.exe" + path: "./dist/gui.exe" + if-no-files-found: warn + retention-days: 14 + - name: "[Publish] Upload CLI Artifact" + uses: actions/upload-artifact@v4 + with: + name: "YAMPD-cli.exe" + path: "./dist/cli.exe" + if-no-files-found: warn + retention-days: 14 From b815947e613ab55447b5edb4ddb4342fb8cf545f Mon Sep 17 00:00:00 2001 From: Radiquum Date: Wed, 25 Jun 2025 15:23:26 +0500 Subject: [PATCH 3/7] fix/ci: linux --- .github/workflows/build.yml | 97 ++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 45 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eacca40..8a1ec75 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,71 +20,78 @@ jobs: name: "linux-build" runs-on: ubuntu-latest steps: + - name: "[Preparing] cloning repository" + uses: actions/checkout@v4 - name: "[DEPS/Tool] bun" uses: oven-sh/setup-bun@v2 - name: "[DEPS/Tool] python" uses: actions/setup-python@v5 with: python-version: '3.13.2' - - name: "[Preparing] cloning repository" - uses: actions/checkout@v4 + cache: 'pip' + - name: "[DEBUG] check if pip is installed" + run: | + which pip + pip --version - name: "[DEPS/Build] Backend" run: | - "pip install -r ./requirements.txt" - "pip install -r ./requirements.dev.txt" + pip install -r requirements.txt + pip install -r requirements.dev.txt - name: "[DEPS/Build] Frontend" - run: "cd ./gui && bun install && cd .." + run: bun install + working-directory: ./gui - name: "[Build] Building artifact" - run: "python ./build.py --exe" + run: python ./build.py --exe - name: "[Publish] Upload GUI Artifact" uses: actions/upload-artifact@v4 with: name: "YAMPD-gui" - path: "./dist/gui" + path: "./gui" + working-directory: ./dist if-no-files-found: warn retention-days: 14 - name: "[Publish] Upload CLI Artifact" uses: actions/upload-artifact@v4 with: name: "YAMPD-cli" - path: "./dist/cli" + path: "./cli" + working-directory: ./dist if-no-files-found: warn retention-days: 14 - build_windows: - name: "windows-build" - runs-on: windows-latest - steps: - - name: "[DEPS/Tool] bun" - uses: oven-sh/setup-bun@v2 - - name: "[DEPS/Tool] python" - uses: actions/setup-python@v5 - with: - python-version: '3.13.2' - - name: "[Preparing] cloning repository" - uses: actions/checkout@v4 - - name: "[DEPS/Build] Backend" - run: | - "pip install -r ./requirements.txt" - "pip install -r ./requirements.dev.txt" - - name: "[DEPS/Build] Frontend" - run: | - "cd ./gui" - "bun install" - "cd .." - - name: "[Build] Building artifact" - run: "python ./build.py --exe" - - name: "[Publish] Upload GUI Artifact" - uses: actions/upload-artifact@v4 - with: - name: "YAMPD-gui.exe" - path: "./dist/gui.exe" - if-no-files-found: warn - retention-days: 14 - - name: "[Publish] Upload CLI Artifact" - uses: actions/upload-artifact@v4 - with: - name: "YAMPD-cli.exe" - path: "./dist/cli.exe" - if-no-files-found: warn - retention-days: 14 + # build_windows: + # name: "windows-build" + # runs-on: windows-latest + # steps: + # - name: "[Preparing] cloning repository" + # uses: actions/checkout@v4 + # - name: "[DEPS/Tool] bun" + # uses: oven-sh/setup-bun@v2 + # - name: "[DEPS/Tool] python" + # uses: actions/setup-python@v5 + # with: + # python-version: '3.13.2' + # cache: 'pip' + # - name: "[DEPS/Build] Backend" + # run: | + # "pip install -r requirements.txt" + # "pip install -r requirements.dev.txt" + # - name: "[DEPS/Build] Frontend" + # run: "bun install" + # working-directory: ./gui + # - name: "[Build] Building artifact" + # run: "python ./build.py --exe" + # - name: "[Publish] Upload GUI Artifact" + # uses: actions/upload-artifact@v4 + # with: + # name: "YAMPD-gui.exe" + # path: "./dist/gui.exe" + # if-no-files-found: warn + # retention-days: 14 + # - name: "[Publish] Upload CLI Artifact" + # uses: actions/upload-artifact@v4 + # with: + # name: "YAMPD-cli.exe" + # path: "./dist/cli.exe" + # if-no-files-found: warn + # retention-days: 14 From 46f0674302cc8d45e747bb34c21a59be6cc8045c Mon Sep 17 00:00:00 2001 From: Radiquum Date: Wed, 25 Jun 2025 16:05:02 +0500 Subject: [PATCH 4/7] fix/ci: use the .build additional deps for python instead of .dev --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8a1ec75..936ef08 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: - name: "[DEPS/Build] Backend" run: | pip install -r requirements.txt - pip install -r requirements.dev.txt + pip install -r requirements.build.txt - name: "[DEPS/Build] Frontend" run: bun install working-directory: ./gui From 5b532e8e16f607dee76e5c64a82144ab50b1c9a9 Mon Sep 17 00:00:00 2001 From: Radiquum Date: Wed, 25 Jun 2025 16:08:56 +0500 Subject: [PATCH 5/7] fix/ci: upload artifact file path --- .github/workflows/build.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 936ef08..71c9452 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,16 +46,14 @@ jobs: uses: actions/upload-artifact@v4 with: name: "YAMPD-gui" - path: "./gui" - working-directory: ./dist + path: "./dist/gui" if-no-files-found: warn retention-days: 14 - name: "[Publish] Upload CLI Artifact" uses: actions/upload-artifact@v4 with: name: "YAMPD-cli" - path: "./cli" - working-directory: ./dist + path: "./dist/cli" if-no-files-found: warn retention-days: 14 From 40c68ba972efffafd47eaf03f747611cf0048600 Mon Sep 17 00:00:00 2001 From: Radiquum Date: Wed, 25 Jun 2025 16:18:44 +0500 Subject: [PATCH 6/7] fix/ci: use the right dist file name --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 71c9452..ff484e9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,15 +45,15 @@ jobs: - name: "[Publish] Upload GUI Artifact" uses: actions/upload-artifact@v4 with: - name: "YAMPD-gui" - path: "./dist/gui" + name: "YAMPD-gui-linux" + path: "./dist/yamcpack" if-no-files-found: warn retention-days: 14 - name: "[Publish] Upload CLI Artifact" uses: actions/upload-artifact@v4 with: - name: "YAMPD-cli" - path: "./dist/cli" + name: "YAMPD-cli-linux" + path: "./dist/yamcpack-cli" if-no-files-found: warn retention-days: 14 From 08c72152d018b1a93df60c8cb8d78c0b76c6da5f Mon Sep 17 00:00:00 2001 From: Radiquum Date: Wed, 25 Jun 2025 16:24:14 +0500 Subject: [PATCH 7/7] feat/ci: re-enable windows build --- .github/workflows/build.yml | 72 ++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ff484e9..11735e2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,39 +57,39 @@ jobs: if-no-files-found: warn retention-days: 14 - # build_windows: - # name: "windows-build" - # runs-on: windows-latest - # steps: - # - name: "[Preparing] cloning repository" - # uses: actions/checkout@v4 - # - name: "[DEPS/Tool] bun" - # uses: oven-sh/setup-bun@v2 - # - name: "[DEPS/Tool] python" - # uses: actions/setup-python@v5 - # with: - # python-version: '3.13.2' - # cache: 'pip' - # - name: "[DEPS/Build] Backend" - # run: | - # "pip install -r requirements.txt" - # "pip install -r requirements.dev.txt" - # - name: "[DEPS/Build] Frontend" - # run: "bun install" - # working-directory: ./gui - # - name: "[Build] Building artifact" - # run: "python ./build.py --exe" - # - name: "[Publish] Upload GUI Artifact" - # uses: actions/upload-artifact@v4 - # with: - # name: "YAMPD-gui.exe" - # path: "./dist/gui.exe" - # if-no-files-found: warn - # retention-days: 14 - # - name: "[Publish] Upload CLI Artifact" - # uses: actions/upload-artifact@v4 - # with: - # name: "YAMPD-cli.exe" - # path: "./dist/cli.exe" - # if-no-files-found: warn - # retention-days: 14 + build_windows: + name: "windows-build" + runs-on: windows-latest + steps: + - name: "[Preparing] cloning repository" + uses: actions/checkout@v4 + - name: "[DEPS/Tool] bun" + uses: oven-sh/setup-bun@v2 + - name: "[DEPS/Tool] python" + uses: actions/setup-python@v5 + with: + python-version: '3.13.2' + cache: 'pip' + - name: "[DEPS/Build] Backend" + run: | + pip install -r requirements.txt + pip install -r requirements.build.txt + - name: "[DEPS/Build] Frontend" + run: "bun install" + working-directory: ./gui + - name: "[Build] Building artifact" + run: python ./build.py --exe + - name: "[Publish] Upload GUI Artifact" + uses: actions/upload-artifact@v4 + with: + name: "YAMPD-gui-windows.exe" + path: "./dist/yamcpack.exe" + if-no-files-found: warn + retention-days: 14 + - name: "[Publish] Upload CLI Artifact" + uses: actions/upload-artifact@v4 + with: + name: "YAMPD-cli-windows.exe" + path: "./dist/yamcpack-cli.exe" + if-no-files-found: warn + retention-days: 14