From c02bb2dc84a73b018a29c6d840ccf20e69f40bbf Mon Sep 17 00:00:00 2001 From: Rim Date: Fri, 28 Feb 2025 18:05:56 -0500 Subject: [PATCH] feat(): add build.yml --- .gitea/workflows/build.yml | 45 ++++++++++++++++++++++++++++++++++++++ build.py | 5 ++++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/build.yml diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..9eb8103 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,45 @@ +name: Build Python Executable + +on: + push: + branches: + - main + schedule: + # - cron: "0 0 * * 0" # Runs weekly on Sunday at midnight UTC + # - cron: "*/1 * * * *" # Runs every 1 minute + - cron: "0 0 0 0 0" + +jobs: + build: + runs-on: ubuntu-latest # Matches the label you assigned to your Gitea runner + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set Up Python 3.9.13 + uses: actions/setup-python@v4 + with: + python-version: "3.9.13" + + - name: Create virtual environment + run: | + python3.9 -m venv venv + python --version + + - name: Install dependencies + run: | + source venv/bin/activate + python --version + pip install aiohttp + pip install zope.interface + pip install pip wheel build ./deps/cod_api-2.0.2-py3-none-any.whl + pip install pyinstaller==6.0.0 + pip uninstall enum34 -y + pyinstaller cod_api_tool.py --name cod_api_tool.exe --noconfirm --onefile --console --distpath bin/build --add-data=deps/frequencies.json:charset_normalizer/assets --add-data=data/replacements.json:data + + - name: Upload Build Artifacts + uses: actions/upload-artifact@v3 + with: + name: cod_api_tool + path: bin/build/cod_api_tool.exe diff --git a/build.py b/build.py index 0c984da..ef1be9e 100644 --- a/build.py +++ b/build.py @@ -21,7 +21,10 @@ if not os.path.exists(replacements_json): sys.exit(1) # Activate the virtual environment -venv_activation_script = os.path.join(os.getcwd(), 'venv', 'Scripts', 'activate') +if sys.platform == 'win32': + venv_activation_script = os.path.join(os.getcwd(), 'venv', 'Scripts', 'activate') +else: + venv_activation_script = os.path.join(os.getcwd(), 'venv', 'bin', 'activate') subprocess.call(venv_activation_script, shell=True) # Run PyInstaller