diff --git a/.github/workflows/pyinstaller_windows.yml b/.github/workflows/pyinstaller_windows.yml new file mode 100644 index 0000000..c5336f6 --- /dev/null +++ b/.github/workflows/pyinstaller_windows.yml @@ -0,0 +1,68 @@ +name: PyInstaller Windows + +on: + push: + tags: + - 'v*' + +jobs: + build: + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U https://github.com/pyinstaller/pyinstaller/archive/develop.zip + pip install -r requirements.txt + - name: build with pyinstaller + run: | + pyinstaller px100.spec + - name: Build NSIS installer package + run: | + makensis -VERSION + makensis px100.nsi + - name: Upload installer artifact + uses: actions/upload-artifact@v2 + with: + name: installer + path: Install* + release: + name: Upload Release Asset + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Download installer artifact + uses: actions/download-artifact@v2 + with: + name: installer + - name: List files + run: | + ls -l + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: Install Battery tester PX100.exe + asset_name: Battery-Tester-PX100.exe + asset_content_type: application/exe diff --git a/.gitignore b/.gitignore index 3625a91..b1f45d0 100644 --- a/.gitignore +++ b/.gitignore @@ -31,7 +31,6 @@ MANIFEST # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest -*.spec # Installer logs pip-log.txt diff --git a/px100.nsi b/px100.nsi new file mode 100644 index 0000000..6d222f4 --- /dev/null +++ b/px100.nsi @@ -0,0 +1,67 @@ +/* +Basic installer for battery tester +*/ + +!define NAME "Battery tester PX100" +!define REGPATH_UNINSTSUBKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" +Name "${NAME}" +OutFile "Install ${NAME}.exe" +Unicode True +RequestExecutionLevel User ; We don't need UAC elevation +InstallDir "" ; Don't set a default $InstDir so we can detect /D= and InstallDirRegKey +InstallDirRegKey HKCU "${REGPATH_UNINSTSUBKEY}" "UninstallString" + +!include LogicLib.nsh +!include WinCore.nsh +!include Integration.nsh + +Page Directory +Page InstFiles + +Uninstpage UninstConfirm +Uninstpage InstFiles + + +Function .onInit + SetShellVarContext Current + + ${If} $InstDir == "" ; No /D= nor InstallDirRegKey? + GetKnownFolderPath $InstDir ${FOLDERID_UserProgramFiles} ; This folder only exists on Win7+ + StrCmp $InstDir "" 0 +2 + StrCpy $InstDir "$LocalAppData\Programs" ; Fallback directory + + StrCpy $InstDir "$InstDir\$(^Name)" + ${EndIf} +FunctionEnd + +Function un.onInit + SetShellVarContext Current +FunctionEnd + +Section "Program files (Required)" + SectionIn Ro + + SetOutPath $InstDir + WriteUninstaller "$InstDir\Uninst.exe" + WriteRegStr HKCU "${REGPATH_UNINSTSUBKEY}" "DisplayName" "${NAME}" + WriteRegStr HKCU "${REGPATH_UNINSTSUBKEY}" "DisplayIcon" "$InstDir\MyApp.exe,0" + WriteRegStr HKCU "${REGPATH_UNINSTSUBKEY}" "UninstallString" '"$InstDir\Uninst.exe"' + WriteRegDWORD HKCU "${REGPATH_UNINSTSUBKEY}" "NoModify" 1 + WriteRegDWORD HKCU "${REGPATH_UNINSTSUBKEY}" "NoRepair" 1 + + File /r dist\px100\* +SectionEnd + +Section "Start Menu shortcut" + CreateShortcut "$SMPrograms\${NAME}.lnk" "$InstDir\px100.exe" +SectionEnd + +Section -Uninstall + ${UnpinShortcut} "$SMPrograms\${NAME}.lnk" + Delete "$SMPrograms\${NAME}.lnk" + + Delete "$InstDir\MyApp.exe" + Delete "$InstDir\Uninst.exe" + RMDir "$InstDir" + DeleteRegKey HKCU "${REGPATH_UNINSTSUBKEY}" +SectionEnd diff --git a/px100.spec b/px100.spec new file mode 100644 index 0000000..d706cd7 --- /dev/null +++ b/px100.spec @@ -0,0 +1,37 @@ +# -*- mode: python ; coding: utf-8 -*- + +block_cipher = None + + +a = Analysis(['main.py'], + pathex=['./'], + binaries=[], + datas=[('gui/*.ui', 'gui') ], + hiddenimports=['pyvisa_py','pyserial'], + 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, + [], + exclude_binaries=True, + name='px100', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + console=True ) +coll = COLLECT(exe, + a.binaries, + a.zipfiles, + a.datas, + strip=False, + upx=True, + upx_exclude=[], + name='px100')