Skip to content

Commit

Permalink
updated workflow and added nsis script
Browse files Browse the repository at this point in the history
  • Loading branch information
officiallyaninja committed Dec 9, 2023
1 parent 1150461 commit 37aca89
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 8 deletions.
64 changes: 56 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
name: Windows Binary Build Workflow
name: Windows Installer Build Workflow
on:
workflow_dispatch:

jobs:

create_branch:
name: Create Branch on Remote
runs-on: windows-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}

- name: Create Branch
run: |
git checkout -b build_branch main
git push origin build_branch
Windows_Python_Build:
name: Windows Python Binary Build
needs: [create_branch]
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
ref: main
ref: build_branch

- uses: actions/setup-python@v4
with:
Expand All @@ -22,22 +38,23 @@ jobs:
git config user.email [email protected]
git pull
git add binary_build/
git commit -m "generated auto-labeller"
git commit -m "generated auto-label exe "
git pull --no-edit
git push
git push -f origin dev
git push -f origin build_branch
Windows_Flutter_Build:
name: Windows Flutter Binary Build
needs: [create_branch]
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
ref: main
ref: build_branch

- uses: subosito/flutter-action@v2
with:
channel: 'beta'
channel: 'stable'
- run: |
./build_flutter_win.bat
git config user.name github-actions
Expand All @@ -47,4 +64,35 @@ jobs:
git commit -m "generated flutter windows build"
git pull --no-edit
git push
git push -f origin dev
git push -f origin build_branch
Installer_Build:
name: Installer Build
needs: [Windows_Python_Build,Windows_Flutter_Build]
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
ref: build_branch

- name: Install NSIS
run: |
Invoke-WebRequest -Uri https://raw.githubusercontent.com/actions/runner-images/main/images/win/scripts/Installers/Install-NSIS.ps1 -OutFile Install-NSIS.ps1
.\Install-NSIS.ps1 -Version "3.06.1"
- name: Build installer
run: |
& 'C:\Program Files (x86)\NSIS\makensis.exe' nsis_script.nsi
- name: Upload installer artifact
uses: actions/upload-artifact@v2
with:
name: autoLabel Installer
path: autoLabelInstaller.exe

- name: Delete branch
run: |
git checkout dev
git branch -d build_branch
git push origin --delete build_branch
70 changes: 70 additions & 0 deletions nsis_script.nsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
Unicode False
!addplugindir "./"
!include LogicLib.nsh

; The name of the installer
Name "autoLabel Installer"

; Set the output file name
OutFile "autoLabelInstaller.exe"

; The default installation directory
InstallDir "$PROGRAMFILES\autoLabel"

; Create the installation directory
Section
SetOutPath $INSTDIR
SectionEnd

; Function to delete specific files in the installation directory
Function DeleteInstallationContents
SetOutPath $INSTDIR
RMDir /r "$INSTDIR\*.*"
FunctionEnd

; Add the files and directories to the installer
Section
Call DeleteInstallationContents ;Call the function to delete specific files
SetOutPath $INSTDIR
File /r "EHSA_V3\*.*"
CreateDirectory "$INSTDIR\output"
SectionEnd

; Create a shortcut for ehsa_frontend.exe on the desktop
Section
SetOutPath "$INSTDIR\bin"
CreateShortCut "$DESKTOP\autoLabel.lnk" "$INSTDIR\hackathon.exe"
ShellLink::SetRunAsAdministrator $DESKTOP\autoLabel.lnk
SectionEnd

; Call the CheckVCRedist function
Function .onInit
Call CheckVCRedist
FunctionEnd

; Install VC++ Redist
Function InstallVCRedist
; Download the VC++ Redist installer
NSISdl::download "https://aka.ms/vs/17/release/vc_redist.x64.exe" "$TEMP\vc_redist.x64.exe"
; Run the installer
ExecWait "$TEMP\vc_redist.x64.exe /q"
; Check if the installation was successful
ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
; If the installation was not successful, prompt the user to try again
${If} $0 == ""
MessageBox MB_RETRYCANCEL "VC++ Redist installation failed. Do you want to try again?" IDRETRY retry
retry:
Call InstallVCRedist
${EndIf}
FunctionEnd

Function CheckVCRedist
; Check if the registry key exists
ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
; If the key does not exist, prompt the user to install VC++ Redist
${If} $0 == ""
MessageBox MB_YESNO "This application requires VC++ Redist. Do you want to install it now?" IDYES install_vc_redist
install_vc_redist:
Call InstallVCRedist
${EndIf}
FunctionEnd

0 comments on commit 37aca89

Please sign in to comment.