Skip to content

Merge pull request #476 from zab1996/ffprobe-plex-mode-additions #1274

Merge pull request #476 from zab1996/ffprobe-plex-mode-additions

Merge pull request #476 from zab1996/ffprobe-plex-mode-additions #1274

Workflow file for this run

name: Docker Image CI
on:
push:
branches: [ "dev", "main", "battery_integration"]
workflow_dispatch: # This enables manual triggering
jobs:
build-windows-exe:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_TOKEN }}
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Upgrade npm (brings in fixed node-gyp)
run: npm install -g npm@10.9.0
shell: bash
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Setup Visual Studio Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
- name: Set PYTHON environment variable for node-gyp
shell: powershell
run: |
$pythonPath = (Get-Command python).Source
echo "PYTHON=$pythonPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Host "Set PYTHON environment variable to $pythonPath"
- name: Verify build environment
shell: powershell
run: |
# Verify Python is available
$pythonPath = (Get-Command python).Source
Write-Host "Python available at: $pythonPath"
python --version
# Verify Visual Studio environment
Write-Host "Visual Studio environment variables:"
Write-Host "VCINSTALLDIR: $env:VCINSTALLDIR"
Write-Host "VCToolsInstallDir: $env:VCToolsInstallDir"
Write-Host "INCLUDE: $env:INCLUDE"
Write-Host "LIB: $env:LIB"
- name: Clean and install phalanx_db_hyperswarm dependencies
shell: powershell
run: |
cd phalanx_db_hyperswarm
# Force kill any processes that might be holding file handles
Write-Host "Stopping any processes that might lock files..."
Get-Process -Name "msbuild" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Get-Process -Name "node" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Get-Process -Name "cl" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
# Remove existing node_modules if it exists
if (Test-Path "node_modules") {
Write-Host "Removing existing node_modules directory..."
# Use robust removal with retry logic
$maxRetries = 3
$retryCount = 0
do {
try {
Remove-Item -Recurse -Force -Path "node_modules" -ErrorAction Stop
Write-Host "Successfully removed node_modules"
break
}
catch {
$retryCount++
Write-Host "Attempt $retryCount failed: $($_.Exception.Message)"
if ($retryCount -lt $maxRetries) {
Write-Host "Waiting 5 seconds before retry..."
Start-Sleep -Seconds 5
} else {
Write-Host "Max retries reached, continuing anyway..."
}
}
} while ($retryCount -lt $maxRetries)
}
# Clean npm cache
npm cache clean --force
# Set environment variables for native compilation
$env:npm_config_cache = "$env:APPDATA\npm-cache"
$env:npm_config_progress = "false"
# Try to install with prebuilt binaries first
Write-Host "Attempting to install with prebuilt binaries..."
npm install --prefer-offline --no-audit --no-fund --loglevel=info
if ($LASTEXITCODE -eq 0) {
Write-Host "[SUCCESS] Successfully installed all dependencies with prebuilt binaries"
} else {
Write-Host "[ERROR] Prebuilt installation failed (exit code: $LASTEXITCODE)"
Write-Host "[INFO] Attempting to build native modules from source..."
# Clear any partial installation
if (Test-Path "node_modules") {
Write-Host "Clearing partial installation..."
Remove-Item -Recurse -Force -Path "node_modules" -ErrorAction SilentlyContinue
Start-Sleep -Seconds 2
}
# Try full installation with build from source
Write-Host "Installing all dependencies with native compilation..."
npm install --msvs_version=2022 --loglevel=verbose
if ($LASTEXITCODE -ne 0) {
Write-Host "[FATAL ERROR] Failed to install npm dependencies"
Write-Host "Build cannot continue without required Node.js dependencies"
Write-Host "Exit code: $LASTEXITCODE"
exit 1
} else {
Write-Host "[SUCCESS] Successfully built all dependencies from source"
}
}
# Verify critical packages are installed
Write-Host "`n=== Verifying Installation ==="
$criticalPackages = @("hyperbee", "hyperswarm", "@hyperswarm/rpc", "autobase", "corestore")
$missingPackages = @()
foreach ($package in $criticalPackages) {
$packagePath = "node_modules\$package"
if (Test-Path $packagePath) {
Write-Host "[OK] $package - installed"
} else {
Write-Host "[MISSING] $package - MISSING"
$missingPackages += $package
}
}
if ($missingPackages.Count -gt 0) {
Write-Host "`n[FATAL ERROR] Missing critical packages: $($missingPackages -join ', ')"
Write-Host "Build cannot continue without these dependencies"
exit 1
}
Write-Host "`n[SUCCESS] All critical Node.js dependencies successfully installed"
cd ..
- name: Create and activate virtual environment
shell: cmd
run: |
python -m venv build_venv
call build_venv\Scripts\activate.bat
- name: Install dependencies
shell: cmd
run: |
call build_venv\Scripts\activate.bat
python -m pip install --upgrade pip
pip install "setuptools<65.0.0" # Pin to a version that supports dash-separated keys in setup.cfg
pip install pyinstaller
pip install -r requirements.txt
pip install psutil
- name: Build Windows executable
shell: cmd
run: |
call build_venv\Scripts\activate.bat
pyinstaller windows_build.spec --clean
- name: Package Windows executable
shell: powershell
run: |
$version = Get-Content -Path version.txt -Raw
$version = $version.Trim()
# Create a zip file containing the entire dist directory
Compress-Archive -Path dist\cli_debrid\* -DestinationPath "dist\cli_debrid-$version.zip"
- name: Upload Windows artifact
uses: actions/upload-artifact@v4
with:
name: windows-executable
path: dist/cli_debrid-*.zip
build-and-push:
runs-on: ubuntu-latest
needs: build-windows-exe
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_TOKEN }}
submodules: recursive
- name: Download Windows artifact
uses: actions/download-artifact@v4
with:
name: windows-executable
path: windows-executable
- name: Get version and verify branch
id: version_check
run: |
VERSION=$(cat version.txt)
BRANCH_ID=$(cat branch_id | tr -d '[:space:]')
CURRENT_BRANCH=${{ github.ref_name }}
echo "VERSION=$VERSION" >> $GITHUB_ENV
# Verify branch_id matches current branch
if [ "$BRANCH_ID" != "$CURRENT_BRANCH" ]; then
echo "::error::Branch mismatch! branch_id contains '$BRANCH_ID' but current branch is '$CURRENT_BRANCH'"
exit 1
fi
- name: Create Release
if: github.ref_name == 'main' || github.ref_name == 'dev'
uses: softprops/action-gh-release@v1
with:
files: "windows-executable/cli_debrid-${{ env.VERSION }}.zip"
name: "Release ${{ env.VERSION }}"
tag_name: "v${{ env.VERSION }}"
target_commitish: ${{ github.sha }}
draft: false
prerelease: ${{ github.ref_name == 'dev' }}
body: |
Version ${{ env.VERSION }} (${{ github.ref_name }} branch)
This release was automatically created from the ${{ github.ref_name }} branch.
Commit: ${{ github.sha }}
## Installation Instructions:
1. Download the ZIP file
2. Extract all contents to a folder of your choice
3. Run `cli_debrid.exe` from the extracted folder
**Note:** All files must be kept together in the same folder for the application to work properly.
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get version from version.txt
run: echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV
- name: Set Docker tags
run: |
if [ "${{ github.ref_name }}" = "dev" ]; then
echo "DOCKER_TAGS=godver3/cli_debrid:dev,godver3/cli_debrid:dev-${{ env.VERSION }},godver3/cli_debrid:latest" >> $GITHUB_ENV
elif [ "${{ github.ref_name }}" = "main" ]; then
echo "DOCKER_TAGS=godver3/cli_debrid:main,godver3/cli_debrid:main-${{ env.VERSION }}" >> $GITHUB_ENV
else
echo "DOCKER_TAGS=godver3/cli_debrid:batteryintegration,godver3/cli_debrid:batteryintegration-${{ env.VERSION }}" >> $GITHUB_ENV
fi
echo "Resolved tags: $DOCKER_TAGS" # Added for debugging/visibility
- name: Notify Discord - Build Started
uses: sarisia/actions-status-discord@v1
with:
webhook: ${{ secrets.DISCORD_TOKEN }}
title: "Docker Build Started"
description: "Building version ${{ env.VERSION }} for tags: ${{ env.DOCKER_TAGS }}"
color: 0xFFA500
- name: Build and push multi-platform image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.DOCKER_TAGS }}
build-args: |
BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
# Pass Windows executable info if needed via build context or args
- name: Notify Discord - Build Completed
uses: sarisia/actions-status-discord@v1
with:
webhook: ${{ secrets.DISCORD_TOKEN }}
title: "Docker Build Completed"
description: "Version ${{ env.VERSION }} has been built and pushed to Docker Hub.\nTags: ${{ env.DOCKER_TAGS }}"
color: 0x00FF00