mirror of
https://github.com/plexguide/Huntarr.io.git
synced 2026-02-23 07:08:45 -06:00
update
This commit is contained in:
@@ -1,277 +0,0 @@
|
||||
name: Build Windows Installer
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*' # Triggers on version tags like v1.0.0
|
||||
workflow_dispatch: # Allows manual triggering
|
||||
|
||||
# Add explicit permissions for the workflow
|
||||
permissions:
|
||||
contents: write # This allows creating releases and uploading assets
|
||||
|
||||
jobs:
|
||||
build-installer:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0 # Full history for versioning
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install pyinstaller==6.3.0
|
||||
pip install -r requirements.txt
|
||||
|
||||
- name: Debug - Show Repository Structure
|
||||
shell: powershell
|
||||
run: |
|
||||
Write-Host "==== REPOSITORY STRUCTURE ====" -ForegroundColor Green
|
||||
# Show current directory
|
||||
Write-Host "Current directory: $PWD" -ForegroundColor Yellow
|
||||
# List all directories at the root level
|
||||
Write-Host "Root level directories:" -ForegroundColor Yellow
|
||||
Get-ChildItem -Directory | Select-Object Name
|
||||
|
||||
# Check for specific directories needed by PyInstaller
|
||||
$requiredDirs = @("templates", "static", "assets", "src", "frontend")
|
||||
foreach ($dir in $requiredDirs) {
|
||||
if (Test-Path $dir) {
|
||||
Write-Host " Found directory: $dir" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host " Missing directory: $dir" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
|
||||
# Look for frontend/templates as a fallback
|
||||
if (Test-Path "frontend/templates") {
|
||||
Write-Host " Found frontend/templates directory" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# Check for icon file
|
||||
if (Test-Path "assets/huntarr.ico") {
|
||||
Write-Host " Found icon file: assets/huntarr.ico" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host " Missing icon file: assets/huntarr.ico" -ForegroundColor Red
|
||||
|
||||
# Search for the icon file
|
||||
Write-Host "Searching for huntarr.ico..." -ForegroundColor Yellow
|
||||
$iconPaths = Get-ChildItem -Path . -Recurse -Filter "huntarr.ico"
|
||||
if ($iconPaths) {
|
||||
foreach ($path in $iconPaths) {
|
||||
Write-Host "Found icon at: $($path.FullName)" -ForegroundColor Green
|
||||
}
|
||||
} else {
|
||||
Write-Host "Could not find huntarr.ico anywhere in the repository" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
|
||||
- name: Fix Repository Structure
|
||||
shell: powershell
|
||||
run: |
|
||||
Write-Host "==== FIXING REPOSITORY STRUCTURE ====" -ForegroundColor Green
|
||||
|
||||
# Create missing directories
|
||||
$requiredDirs = @("templates", "static", "assets")
|
||||
foreach ($dir in $requiredDirs) {
|
||||
if (-not (Test-Path $dir)) {
|
||||
New-Item -Path $dir -ItemType Directory -Force
|
||||
Write-Host "Created directory: $dir" -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
|
||||
# Copy frontend/templates to templates if needed
|
||||
if (-not (Test-Path "templates/*") -and (Test-Path "frontend/templates")) {
|
||||
Write-Host "Copying frontend/templates to templates" -ForegroundColor Yellow
|
||||
Copy-Item -Path "frontend/templates/*" -Destination "templates/" -Recurse -Force
|
||||
}
|
||||
|
||||
# Copy frontend/static to static if needed
|
||||
if (-not (Test-Path "static/*") -and (Test-Path "frontend/static")) {
|
||||
Write-Host "Copying frontend/static to static" -ForegroundColor Yellow
|
||||
Copy-Item -Path "frontend/static/*" -Destination "static/" -Recurse -Force
|
||||
}
|
||||
|
||||
# Create a placeholder icon if needed
|
||||
if (-not (Test-Path "assets/huntarr.ico")) {
|
||||
Write-Host "Searching for huntarr.ico..." -ForegroundColor Yellow
|
||||
$iconPaths = Get-ChildItem -Path . -Recurse -Filter "huntarr.ico"
|
||||
if ($iconPaths) {
|
||||
$iconPath = $iconPaths[0].FullName
|
||||
Write-Host "Copying icon from $iconPath to assets/huntarr.ico" -ForegroundColor Yellow
|
||||
New-Item -Path "assets" -ItemType Directory -Force
|
||||
Copy-Item -Path $iconPath -Destination "assets/huntarr.ico" -Force
|
||||
} else {
|
||||
# Create a simple placeholder icon if no icon is found
|
||||
Write-Host "Creating a placeholder icon file" -ForegroundColor Yellow
|
||||
# This is just to prevent PyInstaller from failing
|
||||
New-Item -Path "assets" -ItemType Directory -Force
|
||||
Copy-Item -Path "C:\Windows\System32\shell32.dll" -Destination "assets/huntarr.ico" -Force
|
||||
}
|
||||
}
|
||||
|
||||
# Check the fixed structure
|
||||
Write-Host "Repository structure after fixes:" -ForegroundColor Yellow
|
||||
Get-ChildItem -Directory | Select-Object Name
|
||||
|
||||
- name: Extract version from tag or version.txt
|
||||
id: get-version
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
|
||||
# Extract version from tag (remove 'v' prefix)
|
||||
VERSION="${{ github.ref_name }}"
|
||||
VERSION="${VERSION#v}"
|
||||
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
||||
# Update version.txt to match tag
|
||||
echo "$VERSION" > version.txt
|
||||
echo "Using version from tag: $VERSION"
|
||||
else
|
||||
# Read from version.txt
|
||||
VERSION=$(cat version.txt | tr -d '\r\n')
|
||||
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "Using version from version.txt: $VERSION"
|
||||
fi
|
||||
|
||||
- name: Update NSIS script version
|
||||
run: |
|
||||
$version = "${{ steps.get-version.outputs.VERSION }}"
|
||||
$versionParts = $version.Split('.')
|
||||
$major = $versionParts[0]
|
||||
$minor = $versionParts[1]
|
||||
$build = $versionParts[2]
|
||||
|
||||
$nsisFile = "installer/huntarr-installer.nsi"
|
||||
$nsisContent = Get-Content -Path $nsisFile -Raw
|
||||
|
||||
$nsisContent = $nsisContent -replace '!define VERSIONMAJOR \d+', "!define VERSIONMAJOR $major"
|
||||
$nsisContent = $nsisContent -replace '!define VERSIONMINOR \d+', "!define VERSIONMINOR $minor"
|
||||
$nsisContent = $nsisContent -replace '!define VERSIONBUILD \d+', "!define VERSIONBUILD $build"
|
||||
|
||||
Set-Content -Path $nsisFile -Value $nsisContent
|
||||
Write-Host "Updated NSIS script version to $version"
|
||||
|
||||
- name: Generate PyInstaller spec file
|
||||
run: |
|
||||
python installer/generate_spec.py
|
||||
|
||||
# Verify the spec file exists
|
||||
if (Test-Path "huntarr.spec") {
|
||||
Write-Host "PyInstaller spec file created and verified"
|
||||
Get-Content "huntarr.spec" | Select-Object -First 5
|
||||
} else {
|
||||
Write-Error "Failed to create PyInstaller spec file"
|
||||
exit 1
|
||||
}
|
||||
|
||||
- name: Create simplified main.py
|
||||
run: |
|
||||
python installer/generate_main.py
|
||||
|
||||
# Verify the file exists
|
||||
if (Test-Path "main.py") {
|
||||
Write-Host "Simplified main.py with Windows service support created successfully"
|
||||
} else {
|
||||
Write-Error "Failed to create simplified main.py"
|
||||
exit 1
|
||||
}
|
||||
|
||||
- name: Build executable with PyInstaller
|
||||
run: |
|
||||
pyinstaller huntarr.spec
|
||||
|
||||
# Check if the build was successful
|
||||
if (Test-Path "dist/Huntarr.exe") {
|
||||
Write-Host "PyInstaller build successful!"
|
||||
} else {
|
||||
Write-Error "PyInstaller failed to build the executable"
|
||||
exit 1
|
||||
}
|
||||
|
||||
- name: Install NSIS
|
||||
run: |
|
||||
choco install nsis -y
|
||||
|
||||
- name: Build installer
|
||||
run: |
|
||||
makensis installer/huntarr-installer.nsi
|
||||
|
||||
- name: Get installer path
|
||||
id: installer-path
|
||||
shell: bash
|
||||
run: |
|
||||
VERSION="${{ steps.get-version.outputs.VERSION }}"
|
||||
INSTALLER_FILE="Huntarr-Setup-$VERSION.exe"
|
||||
ROOT_INSTALLER_PATH="$INSTALLER_FILE"
|
||||
INSTALLER_DIR_PATH="installer/$INSTALLER_FILE"
|
||||
|
||||
# Check multiple possible locations
|
||||
if [ -f "$ROOT_INSTALLER_PATH" ]; then
|
||||
echo "Installer found at root: $ROOT_INSTALLER_PATH"
|
||||
echo "INSTALLER_FILE=$ROOT_INSTALLER_PATH" >> $GITHUB_OUTPUT
|
||||
exit 0
|
||||
elif [ -f "$INSTALLER_DIR_PATH" ]; then
|
||||
echo "Installer found in installer directory: $INSTALLER_DIR_PATH"
|
||||
# Copy to root for consistency with release
|
||||
cp "$INSTALLER_DIR_PATH" "$ROOT_INSTALLER_PATH"
|
||||
echo "Copied installer to root directory"
|
||||
echo "INSTALLER_FILE=$ROOT_INSTALLER_PATH" >> $GITHUB_OUTPUT
|
||||
exit 0
|
||||
else
|
||||
# Find the installer wherever it might be
|
||||
echo "Searching for installer files:"
|
||||
find . -name "Huntarr-Setup-*.exe" -type f | while read file; do
|
||||
echo "Found installer: $file"
|
||||
# Copy the first one we find to the root
|
||||
cp "$file" "$ROOT_INSTALLER_PATH"
|
||||
echo "Copied $file to $ROOT_INSTALLER_PATH"
|
||||
echo "INSTALLER_FILE=$ROOT_INSTALLER_PATH" >> $GITHUB_OUTPUT
|
||||
exit 0
|
||||
done
|
||||
|
||||
# If we get here, no installer was found
|
||||
echo "ERROR: Installer not found. Checked:"
|
||||
echo " - $ROOT_INSTALLER_PATH"
|
||||
echo " - $INSTALLER_DIR_PATH"
|
||||
echo " - Searched for all Huntarr-Setup-*.exe files"
|
||||
echo "Directory contents:"
|
||||
ls -la
|
||||
echo "Installer directory contents:"
|
||||
ls -la installer/
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Create/Update Release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: ${{ steps.installer-path.outputs.INSTALLER_FILE }}
|
||||
name: Huntarr ${{ steps.get-version.outputs.VERSION }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
generate_release_notes: true
|
||||
body: |
|
||||
## Huntarr ${{ steps.get-version.outputs.VERSION }}
|
||||
|
||||
### Windows Installer
|
||||
|
||||
The Windows installer includes:
|
||||
- Full Huntarr application
|
||||
- Windows Service support for background operation
|
||||
- Automatic startup option
|
||||
|
||||
### Installation
|
||||
|
||||
1. Download the installer: `Huntarr-Setup-${{ steps.get-version.outputs.VERSION }}.exe`
|
||||
2. Run the installer and follow the instructions
|
||||
3. Optionally install as a Windows service for background operation
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
Reference in New Issue
Block a user