diff --git a/.github/workflows/release-builder.yml b/.github/workflows/release-builder.yml index a35f4b8..ee5996c 100644 --- a/.github/workflows/release-builder.yml +++ b/.github/workflows/release-builder.yml @@ -32,7 +32,7 @@ jobs: pip install pyinstaller - name: Run Windows Build Script - run: scripts\build_windows.bat + run: scripts/workflow/build_windows.bat shell: cmd - name: Upload Artifacts @@ -59,10 +59,10 @@ jobs: pip install pyinstaller - name: Make Build Script Executable - run: chmod +x scripts/build_linux.sh + run: chmod +x scripts/workflow/build_linux.sh - name: Run Linux Build Script - run: scripts/build_linux.sh + run: scripts/workflow/build_linux.sh shell: bash - name: Upload Artifacts @@ -88,10 +88,10 @@ jobs: pip install pyinstaller - name: Make Build Script Executable - run: chmod +x scripts/build_mac.sh + run: chmod +x scripts/workflow/build_mac.sh - name: Run macOS Build Script - run: scripts/build_mac.sh + run: scripts/workflow/build_mac.sh shell: bash - name: Upload Artifacts diff --git a/scripts/build_appimage.sh b/scripts/user/build_appimage.sh old mode 100755 new mode 100644 similarity index 100% rename from scripts/build_appimage.sh rename to scripts/user/build_appimage.sh diff --git a/scripts/build_linux.sh b/scripts/user/build_linux.sh old mode 100755 new mode 100644 similarity index 100% rename from scripts/build_linux.sh rename to scripts/user/build_linux.sh diff --git a/scripts/build_mac.sh b/scripts/user/build_mac.sh old mode 100755 new mode 100644 similarity index 100% rename from scripts/build_mac.sh rename to scripts/user/build_mac.sh diff --git a/scripts/build_windows.bat b/scripts/user/build_windows.bat similarity index 100% rename from scripts/build_windows.bat rename to scripts/user/build_windows.bat diff --git a/scripts/workflow/build_linux.sh b/scripts/workflow/build_linux.sh new file mode 100644 index 0000000..8fb14e2 --- /dev/null +++ b/scripts/workflow/build_linux.sh @@ -0,0 +1,110 @@ +#!/bin/bash + +echo "========= OnTheSpot Linux Build Script =========" + +# Get the directory of the script +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Change to the project root directory (parent of scripts directory) +PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" +cd "$PROJECT_ROOT" + +echo "Current directory: $(pwd)" + +# Clean up previous builds +echo " => Cleaning up!" +rm -f ./dist/onthespot_linux ./dist/onthespot_linux_ffm +rm -f ./dist/onthespot_linux.tar.gz +rm -f ./dist/OnTheSpot.AppImage +rm -rf ./AppDir + +# Check for FFmpeg and set build options +if [ -f "ffbin_nix/ffmpeg" ]; then + echo " => Found 'ffbin_nix' directory and ffmpeg binary. Including FFmpeg in the build." + FFBIN="--add-binary=ffbin_nix/*:onthespot/bin/ffmpeg" + NAME="onthespot_linux_ffm" +else + echo " => FFmpeg binary not found. Building without it." + FFBIN="" + NAME="onthespot_linux" +fi + +# Run PyInstaller +echo " => Running PyInstaller..." +pyinstaller --onefile \ + --hidden-import=zeroconf._utils.ipaddress \ + --hidden-import=zeroconf._handlers.answers \ + --add-data="src/onthespot/gui/qtui/*.ui:onthespot/gui/qtui" \ + --add-data="src/onthespot/resources/icons/*.png:onthespot/resources/icons" \ + --add-data="src/onthespot/resources/themes/*.qss:onthespot/resources/themes" \ + --add-data="src/onthespot/resources/translations/*.qm:onthespot/resources/translations" \ + $FFBIN \ + --paths="src/onthespot" \ + --name="$NAME" \ + --icon="src/onthespot/resources/icons/onthespot.png" \ + src/portable.py + +# Check if the build was successful +if [ -f "./dist/$NAME" ]; then + # Set executable permissions + echo " => Setting executable permissions..." + chmod +x "./dist/$NAME" +else + echo " => Build failed or output file not found." + exit 1 +fi + +# Create .tar.gz archive +echo " => Creating tar.gz archive..." +cd dist +tar -czvf "$NAME.tar.gz" "$NAME" +cd .. + +# Build AppImage +echo " => Building AppImage..." + +# Download linuxdeploy +wget -q https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage +chmod +x linuxdeploy-x86_64.AppImage + +# Create AppDir structure +mkdir -p AppDir/usr/bin +cp "dist/$NAME" AppDir/usr/bin/onthespot + +# Copy desktop file and icon +mkdir -p AppDir/usr/share/applications +mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps + +cp src/onthespot/resources/icons/onthespot.png AppDir/usr/share/icons/hicolor/256x256/apps/onthespot.png + +# Create desktop file +cat > AppDir/usr/share/applications/onthespot.desktop < Moving artifacts to artifacts folder..." +mkdir -p artifacts/linux +mv dist/"$NAME.tar.gz" artifacts/linux/ +mv dist/OnTheSpot.AppImage artifacts/linux/ + +# Clean up +rm linuxdeploy-x86_64.AppImage +rm -rf AppDir + +# Clean up unnecessary files +echo " => Cleaning up temporary files..." +rm -rf __pycache__ build *.spec + +echo " => Done!" diff --git a/scripts/workflow/build_mac.sh b/scripts/workflow/build_mac.sh new file mode 100644 index 0000000..7ae494d --- /dev/null +++ b/scripts/workflow/build_mac.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +echo "========= OnTheSpot MacOS Build Script ==========" + +# Get the directory of the script +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Change to the project root directory (parent of scripts directory) +PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" +cd "$PROJECT_ROOT" + +echo "Current directory: $(pwd)" + +# Clean up previous builds +echo " => Cleaning up!" +rm -rf ./dist/OnTheSpot.app +rm -f ./dist/OnTheSpot.dmg + +# Check for FFmpeg binary and set build options +if [ -f "ffbin_mac/ffmpeg" ]; then + echo " => Found 'ffbin_mac' directory and ffmpeg binary. Including FFmpeg in the build." + FFBIN='--add-binary=ffbin_mac/*:onthespot/bin/ffmpeg' +else + echo " => FFmpeg binary not found. Building without it." + FFBIN="" +fi + +# Run PyInstaller to create the app +echo " => Running PyInstaller..." +pyinstaller --windowed \ + --hidden-import=zeroconf._utils.ipaddress \ + --hidden-import=zeroconf._handlers.answers \ + --add-data="src/onthespot/gui/qtui/*.ui:onthespot/gui/qtui" \ + --add-data="src/onthespot/resources/icons/*.png:onthespot/resources/icons" \ + --add-data="src/onthespot/resources/themes/*.qss:onthespot/resources/themes" \ + --add-data="src/onthespot/resources/translations/*.qm:onthespot/resources/translations" \ + $FFBIN \ + --paths="src/onthespot" \ + --name="OnTheSpot" \ + --icon="src/onthespot/resources/icons/onthespot.icns" \ + src/portable.py + +# Check if the build was successful +if [ -d "./dist/OnTheSpot.app" ]; then + # Set executable permissions + echo " => Setting executable permissions..." + chmod +x "./dist/OnTheSpot.app" +else + echo " => Build failed or output app not found." + exit 1 +fi + +# Create .dmg file +echo " => Creating DMG file..." +mkdir -p dist/dmg_contents +cp -R dist/OnTheSpot.app dist/dmg_contents/ +hdiutil create -volname "OnTheSpot" -srcfolder dist/dmg_contents -ov -format UDZO dist/OnTheSpot.dmg +rm -rf dist/dmg_contents + +# Move the DMG to artifacts folder +echo " => Moving DMG to artifacts folder..." +mkdir -p artifacts/macos +mv dist/OnTheSpot.dmg artifacts/macos/ + +# Clean up unnecessary files +echo " => Cleaning up temporary files..." +rm -rf __pycache__ build *.spec + +echo " => Done!" diff --git a/scripts/workflow/build_windows.bat b/scripts/workflow/build_windows.bat new file mode 100644 index 0000000..3da6a77 --- /dev/null +++ b/scripts/workflow/build_windows.bat @@ -0,0 +1,76 @@ +@echo off + +echo ========= OnTheSpot Windows Build Script ========= + +REM Navigate to the root directory if in scripts +set FOLDER_NAME=%cd% +for %%F in ("%cd%") do set FOLDER_NAME=%%~nxF +if /i "%FOLDER_NAME%"=="scripts" ( + echo You are in the scripts folder. Changing to the parent directory... + cd .. +) + +REM Clean up previous builds +echo => Cleaning up previous builds... +del /F /Q dist\* 2>nul + +REM Bundle ffmpeg +echo => Downloading FFmpeg binary... +mkdir build +curl -L https://github.com/GyanD/codexffmpeg/releases/download/7.1/ffmpeg-7.1-essentials_build.zip -o build\ffmpeg.zip || ( + echo Failed to download FFmpeg. Exiting... + exit /b 1 +) + +powershell -Command "Expand-Archive -Path build\ffmpeg.zip -DestinationPath build\ffmpeg" || ( + echo Failed to extract FFmpeg. Exiting... + exit /b 1 +) + +mkdir ffbin_win + +REM Find the extracted FFmpeg directory +set FFMPEG_DIR= +for /d %%D in ("build\ffmpeg\*") do set FFMPEG_DIR=%%D +if defined FFMPEG_DIR ( + copy "%FFMPEG_DIR%\bin\ffmpeg.exe" ffbin_win\ || ( + echo Failed to copy FFmpeg binary. Exiting... + exit /b 1 + ) +) else ( + echo Failed to find extracted FFmpeg directory. Exiting... + exit /b 1 +) + +REM Build with PyInstaller +echo => Building executable with PyInstaller... +pyinstaller --onefile --noconsole --noconfirm ^ + --hidden-import=zeroconf._utils.ipaddress ^ + --hidden-import=zeroconf._handlers.answers ^ + --add-data="src/onthespot/resources/translations/*.qm;onthespot/resources/translations" ^ + --add-data="src/onthespot/resources/themes/*.qss;onthespot/resources/themes" ^ + --add-data="src/onthespot/gui/qtui/*.ui;onthespot/gui/qtui" ^ + --add-data="src/onthespot/resources/icons/*.png;onthespot/resources/icons" ^ + --add-binary="ffbin_win/ffmpeg.exe;onthespot/bin/ffmpeg" ^ + --paths=src/onthespot ^ + --name=onthespot_windows ^ + --icon=src/onthespot/resources/icons/onthespot.png ^ + src\portable.py || ( + echo PyInstaller build failed. Exiting... + exit /b 1 +) + +REM Move the executable to artifacts folder +echo => Moving executable to artifacts folder... +mkdir artifacts +mkdir artifacts\windows +move dist\onthespot_windows.exe artifacts\windows\ + +REM Clean up unnecessary files +echo => Cleaning up temporary files... +del /F /Q *.spec 2>nul +rd /s /q build 2>nul +rd /s /q __pycache__ 2>nul +rd /s /q ffbin_win 2>nul + +echo => Done!