From 2e77e967ecce88a66e2a170f52e5fa9ad65102fe Mon Sep 17 00:00:00 2001 From: Daniel Milnes Date: Sat, 20 May 2023 14:21:15 +0100 Subject: [PATCH] Build Pyinstaller EXE from GitHub Actions (#109) * Use an older version of PyInstaller for now * Build Pyinstaller EXE from GitHub Actions * Poetry should be in path * Make sure Poetry is installed to PATH * Python on Windows is awful * Sanity check the EXE before releasing * Revert "Use an older version of PyInstaller for now" This reverts commit 7a068f8f8010b6701345f94289764302e41bb006. * Try not excluding bootlocale * Try a venv * Revert "Try a venv" This reverts commit 1619e0447e7e9c42ebb2e19b6e7bc47bf495f718. * Troubleshooting * Add missing argument --- .github/workflows/build.yaml | 52 ++++++++++++++++++++++++++++++++++++ .github/workflows/lint.yaml | 13 ++++----- hooks/hook-prettytable.py | 3 +++ 3 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/build.yaml create mode 100644 hooks/hook-prettytable.py diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..1a3feb2 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,52 @@ +--- +name: Build Releases +on: push + +jobs: + windows: + runs-on: windows-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.11' + + - name: Cache Python modules + uses: actions/cache@v1 + env: + cache-name: cache-node-modules + with: + path: ~/.pip + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/poetry.lock') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Install and configure Poetry + uses: snok/install-poetry@v1 + with: + version: 1.5.0 + virtualenvs-create: false + installer-parallel: true + + - name: Install Python Dependencies + run: C:\Users\runneradmin\.local\bin\poetry install --no-interaction --no-ansi + env: + PIP_CACHE_DIR: ~/.pip + + - name: Build Executable + run: C:\Users\runneradmin\.local\bin\poetry run pyinstaller --onefile --additional-hooks-dir hooks hstsparser.py + + - name: Print Helptext to Validate Executable + run: dist\hstsparser.exe -h + + - name: Upload Executable + uses: actions/upload-artifact@v3 + with: + name: hstsparser.exe + path: dist/hstsparser.exe diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 2600e81..d0e24a6 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -27,14 +27,15 @@ jobs: ${{ runner.os }}-build- ${{ runner.os }}- - - name: Install Poetry - run: curl -sSL https://install.python-poetry.org | python3 - - - - name: Disable Virtualenvs - run: $HOME/.local/bin/poetry config virtualenvs.create false + - name: Install and configure Poetry + uses: snok/install-poetry@v1 + with: + version: 1.5.0 + virtualenvs-create: false + installer-parallel: true - name: Install Python Dependencies - run: $HOME/.local/bin/poetry install --no-interaction --no-ansi + run: poetry install --no-interaction --no-ansi env: PIP_CACHE_DIR: ~/.pip diff --git a/hooks/hook-prettytable.py b/hooks/hook-prettytable.py new file mode 100644 index 0000000..a3bbf02 --- /dev/null +++ b/hooks/hook-prettytable.py @@ -0,0 +1,3 @@ +from PyInstaller.utils.hooks import collect_all + +datas, binaries, hiddenimports = collect_all('prettytable')