version #351
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Windows Build with NSIS | |
# Add permissions needed for creating releases | |
permissions: | |
contents: write | |
on: | |
push: | |
branches: [ "main", "dev", "win-*" ] | |
tags: | |
- "*" # This will trigger on any tag push | |
pull_request: | |
branches: [ "main", "dev" ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Extract metadata | |
id: meta | |
shell: bash | |
run: | | |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
echo "IS_TAG=true" >> $GITHUB_OUTPUT | |
else | |
echo "VERSION=$(cat version.txt)" >> $GITHUB_OUTPUT | |
echo "IS_TAG=false" >> $GITHUB_OUTPUT | |
fi | |
- 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 -r requirements.txt | |
pip install pyinstaller==5.13.0 | |
pip install pywin32 | |
- name: Create directories | |
run: | | |
mkdir -p config/logs | |
dir | |
dir config | |
- name: Build with PyInstaller | |
run: | | |
# Copy spec file from distribution directory to root | |
cp distribution/windows/huntarr.spec . | |
# Use the dedicated build script from the distribution directory | |
python -m pip install -r requirements.txt | |
python -m pip install pywin32 | |
pyinstaller -y distribution/windows/huntarr.spec | |
# Display contents of dist/Huntarr | |
dir dist/Huntarr | |
- name: Install NSIS | |
run: | | |
choco install nsis -y | |
- name: Build NSIS Installer | |
run: | | |
# Display current directory structure | |
dir | |
# Create installer output directory | |
mkdir -Force distribution\windows\installer\installer | |
mkdir -Force installer | |
# Prepare version file path | |
$versionContent = Get-Content version.txt -Raw | |
Write-Host "Version from file: $versionContent" | |
$AbsVersionFile = Join-Path -Path $PWD.Path -ChildPath "version.txt" | |
Write-Host "Absolute path for VERSIONFILE: $AbsVersionFile" | |
# Prepare arguments for makensis.exe | |
$MakensisArgs = @( | |
"/DVERSIONFILE=$AbsVersionFile", | |
"/DPROJECT_ROOT=$($PWD.Path)", | |
"distribution\windows\installer\huntarr_installer.nsi" | |
) | |
# Run NSIS compiler | |
Write-Host "Running makensis.exe with arguments: $MakensisArgs" | |
& "C:\Program Files (x86)\NSIS\makensis.exe" $MakensisArgs | |
# Check if installer was created | |
$version = (Get-Content version.txt).Trim() | |
$installerPath = "distribution\windows\installer\installer\Huntarr-${version}-win.exe" | |
if (Test-Path $installerPath) { | |
Write-Host "Installer created successfully at $installerPath" | |
# Copy to expected upload location | |
Copy-Item -Path $installerPath -Destination "installer\Huntarr-${version}-win.exe" -Force | |
} else { | |
Write-Error "Installer was not created. Check the logs above for errors." | |
exit 1 | |
} | |
# List any exe files in the installer directory | |
Get-ChildItem -Path installer -Filter *.exe | ForEach-Object { Write-Host $_.FullName } | |
- name: Upload installer | |
uses: actions/upload-artifact@v4 | |
with: | |
name: huntarr-installer | |
path: installer/Huntarr-*-win.exe | |
- name: Upload to release | |
if: steps.meta.outputs.IS_TAG == 'true' | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: installer/Huntarr-*-win.exe | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |