Skip to content

Commit 34223fa

Browse files
authored
Merge pull request #6 from misdoro/gh_actions
Build and publish windows installer binary on tag releases
2 parents 7392769 + c53594f commit 34223fa

File tree

4 files changed

+172
-1
lines changed

4 files changed

+172
-1
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: PyInstaller Windows
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build:
10+
runs-on: windows-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v2
14+
- name: Set up Python 3.8
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: 3.8
18+
- name: Install dependencies
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install -U https://github.com/pyinstaller/pyinstaller/archive/develop.zip
22+
pip install -r requirements.txt
23+
- name: build with pyinstaller
24+
run: |
25+
pyinstaller px100.spec
26+
- name: Build NSIS installer package
27+
run: |
28+
makensis -VERSION
29+
makensis px100.nsi
30+
- name: Upload installer artifact
31+
uses: actions/upload-artifact@v2
32+
with:
33+
name: installer
34+
path: Install*
35+
release:
36+
name: Upload Release Asset
37+
runs-on: ubuntu-latest
38+
needs: build
39+
steps:
40+
- name: Checkout code
41+
uses: actions/checkout@v2
42+
- name: Download installer artifact
43+
uses: actions/download-artifact@v2
44+
with:
45+
name: installer
46+
- name: List files
47+
run: |
48+
ls -l
49+
- name: Create Release
50+
id: create_release
51+
uses: actions/create-release@v1
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
with:
55+
tag_name: ${{ github.ref }}
56+
release_name: Release ${{ github.ref }}
57+
draft: false
58+
prerelease: false
59+
- name: Upload Release Asset
60+
id: upload-release-asset
61+
uses: actions/upload-release-asset@v1
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
with:
65+
upload_url: ${{ steps.create_release.outputs.upload_url }}
66+
asset_path: Install Battery tester PX100.exe
67+
asset_name: Battery-Tester-PX100.exe
68+
asset_content_type: application/exe

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ MANIFEST
3131
# Usually these files are written by a python script from a template
3232
# before PyInstaller builds the exe, so as to inject date/other infos into it.
3333
*.manifest
34-
*.spec
3534

3635
# Installer logs
3736
pip-log.txt

px100.nsi

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
Basic installer for battery tester
3+
*/
4+
5+
!define NAME "Battery tester PX100"
6+
!define REGPATH_UNINSTSUBKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}"
7+
Name "${NAME}"
8+
OutFile "Install ${NAME}.exe"
9+
Unicode True
10+
RequestExecutionLevel User ; We don't need UAC elevation
11+
InstallDir "" ; Don't set a default $InstDir so we can detect /D= and InstallDirRegKey
12+
InstallDirRegKey HKCU "${REGPATH_UNINSTSUBKEY}" "UninstallString"
13+
14+
!include LogicLib.nsh
15+
!include WinCore.nsh
16+
!include Integration.nsh
17+
18+
Page Directory
19+
Page InstFiles
20+
21+
Uninstpage UninstConfirm
22+
Uninstpage InstFiles
23+
24+
25+
Function .onInit
26+
SetShellVarContext Current
27+
28+
${If} $InstDir == "" ; No /D= nor InstallDirRegKey?
29+
GetKnownFolderPath $InstDir ${FOLDERID_UserProgramFiles} ; This folder only exists on Win7+
30+
StrCmp $InstDir "" 0 +2
31+
StrCpy $InstDir "$LocalAppData\Programs" ; Fallback directory
32+
33+
StrCpy $InstDir "$InstDir\$(^Name)"
34+
${EndIf}
35+
FunctionEnd
36+
37+
Function un.onInit
38+
SetShellVarContext Current
39+
FunctionEnd
40+
41+
Section "Program files (Required)"
42+
SectionIn Ro
43+
44+
SetOutPath $InstDir
45+
WriteUninstaller "$InstDir\Uninst.exe"
46+
WriteRegStr HKCU "${REGPATH_UNINSTSUBKEY}" "DisplayName" "${NAME}"
47+
WriteRegStr HKCU "${REGPATH_UNINSTSUBKEY}" "DisplayIcon" "$InstDir\MyApp.exe,0"
48+
WriteRegStr HKCU "${REGPATH_UNINSTSUBKEY}" "UninstallString" '"$InstDir\Uninst.exe"'
49+
WriteRegDWORD HKCU "${REGPATH_UNINSTSUBKEY}" "NoModify" 1
50+
WriteRegDWORD HKCU "${REGPATH_UNINSTSUBKEY}" "NoRepair" 1
51+
52+
File /r dist\px100\*
53+
SectionEnd
54+
55+
Section "Start Menu shortcut"
56+
CreateShortcut "$SMPrograms\${NAME}.lnk" "$InstDir\px100.exe"
57+
SectionEnd
58+
59+
Section -Uninstall
60+
${UnpinShortcut} "$SMPrograms\${NAME}.lnk"
61+
Delete "$SMPrograms\${NAME}.lnk"
62+
63+
Delete "$InstDir\MyApp.exe"
64+
Delete "$InstDir\Uninst.exe"
65+
RMDir "$InstDir"
66+
DeleteRegKey HKCU "${REGPATH_UNINSTSUBKEY}"
67+
SectionEnd

px100.spec

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# -*- mode: python ; coding: utf-8 -*-
2+
3+
block_cipher = None
4+
5+
6+
a = Analysis(['main.py'],
7+
pathex=['./'],
8+
binaries=[],
9+
datas=[('gui/*.ui', 'gui') ],
10+
hiddenimports=['pyvisa_py','pyserial'],
11+
hookspath=[],
12+
runtime_hooks=[],
13+
excludes=[],
14+
win_no_prefer_redirects=False,
15+
win_private_assemblies=False,
16+
cipher=block_cipher,
17+
noarchive=False)
18+
pyz = PYZ(a.pure, a.zipped_data,
19+
cipher=block_cipher)
20+
exe = EXE(pyz,
21+
a.scripts,
22+
[],
23+
exclude_binaries=True,
24+
name='px100',
25+
debug=False,
26+
bootloader_ignore_signals=False,
27+
strip=False,
28+
upx=True,
29+
console=True )
30+
coll = COLLECT(exe,
31+
a.binaries,
32+
a.zipfiles,
33+
a.datas,
34+
strip=False,
35+
upx=True,
36+
upx_exclude=[],
37+
name='px100')

0 commit comments

Comments
 (0)