name: Build Windows Installer on: workflow_call: inputs: app_version: description: 'Application version' type: string required: false default: '' ref: description: 'Git ref to checkout (branch, tag, or SHA). Defaults to github.ref_name.' type: string required: false default: '' jobs: build-windows-installer: runs-on: windows-latest steps: - name: Set variables shell: pwsh run: | $repoFullName = "${{ github.repository }}" $ref = "${{ github.ref }}" $inputVersion = "${{ inputs.app_version }}" # Use input version if provided, otherwise determine from ref if ($inputVersion -ne "") { $appVersion = $inputVersion $releaseVersion = "v$appVersion" } elseif ($ref -match "^refs/tags/") { $releaseVersion = $ref -replace "refs/tags/", "" $appVersion = $releaseVersion -replace "^v", "" } else { # For manual dispatch, use a default version $releaseVersion = "dev-$(Get-Date -Format 'yyyyMMdd-HHmmss')" $appVersion = "0.0.1-dev" } $repositoryName = $repoFullName.Split("/")[1] echo "githubRepository=${{ github.repository }}" >> $env:GITHUB_ENV echo "githubRepositoryName=$repositoryName" >> $env:GITHUB_ENV echo "releaseVersion=$releaseVersion" >> $env:GITHUB_ENV echo "appVersion=$appVersion" >> $env:GITHUB_ENV echo "APP_VERSION=$appVersion" >> $env:GITHUB_ENV echo "executableName=Cleanuparr.Api" >> $env:GITHUB_ENV - name: Get vault secrets uses: hashicorp/vault-action@v2 with: url: ${{ secrets.VAULT_HOST }} method: approle roleId: ${{ secrets.VAULT_ROLE_ID }} secretId: ${{ secrets.VAULT_SECRET_ID }} secrets: secrets/data/github repo_readonly_pat | REPO_READONLY_PAT; secrets/data/github packages_pat | PACKAGES_PAT - name: Checkout repository uses: actions/checkout@v4 with: repository: ${{ env.githubRepository }} ref: ${{ inputs.ref || github.ref_name }} token: ${{ env.REPO_READONLY_PAT }} - name: Download frontend artifact uses: actions/download-artifact@v4 with: name: frontend-dist path: code/frontend/dist/ui/browser - name: Setup .NET uses: actions/setup-dotnet@v5 with: dotnet-version: 10.0.200 - name: Restore .NET dependencies run: | dotnet nuget add source --username ${{ github.repository_owner }} --password ${{ env.PACKAGES_PAT }} --store-password-in-clear-text --name Cleanuparr https://nuget.pkg.github.com/Cleanuparr/index.json dotnet restore code/backend/${{ env.executableName }}/${{ env.executableName }}.csproj - name: Copy frontend to backend wwwroot shell: pwsh run: | New-Item -ItemType Directory -Force -Path "code/backend/${{ env.executableName }}/wwwroot" Copy-Item -Path "code/frontend/dist/ui/browser/*" -Destination "code/backend/${{ env.executableName }}/wwwroot/" -Recurse -Force - name: Build Windows executable run: | dotnet publish code/backend/${{ env.executableName }}/${{ env.executableName }}.csproj -c Release --runtime win-x64 --self-contained -o dist /p:PublishSingleFile=true /p:Version=${{ env.appVersion }} /p:DebugType=None /p:DebugSymbols=false - name: Setup Inno Setup shell: pwsh run: | # Download and install Inno Setup $url = "https://jrsoftware.org/download.php/is.exe" $output = "innosetup-installer.exe" Invoke-WebRequest -Uri $url -OutFile $output Start-Process -FilePath $output -ArgumentList "/VERYSILENT", "/SUPPRESSMSGBOXES", "/NORESTART" -Wait # Add Inno Setup to PATH $innoPath = "C:\Program Files (x86)\Inno Setup 6" echo "$innoPath" >> $env:GITHUB_PATH - name: Verify LICENSE file exists shell: pwsh run: | if (-not (Test-Path "LICENSE")) { Write-Error "LICENSE file not found in repository root" exit 1 } Write-Host "LICENSE file found successfully" - name: Build Windows installer shell: pwsh run: | # Copy installer script to root Copy-Item "installers/windows/cleanuparr-installer.iss" -Destination "cleanuparr-installer.iss" # The installer script has been pre-updated with proper icon and config paths # No dynamic modifications needed as the base script now includes correct references # Run Inno Setup compiler & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "cleanuparr-installer.iss" # Check if installer was created if (Test-Path "installer/Cleanuparr_Setup.exe") { Write-Host "Installer created successfully" } else { Write-Error "Installer creation failed" exit 1 } - name: Rename installer with version shell: pwsh run: | $installerName = "Cleanuparr-${{ env.appVersion }}-Setup.exe" Move-Item "installer/Cleanuparr_Setup.exe" "installer/$installerName" echo "installerName=$installerName" >> $env:GITHUB_ENV - name: Upload installer artifact uses: actions/upload-artifact@v4 with: name: Cleanuparr-windows-installer path: installer/${{ env.installerName }} retention-days: 30 # Removed individual release step - handled by main release workflow