Skip to content

Commit

Permalink
Merge pull request #6 from misdoro/gh_actions
Browse files Browse the repository at this point in the history
Build and publish windows installer binary on tag releases
  • Loading branch information
misdoro authored Nov 15, 2020
2 parents 7392769 + c53594f commit 34223fa
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 1 deletion.
68 changes: 68 additions & 0 deletions .github/workflows/pyinstaller_windows.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
67 changes: 67 additions & 0 deletions px100.nsi
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions px100.spec
Original file line number Diff line number Diff line change
@@ -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')

0 comments on commit 34223fa

Please sign in to comment.