diff --git a/.github/workflows/msys2.yml b/.github/workflows/msys2.yml new file mode 100644 index 0000000..98d21da --- /dev/null +++ b/.github/workflows/msys2.yml @@ -0,0 +1,74 @@ + +name: msys2 +on: push +jobs: + Deploy-on-windows: + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + steps: + - uses: msys2/setup-msys2@v2 + with: + msystem: UCRT64 + update: true + install: >- + base-devel + git + mingw-w64-ucrt-x86_64-python-pip + mingw-w64-ucrt-x86_64-nsis + mingw-w64-ucrt-x86_64-nsis-nsisunz + mingw-w64-ucrt-x86_64-gcc + zip + unzip + p7zip + mingw-w64-ucrt-x86_64-python-pyqt5 + python-setuptools + mingw-w64-ucrt-x86_64-python-pyserial + mingw-w64-ucrt-x86_64-python-requests + mingw-w64-ucrt-x86_64-python-babel + mingw-w64-ucrt-x86_64-python-qtawesome + mingw-w64-ucrt-x86_64-python-paramiko + mingw-w64-ucrt-x86_64-python-pyperclip + mingw-w64-ucrt-x86_64-python-pyqtgraph + - name: Check out repository code + uses: actions/checkout@v3 + - name: Running pyinstaller without pack.py + run: | + APP=comtool + if [ ! -d venv ]; then + python3 -m venv --system-site-packages venv + . venv/bin/activate + python3 -m pip install --upgrade pip + PYINSTALLER_COMPILE_BOOTLOADER=1 PYI_STATIC_ZLIB=1 python3 -m pip install -r requirements.txt + python3 -m pip install git+https://github.com/pyinstaller/pyinstaller.git + else + . venv/bin/activate + fi + + python3 -m pip install wheel pyinstaller-hooks-contrib + python3 setup.py sdist bdist_wheel + python3 pack.py + # python3 -m PyInstaller $APP.spec -y + # echo "Preparing app..." + # cd dist/$APP + # zip -r $APP.zip * + # mv $APP.zip ../.. + # cd ../.. + echo $(du -sk dist/$APP | cut -f 1) > INSTALLSIZE + echo $(uname -m) > ARCH + echo "Running makensis..." + makensis $APP.nsi + + python3 -m PyInstaller $APP-portable.spec + echo "Preparing app..." + version=$(cat VERSION) + mv dist/$APP.exe ./$APP-$version-$(uname -m)-portable.exe + - name: List files + run: ls -R + - name: Upload output files + uses: actions/upload-artifact@v3 + with: + name: EXE + path: comtool*.exe + retention-days: 5 diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..e4604e3 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +3.2.1 diff --git a/comtool-portable.spec b/comtool-portable.spec new file mode 100644 index 0000000..a4485fa --- /dev/null +++ b/comtool-portable.spec @@ -0,0 +1,40 @@ +# -*- mode: python ; coding: utf-8 -*- + + +block_cipher = None + + +a = Analysis( + ['COMTool/Main.py'], + pathex=['COMTool'], + binaries=[], + datas=[('COMTool/assets', 'assets'), ('COMTool/locales', 'locales'), ('COMTool/protocols', 'protocols'), ('README.MD', './'), ('README_ZH.MD', './')], + hiddenimports=['babel.numbers'], + hookspath=[], + hooksconfig={}, + 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, + [], + name='comtool', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + console=False, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, + icon=['COMTool/assets/logo.ico'], +) diff --git a/comtool.nsi b/comtool.nsi new file mode 100644 index 0000000..baa6af5 --- /dev/null +++ b/comtool.nsi @@ -0,0 +1,79 @@ +#!/usr/bin/makensis + +!define APPNAME "comtool" +!define FILENAME "comtool" +!define AUTHOR "Author name" +!define DESCRIPTION "com debug tool" + +Unicode True + +!define /file VERSION "VERSION" +!define /file INSTALLSIZE "INSTALLSIZE" +!define /file ARCH "ARCH" + +InstallDir "$PROGRAMFILES\${APPNAME}" + +Name "${APPNAME}" +Icon "COMTool/assets/logo.ico" +outFile "${FILENAME}-${VERSION}-${ARCH}.exe" + +!include LogicLib.nsh + +Page directory +Page instfiles + +!macro VerifyUserIsAdmin +UserInfo::GetAccountType +pop $0 +${If} $0 != "admin" ;Require admin rights on NT4+ + messageBox mb_iconstop "Administrator rights required!" + setErrorLevel 740 ;ERROR_ELEVATION_REQUIRED + quit +${EndIf} +!macroend + +function .onInit + setShellVarContext all + !insertmacro VerifyUserIsAdmin +functionEnd + +section "install" + + setOutPath $INSTDIR + file "COMTool\assets\logo.ico" + file "${FILENAME}.zip" + + nsisunz::Unzip "$INSTDIR\${FILENAME}.zip" "$INSTDIR" + + delete "$INSTDIR\${FILENAME}.zip" + + writeUninstaller "$INSTDIR\uninstall.exe" + + createDirectory "$SMPROGRAMS\${APPNAME}" + createShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\${FILENAME}.exe" "" "$INSTDIR\COMTool\assets\logo.ico.ico" + + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayName" "${APPNAME}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "InstallLocation" "$\"$INSTDIR$\"" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayIcon" "$\"$INSTDIR\COMTool\assets\logo.ico$\"" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "Publisher" "${AUTHOR}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayVersion" "${VERSION}" + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "NoRepair" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "EstimatedSize" ${INSTALLSIZE} +sectionEnd + +function un.onInit + SetShellVarContext all + MessageBox MB_OKCANCEL "Permanently remove ${APPNAME}?" IDOK next + Abort + next: + !insertmacro VerifyUserIsAdmin +functionEnd + +section "uninstall" + rmDir /r /REBOOTOK "$SMPROGRAMS\${APPNAME}" + rmDir /r /REBOOTOK $INSTDIR + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" +sectionEnd diff --git a/pack.py b/pack.py index b50210d..8065fea 100644 --- a/pack.py +++ b/pack.py @@ -21,7 +21,8 @@ linux_out = "comtool_ubuntu_v{}.tar.xz".format(version.__version__) macos_out = "comtool_macos_v{}.dmg".format(version.__version__) -windows_out = "comtool_windows_v{}.7z".format(version.__version__) +windows_out_7z = "comtool_windows_v{}.7z".format(version.__version__) +windows_out_zip = "comtool.zip" def zip(out, path): out = os.path.abspath(out) @@ -135,8 +136,8 @@ def pack(): print("files in dist dir:", os.listdir("dist")) shutil.copyfile("./dist/comtool 0.0.0.dmg", macos_out) elif sys.platform.startswith("win32"): - # zip(windows_out, "dist/comtool") - zip_7z(windows_out, "dist/comtool") + zip(windows_out_zip, "dist/comtool") + # zip_7z(windows_out_7z, "dist/comtool") else: cmd = "cd dist && tar -Jcf {} comtool/ && mv {} ../ && cd ..".format(linux_out, linux_out) ret = os.system(cmd)