Skip to content

Commit

Permalink
finish installer
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-pro committed Jan 10, 2024
1 parent 812a61b commit d1d1101
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 35 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,26 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Cargo Clippy
run: cargo clippy -- -D warnings

- name: Cargo Test
run: cargo test

- if: startsWith(github.ref, 'refs/tags/')
name: Compile Release
- name: Cargo Clippy
run: cargo clippy -- -D warnings

- name: Cargo Release Build
run: cargo build --release

- name: Create installer
run: makensis installer/windows.nsi

- if: startsWith(github.ref, 'refs/tags/')
name: Publish Release Artifacts
uses: softprops/action-gh-release@v1
with:
files: |
./target/release/ssb.exe
./target/release/ssb-cli.exe
./installer/ssb-installer.exe
ubuntu:
runs-on: ubuntu-latest
Expand All @@ -40,12 +43,11 @@ jobs:

- uses: actions/checkout@v2

- name: Cargo Clippy
run: cargo clippy -- -D warnings

- name: Cargo Test
run: cargo test

- name: Cargo Clippy
run: cargo clippy -- -D warnings

check_style:
runs-on: ubuntu-latest
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
.PHONY: test format

.PHONY: test
test:
cargo fmt -- --check
cargo-sort --check --workspace
cargo clippy --all-features --workspace -- -D warnings
cargo test --all-features --workspace

.PHONY: format
format:
cargo fmt
cargo-sort --workspace

.PHONY: installer
installer:
makensis installer/windows.nsi
5 changes: 5 additions & 0 deletions installer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Windows NSIS Installer

Requires NsProcess plugin:
- https://nsis.sourceforge.io/NsProcess_plugin
- https://nsis.sourceforge.io/mediawiki/images/1/18/NsProcess.zip (The Unicode version nsProcessW.dll)
28 changes: 28 additions & 0 deletions installer/include/nsProcess.nsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
!define nsProcess::FindProcess `!insertmacro nsProcess::FindProcess`

!macro nsProcess::FindProcess _FILE _ERR
nsProcess::_FindProcess /NOUNLOAD `${_FILE}`
Pop ${_ERR}
!macroend


!define nsProcess::KillProcess `!insertmacro nsProcess::KillProcess`

!macro nsProcess::KillProcess _FILE _ERR
nsProcess::_KillProcess /NOUNLOAD `${_FILE}`
Pop ${_ERR}
!macroend

!define nsProcess::CloseProcess `!insertmacro nsProcess::CloseProcess`

!macro nsProcess::CloseProcess _FILE _ERR
nsProcess::_CloseProcess /NOUNLOAD `${_FILE}`
Pop ${_ERR}
!macroend


!define nsProcess::Unload `!insertmacro nsProcess::Unload`

!macro nsProcess::Unload
nsProcess::_Unload
!macroend
Binary file added installer/plugins/nsProcess.dll
Binary file not shown.
70 changes: 70 additions & 0 deletions installer/windows.nsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
Unicode True
!addplugindir plugins
!addincludedir include

!include "MUI2.nsh"
!include "nsProcess.nsh"

OutFile "ssb-installer.exe"
Name "Solar Screen Brightness"
InstallDir "$LocalAppdata\solar-screen-brightness"

!define SHORT_CUT "$SMPROGRAMS\Solar Screen Brightness.lnk"
!define SHORT_CUT_UNINSTALL "$SMPROGRAMS\Uninstall Solar Screen Brightness.lnk"
!define SHORT_CUT_START_UP "$SMSTARTUP\Solar Screen Brightness (Minimised).lnk"

!define MUI_ICON "..\assets\icon-256.ico"
!define MUI_WELCOMEPAGE_TITLE "Solar Screen Brightness"
!define MUI_WELCOMEPAGE_TEXT "Click Install to start the installation."
!define MUI_FINISHPAGE_RUN "$INSTDIR\ssb.exe"

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!define MUI_WELCOMEPAGE_TITLE "Solar Screen Brightness"
!define MUI_WELCOMEPAGE_TEXT "Click Uninstall to start the uninstallation."

!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"

Section
SetOutPath "$INSTDIR"

# Stop version 1
${nsProcess::KillProcess} "solar-screen-brightness.exe" $R0
DetailPrint "Stopping solar-screen-brightness.exe code: $R0"
# Stop version 2
${nsProcess::KillProcess} "ssb.exe" $R0
DetailPrint "Stopping ssb.exe code: $R0"

# Allow time for processes to stop
Sleep 500

# Delete version 1
RMDir /r "$APPDATA\Solar Screen Brightness"

File "..\target\release\ssb.exe"
File "..\target\release\ssb-cli.exe"
WriteUninstaller "$INSTDIR\uninstall.exe"
CreateShortcut "${SHORT_CUT}" "$INSTDIR\ssb.exe"
CreateShortcut "${SHORT_CUT_UNINSTALL}" "$INSTDIR\uninstall.exe"
CreateShortcut "${SHORT_CUT_START_UP}" "$INSTDIR\ssb.exe" "--minimised"
SectionEnd

Section "uninstall"
# Stop version 2
${nsProcess::KillProcess} "ssb.exe" $R0
DetailPrint "Stopping ssb.exe code: $R0"

# Allow time for processes to stop
Sleep 500

Delete "${SHORT_CUT}"
Delete "${SHORT_CUT_UNINSTALL}"
Delete "${SHORT_CUT_START_UP}"
RMDir /r "$INSTDIR"
SectionEnd

25 changes: 0 additions & 25 deletions installers/windows.nsi

This file was deleted.

0 comments on commit d1d1101

Please sign in to comment.