Skip to content

Commit

Permalink
Merge pull request #425 from gokulprathin8/windows/autodeploy
Browse files Browse the repository at this point in the history
Windows/autodeploy
  • Loading branch information
ZihengSun authored Nov 22, 2023
2 parents 4c7063b + 5026fde commit 9580e9d
Show file tree
Hide file tree
Showing 9 changed files with 231 additions and 1 deletion.
55 changes: 54 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,43 @@ jobs:
target/*.jar
pom.xml
linux-deployment/*.deb
build-windows:
needs: build-jar
runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Download Geoweaver Artifacts
uses: actions/download-artifact@v2
with:
name: geoweaver-artifacts
path: artifact

- name: Prepare Deployment Directory
run: |
cp artifact/target/geoweaver.jar windows-deployment/geoweaver.jar
- name: Install NSIS
run: choco install nsis

- name: Install PyInstaller
run: pip install pyinstaller

- name: Build Executable with PyInstaller
run: pyinstaller windows-deployment/pyinstaller.spec

- name: Build NSIS Installer
run: '& "C:\Program Files (x86)\NSIS\makensis.exe" windows-deployment/installer.nsi'

- name: Upload Windows Installer to Release
uses: actions/upload-artifact@v2
with:
name: geoweaver-windows-installer
path: D:\a\Geoweaver\Geoweaver\windows-deployment\GeoweaverInstaller.exe

build-macos:
needs: build-jar
Expand Down Expand Up @@ -99,7 +136,7 @@ jobs:
path: /Users/runner/work/Geoweaver/Geoweaver/Geoweaver.dmg

release:
needs: [build-jar, build-macos]
needs: [build-jar, build-macos, build-windows]
runs-on: ubuntu-latest

steps:
Expand All @@ -119,6 +156,12 @@ jobs:
with:
name: geoweaver-dmg

- name: Download Windows Installer Artifact
uses: actions/download-artifact@v2
with:
name: geoweaver-windows-installer


- name: Get ID and upload URL of the latest release
run: |
RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.PAT }}" "https://api.github.com/repos/${{ github.repository }}/releases/latest")
Expand Down Expand Up @@ -164,3 +207,13 @@ jobs:
asset_content_type: application/x-diskcopy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Windows Installer to Release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: GeoweaverInstaller.exe
asset_name: GeoweaverInstaller.exe
asset_content_type: application/vnd.microsoft.portable-executable
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
8 changes: 8 additions & 0 deletions windows-deployment/binder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from subprocess import Popen
import os

script_dir = os.path.dirname(os.path.realpath(__file__))
bat_path = os.path.join(script_dir, "launch.bat")

p = Popen(bat_path, cwd=script_dir)
stdout, stderr = p.communicate()
43 changes: 43 additions & 0 deletions windows-deployment/binder.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- mode: python ; coding: utf-8 -*-


a = Analysis(
['binder.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
)
pyz = PYZ(a.pure)

exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='binder',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='binder',
)
Binary file added windows-deployment/geoweaver.ico
Binary file not shown.
20 changes: 20 additions & 0 deletions windows-deployment/installer.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[Application]
name=Geoweaver
version=1.0.0

[Build]
installer_name=Geoweaver_Installer.exe
# No 'entry_point' or 'Python' section needed, as we are not directly running a Python script

[Include]
files = dist/geoweaver/* # Include the entire directory where PyInstaller output the executable

[Command run]
command=dist/geoweaver/geoweaver.exe
# The above line should point to the location of the .exe file within the included files

[Shortcuts]
Geoweaver=run
Geoweaver (Desktop)=run
# The icon is specified here, pointing to the icon file within the included files
icon=dist/geoweaver/geoweaver.ico
35 changes: 35 additions & 0 deletions windows-deployment/installer.nsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
; Define the name of the installer
OutFile "GeoweaverInstaller.exe"

; Define the installation directory
InstallDir "$PROGRAMFILES\Geoweaver"

; Define the package's properties
Name "Geoweaver"
BrandingText "Geoweaver Installation"
Icon "geoweaver.ico"

; Default installation section
Section "Install Geoweaver"

; Set the output path to the installation directory
SetOutPath $INSTDIR

; Include the files from the dist/geoweaver directory
File /r "D:\a\Geoweaver\Geoweaver\dist\geoweaver\*.*"

; Create a desktop shortcut
CreateShortCut "$DESKTOP\Geoweaver.lnk" "$INSTDIR\geoweaver.exe" "" "$INSTDIR\_internal\geoweaver.ico"

SectionEnd

; Uninstallation section
Section "Uninstall"

; Remove the application's files
RMDir /r $INSTDIR

; Remove the desktop shortcut
Delete "$DESKTOP\Geoweaver.lnk"

SectionEnd
28 changes: 28 additions & 0 deletions windows-deployment/installer.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="GeoweaverApp" Version="1.0.0.0" Manufacturer="YourCompany" UpgradeCode="YOUR-GUID-HERE">
<Package InstallerVersion="200" Compressed="yes" />

<Media Id="1" Cabinet="geoweaver.cab" EmbedCab="yes" />

<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="GeoweaverApp" />
</Directory>
</Directory>

<Feature Id="ProductFeature" Title="GeoweaverApp" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>

<DirectoryRef Id="INSTALLFOLDER">
<Component Id="GeoweaverAppComponent" Guid="YOUR-ANOTHER-GUID-HERE">
<File Id="GeoweaverExecutable" Source="path\to\your\GeoweaverExecutable.exe" />
<!-- Add more files as needed -->
</Component>
</DirectoryRef>

<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<ComponentRef Id="GeoweaverAppComponent" />
</ComponentGroup>
</Product>
</Wix>
7 changes: 7 additions & 0 deletions windows-deployment/launch.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@echo off
start /min cmd /c java -jar geoweaver.jar
:LOOP
timeout /t 5
netstat -ano | find "8070" >nul
if errorlevel 1 goto LOOP
start http://localhost:8070/Geoweaver
36 changes: 36 additions & 0 deletions windows-deployment/pyinstaller.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
block_cipher = None

a = Analysis(['binder.py'],
pathex=['path_to_your_script'],
binaries=[],
datas=[('launch.bat', '.'), ('geoweaver.jar', '.'), ('geoweaver.ico', '.')],
hiddenimports=[],
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='geoweaver',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
icon='geoweaver.ico')
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='geoweaver',
dest_folder='.')

0 comments on commit 9580e9d

Please sign in to comment.