From 591183ace9af702497bba930e928e76949b1ac7d Mon Sep 17 00:00:00 2001 From: Wilson Date: Tue, 31 Dec 2024 13:39:26 +0800 Subject: [PATCH] Auto build client on Windows, Linux and MacOS. --- .github/workflows/pyinstaller.yml | 50 +++++++++++++++++++++++++++++++ .gitignore | 4 ++- script/pyinstaller.spec | 41 +++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pyinstaller.yml create mode 100644 script/pyinstaller.spec diff --git a/.github/workflows/pyinstaller.yml b/.github/workflows/pyinstaller.yml new file mode 100644 index 0000000..c3e00c7 --- /dev/null +++ b/.github/workflows/pyinstaller.yml @@ -0,0 +1,50 @@ +name: Client Build + +on: + push: + branches: + - main + pull_request: + branches: + - main + release: + types: [created] + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + include: + - os: ubuntu-latest + artifact_name: pn532_cli_release_linux + - os: windows-latest + artifact_name: pn532_cli_release_windows + - os: macos-latest + artifact_name: pn532_cli_release_macos + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r script/requirements.txt + pip install pyinstaller + + - name: Run PyInstaller + run: | + pyinstaller script/pyinstaller.spec + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.artifact_name }} + path: dist/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 57e030e..b232765 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ __pycache__ *.bin -*.json \ No newline at end of file +*.json +build/ +dist/ \ No newline at end of file diff --git a/script/pyinstaller.spec b/script/pyinstaller.spec new file mode 100644 index 0000000..79700b2 --- /dev/null +++ b/script/pyinstaller.spec @@ -0,0 +1,41 @@ +# -*- mode: python ; coding: utf-8 -*- + +block_cipher = None + +a = Analysis( + ['pn532_cli_main.py'], + pathex=['.'], + binaries=[], + datas=[], + hookspath=[], + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False, +) + +pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='pn532_cli_main', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +)