Skip to content

Commit

Permalink
package lang-fixer into an installer, attempt #1
Browse files Browse the repository at this point in the history
  • Loading branch information
TheYarin committed Apr 2, 2022
1 parent cda2208 commit 104eb1c
Show file tree
Hide file tree
Showing 5 changed files with 176 additions and 1 deletion.
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Python application

on:
push:
paths:
- "version.txt"
branches: [$default_branch]
paths-ignore:
- "*.md"
pull_request:
branches: [$default_branch]

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pipenv
pipenv install -d
- name: Test with pytest
run: |
pipenv run pytest
- name: Pyinstaller
run: |
pipenv run pyinstaller --onefile --noconsole lang-fixer.py
- name: install NSIS`
run: |
Invoke-WebRequest -Uri 'https://prdownloads.sourceforge.net/nsis/nsis-3.08-setup.exe?download' -OutFile nsis-setup.exe
nsis-setup.exe /S
- name: build installer with nsis
run: "C:\Program Files (x86)\NSIS\makensis.exe" lang-fixer.nsi
-name: Release installer to GitHub
uses: softprops/action-gh-release@v1
with:
files: lang-fixer-installer*.exe
- name: push new version tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: v$(cat version.txt)
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pynput = "*"
[dev-packages]
pytest = "*"
autopep8 = "*"
pyinstaller = "*"

[requires]
python_version = "3.9"
56 changes: 55 additions & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions lang-fixer.nsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
InstallDir "$PROGRAMFILES\lang-fixer"
Name "lang-fixer"

; Read version
FileOpen $VersionFile "version.txt" r
FileRead $VersionFile $VERSION ; Read until the end of line (including carriage return and new line) and save it to $VERSION
FileClose $VersionFile ; and close the file

outFile "lang-fixer-installer_v${VERSION}.exe"

Page directory
Page instfiles

Section "install"
setOutPath $INSTDIR

file -oname "lang-fixer.exe" ".\dist\lang-fixer.exe"
file "settings.json"
file "layout1.txt"
file "layout2.txt"

writeRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "lang-fixer" "$INSTDIR\lang-fixer.exe"

writeUninstaller "$INSTDIR\uninstall.exe"
writeRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\lang-fixer" "DisplayName" "lang-fixer"
writeRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\lang-fixer" "DisplayVersion" "$VERSION"
writeRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\lang-fixer" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
writeRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\lang-fixer" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
writeRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\lang-fixer" "InstallLocation" "$INSTDIR"
writeRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\lang-fixer" "Publisher" "TheYarin"
writeRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\lang-fixer" "HelpLink" "https://github.com/TheYarin/lang-fixer"
writeRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\lang-fixer" "Readme" "https://github.com/TheYarin/lang-fixer"
writeRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\lang-fixer" "NoModify" 1
writeRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\lang-fixer" "NoRepair" 1

${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\lang-fixer" "EstimatedSize" "$0"

SectionEnd

function un.onInit
SetShellVarContext all

#Verify the uninstaller - last chance to back out
MessageBox MB_OKCANCEL "Permanently remove lang-fixer?" IDOK next
Abort
next:
!insertmacro VerifyUserIsAdmin
functionEnd

section "uninstall"
Delete "$INSTDIR\lang-fixer.exe"

MessageBox MB_YESNO "Would you like to delete even the settings and the keyboard layouts configured?" /SD IDYES lbl_delete_configs IDNO lbl_skip

lbl_delete_configs:
Delete $INSTDIR\settings.json
Delete $INSTDIR\layout1.txt
Delete $INSTDIR\layout2.txt

lbl_skip:

Delete $INSTDIR\uninstall.exe

rmdir $INSTDIR

DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "lang-fixer"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\lang-fixer"
sectionEnd
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0

0 comments on commit 104eb1c

Please sign in to comment.