release/docs: version explicite dans les fichiers, ajout de sudo apt … #20
Workflow file for this run
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: Build and Release FileFind | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| tags: [ 'v*' ] | |
| pull_request: | |
| branches: [ main ] | |
| release: | |
| types: [published] | |
| env: | |
| APP_NAME: filefind | |
| # Note: github.ref_name will include the 'v' for tags, e.g., 'v1.1.3' | |
| # The version step below will handle removing it for the package version number. | |
| VERSION: ${{ github.ref_name }} | |
| permissions: | |
| contents: write | |
| pull-requests: read | |
| jobs: | |
| build-linux: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Get version | |
| id: version | |
| run: | | |
| if [[ $GITHUB_REF == refs/tags/* ]]; then | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| # Remove 'v' prefix if present for Debian compatibility | |
| VERSION=${VERSION#v} | |
| else | |
| # Debian-compatible dev version format | |
| VERSION="0.0.0-dev$(date +%Y%m%d).${GITHUB_SHA::7}" | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Building version: $VERSION" | |
| - name: Install Free Pascal Compiler | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y fpc lazarus-ide-qt5 lazarus-src lcl-utils build-essential | |
| - name: Build Linux binary | |
| run: | | |
| cd src | |
| # Try to compile with Lazarus first (handles dependencies better) | |
| echo "Building with Lazarus..." | |
| if command -v lazbuild >/dev/null 2>&1; then | |
| lazbuild --build-mode=Release filefind.lpi | |
| else | |
| echo "Lazarus not available, trying FPC directly..." | |
| fpc -O2 -Xs -XX -CX filefind.lpr | |
| fi | |
| # Find the binary (Lazarus puts it in subdirectories) | |
| if [ -f filefind ]; then | |
| BINARY_PATH="filefind" | |
| elif [ -f bin/x86_64-linux/filefind ]; then | |
| BINARY_PATH="bin/x86_64-linux/filefind" | |
| cp bin/x86_64-linux/filefind ./filefind | |
| elif [ -f lib/x86_64-linux/filefind ]; then | |
| BINARY_PATH="lib/x86_64-linux/filefind" | |
| cp lib/x86_64-linux/filefind ./filefind | |
| else | |
| echo "Build failed - binary not found" | |
| find . -name "filefind" -type f 2>/dev/null || echo "No filefind binary found anywhere" | |
| exit 1 | |
| fi | |
| # Strip and verify | |
| strip filefind | |
| echo "Build successful! Binary: $BINARY_PATH" | |
| ls -la filefind | |
| - name: Create Linux package structure | |
| run: | | |
| # Create standard package directories | |
| mkdir -p package/usr/bin | |
| mkdir -p package/usr/share/applications | |
| # Use standard Freedesktop icon theme path (assuming a 48x48 icon) | |
| mkdir -p package/usr/share/icons/hicolor/48x48/apps | |
| mkdir -p package/DEBIAN | |
| # Copy binary | |
| cp src/filefind package/usr/bin/ | |
| chmod +x package/usr/bin/filefind | |
| # Copy icon to the correct theme directory | |
| # Note: Renaming .ico to .png is not ideal. A proper conversion should be part of the build. | |
| cp src/filefind.ico package/usr/share/icons/hicolor/48x48/apps/filefind.png | |
| # Create desktop file | |
| cat > package/usr/share/applications/filefind.desktop << EOF | |
| [Desktop Entry] | |
| Version=1.0 | |
| Type=Application | |
| Name=FileFind | |
| Comment=Advanced file search utility | |
| Exec=filefind | |
| Icon=filefind | |
| Terminal=false | |
| Categories=Utility;FileTools; | |
| EOF | |
| - name: Create DEB control file | |
| run: | | |
| cat > package/DEBIAN/control << EOF | |
| Package: filefind | |
| Version: ${{ steps.version.outputs.version }} | |
| Section: utils | |
| Priority: optional | |
| Architecture: amd64 | |
| Depends: libc6 (>= 2.17) | |
| Maintainer: Nicolas DEOUX <[email protected]> | |
| Description: Advanced file search utility | |
| FileFind is an advanced file search utility designed to efficiently | |
| locate files and directories based on a wide range of criteria, | |
| including name patterns, size, attributes, content, and timestamps. | |
| . | |
| Features include comprehensive search options, content search, | |
| advanced filters, and cross-platform compatibility. | |
| Homepage: https://github.com/NDXDeveloper/FileFind | |
| EOF | |
| # The postinst and prerm scripts are removed as they are no longer needed. | |
| # dpkg triggers will handle icon cache and desktop database updates automatically. | |
| - name: Build DEB package | |
| run: | | |
| dpkg-deb --build package | |
| DEB_FILE="filefind_${{ steps.version.outputs.version }}_amd64.deb" | |
| mv package.deb "$DEB_FILE" | |
| # Fix permissions | |
| chmod a+r "$DEB_FILE" | |
| # Verify package | |
| dpkg-deb --info "$DEB_FILE" | |
| dpkg-deb --contents "$DEB_FILE" | |
| - name: Create portable Linux archive | |
| run: | | |
| mkdir -p filefind-linux-portable | |
| cp src/filefind filefind-linux-portable/ | |
| cp README.md filefind-linux-portable/ | |
| cp LICENSE.txt filefind-linux-portable/ | |
| # Create run script | |
| cat > filefind-linux-portable/run.sh << 'EOF' | |
| #!/bin/bash | |
| DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| "$DIR/filefind" "$@" | |
| EOF | |
| chmod +x filefind-linux-portable/run.sh | |
| tar -czf "filefind-linux-portable-${{ steps.version.outputs.version }}.tar.gz" filefind-linux-portable/ | |
| chmod a+r "filefind-linux-portable-${{ steps.version.outputs.version }}.tar.gz" | |
| - name: Upload Linux artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-builds | |
| path: | | |
| filefind_*.deb | |
| filefind-linux-portable-*.tar.gz | |
| src/filefind | |
| retention-days: 30 | |
| build-windows: | |
| runs-on: windows-latest | |
| needs: build-linux | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Free Pascal Compiler | |
| run: | | |
| # Use Chocolatey for complete Lazarus installation | |
| Write-Host "Installing Lazarus (includes FPC) via Chocolatey..." | |
| choco install lazarus -y | |
| # Add Lazarus paths to environment | |
| echo "C:\lazarus\fpc\3.2.2\bin\i386-win32" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| echo "C:\lazarus" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| # Verify installation | |
| Write-Host "Verifying Lazarus installation..." | |
| & "C:\lazarus\lazbuild.exe" --version | |
| - name: Build Windows binary | |
| run: | | |
| cd src | |
| $version = "${{ needs.build-linux.outputs.version }}" | |
| # Try to build with Lazarus first (handles dependencies) | |
| Write-Host "Building with Lazarus..." | |
| if (Test-Path "C:\lazarus\lazbuild.exe") { | |
| & "C:\lazarus\lazbuild.exe" --build-mode=Release filefind.lpi | |
| } else { | |
| Write-Host "Lazarus not found, trying FPC with simplified approach..." | |
| & fpc -O2 -Xs -XX -CX filefind.lpr | |
| } | |
| # Find the binary (Lazarus puts it in subdirectories) | |
| $binaryFound = $false | |
| $binaryPath = "" | |
| if (Test-Path "filefind.exe") { | |
| $binaryPath = "filefind.exe" | |
| $binaryFound = $true | |
| } elseif (Test-Path "bin\x86_64-win64\filefind.exe") { | |
| $binaryPath = "bin\x86_64-win64\filefind.exe" | |
| Copy-Item "bin\x86_64-win64\filefind.exe" "filefind.exe" | |
| $binaryFound = $true | |
| } elseif (Test-Path "lib\x86_64-win64\filefind.exe") { | |
| $binaryPath = "lib\x86_64-win64\filefind.exe" | |
| Copy-Item "lib\x86_64-win64\filefind.exe" "filefind.exe" | |
| $binaryFound = $true | |
| } | |
| if ($binaryFound) { | |
| Write-Host "Build successful! Binary found at: $binaryPath" | |
| Get-Item "filefind.exe" | Format-List Name, Length, LastWriteTime | |
| } else { | |
| Write-Host "Build failed - binary not found" | |
| Get-ChildItem -Filter "*.exe" -Recurse | Format-Table Name, FullName | |
| exit 1 | |
| } | |
| - name: Create Windows installer script | |
| run: | | |
| $version = "${{ needs.build-linux.outputs.version }}" | |
| $issScript = @" | |
| #define MyAppName "FileFind" | |
| #define MyAppVersion "$version" | |
| #define MyAppPublisher "Nicolas DEOUX" | |
| #define MyAppURL "https://github.com/NDXDeveloper/FileFind" | |
| #define MyAppExeName "filefind.exe" | |
| [Setup] | |
| AppId={{B8C5C1F0-8A2D-4E3F-9B1A-2C4D5E6F7G8H} | |
| AppName={#MyAppName} | |
| AppVersion={#MyAppVersion} | |
| AppPublisher={#MyAppPublisher} | |
| AppPublisherURL={#MyAppURL} | |
| AppSupportURL={#MyAppURL} | |
| AppUpdatesURL={#MyAppURL} | |
| DefaultDirName={autopf}\{#MyAppName} | |
| DefaultGroupName={#MyAppName} | |
| AllowNoIcons=yes | |
| OutputDir=. | |
| OutputBaseFilename=FileFind-Setup-{#MyAppVersion} | |
| Compression=lzma | |
| SolidCompression=yes | |
| WizardStyle=modern | |
| ArchitecturesAllowed=x86 x64 | |
| ArchitecturesInstallIn64BitMode=x64 | |
| [Languages] | |
| Name: "english"; MessagesFile: "compiler:Default.isl" | |
| Name: "french"; MessagesFile: "compiler:Languages\French.isl" | |
| [Tasks] | |
| Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked | |
| Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 6.1 | |
| [Files] | |
| Source: "src\filefind.exe"; DestDir: "{app}"; Flags: ignoreversion | |
| Source: "README.md"; DestDir: "{app}"; Flags: ignoreversion | |
| Source: "LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion | |
| Source: "docs\*"; DestDir: "{app}\docs"; Flags: ignoreversion recursesubdirs createallsubdirs | |
| [Icons] | |
| Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" | |
| Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" | |
| Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon | |
| Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon | |
| [Registry] | |
| Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\{#MyAppExeName}"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName}"; Flags: uninsdeletekeyifempty | |
| Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\{#MyAppExeName}"; ValueType: string; ValueName: "Path"; ValueData: "{app}"; Flags: uninsdeletekeyifempty | |
| [Run] | |
| Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#MyAppName}}"; Flags: nowait postinstall skipifsilent | |
| [Code] | |
| procedure InitializeWizard; | |
| begin | |
| WizardForm.LicenseAcceptedRadio.Checked := True; | |
| end; | |
| "@ | |
| $issScript | Out-File -FilePath "installer.iss" -Encoding utf8 | |
| - name: Install Inno Setup | |
| run: | | |
| choco install innosetup -y | |
| - name: Create Windows installer | |
| run: | | |
| & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" installer.iss | |
| - name: Create portable Windows archive | |
| run: | | |
| mkdir filefind-windows-portable | |
| copy src\filefind.exe filefind-windows-portable\ | |
| copy README.md filefind-windows-portable\ | |
| copy LICENSE.txt filefind-windows-portable\ | |
| # Create batch file | |
| @" | |
| @echo off | |
| cd /d "%~dp0" | |
| filefind.exe %* | |
| "@ | Out-File -FilePath "filefind-windows-portable\run.bat" -Encoding ascii | |
| Compress-Archive -Path "filefind-windows-portable" -DestinationPath "filefind-windows-portable-${{ needs.build-linux.outputs.version }}.zip" | |
| - name: Upload Windows artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-builds | |
| path: | | |
| FileFind-Setup-*.exe | |
| filefind-windows-portable-*.zip | |
| src/filefind.exe | |
| retention-days: 30 | |
| create-release: | |
| runs-on: ubuntu-latest | |
| needs: [build-linux, build-windows] | |
| if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| - name: Prepare release assets | |
| run: | | |
| mkdir -p release-assets | |
| # Copy Linux builds | |
| cp linux-builds/*.deb release-assets/ | |
| cp linux-builds/*.tar.gz release-assets/ | |
| # Copy Windows builds | |
| cp windows-builds/*.exe release-assets/ | |
| cp windows-builds/*.zip release-assets/ | |
| # Create checksums | |
| cd release-assets | |
| sha256sum * > checksums.txt | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: release-assets/* | |
| draft: false | |
| prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }} | |
| # generate_release_notes: true # We are providing a custom body | |
| body: | | |
| ## FileFind ${{ needs.build-linux.outputs.version }} | |
| Advanced file search utility with comprehensive search options and cross-platform compatibility. | |
| ### Downloads 📦 | |
| - **Linux Debian/Ubuntu Package:** `filefind_${{ needs.build-linux.outputs.version }}_amd64.deb` | |
| - **Linux Portable Archive:** `filefind-linux-portable-${{ needs.build-linux.outputs.version }}.tar.gz` | |
| - **Windows Installer:** `FileFind-Setup-${{ needs.build-linux.outputs.version }}.exe` | |
| - **Windows Portable Archive:** `filefind-windows-portable-${{ needs.build-linux.outputs.version }}.zip` | |
| --- | |
| ### Installation 🚀 | |
| #### Linux (DEB) | |
| **1. Download the package:** | |
| ```bash | |
| curl -LO [https://github.com/$](https://github.com/$){{ github.repository }}/releases/download/${{ github.ref_name }}/filefind_${{ needs.build-linux.outputs.version }}_amd64.deb | |
| ``` | |
| **2. Install the package (choose one method):** | |
| *Method A: Recommended (handles dependencies)* | |
| ```bash | |
| sudo apt install ./filefind_${{ needs.build-linux.outputs.version }}_amd64.deb | |
| ``` | |
| *Method B: Using dpkg* | |
| ```bash | |
| sudo dpkg -i filefind_${{ needs.build-linux.outputs.version }}_amd64.deb | |
| # If you have dependency errors, run this: | |
| sudo apt-get install -f | |
| ``` | |
| #### Linux (Portable) | |
| **1. Download and extract:** | |
| ```bash | |
| curl -LO [https://github.com/$](https://github.com/$){{ github.repository }}/releases/download/${{ github.ref_name }}/filefind-linux-portable-${{ needs.build-linux.outputs.version }}.tar.gz | |
| tar -xzf filefind-linux-portable-${{ needs.build-linux.outputs.version }}.tar.gz | |
| ``` | |
| **2. Run the application:** | |
| ```bash | |
| cd filefind-linux-portable | |
| ./run.sh | |
| ``` | |
| #### Windows | |
| - **Installer:** Download and run `FileFind-Setup-${{ needs.build-linux.outputs.version }}.exe`. | |
| - **Portable:** Download and extract `filefind-windows-portable-${{ needs.build-linux.outputs.version }}.zip`. | |
| --- | |
| ### Verification ✅ | |
| All files are signed with SHA256 checksums available in `checksums.txt`. | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| notify-success: | |
| runs-on: ubuntu-latest | |
| needs: [build-linux, build-windows] | |
| if: always() | |
| steps: | |
| - name: Notify build status | |
| run: | | |
| if [[ "${{ needs.build-linux.result }}" == "success" ]] && [[ "${{ needs.build-windows.result }}" == "success" ]]; then | |
| echo "✅ All builds completed successfully!" | |
| echo "Version: ${{ needs.build-linux.outputs.version }}" | |
| else | |
| echo "❌ Some builds failed" | |
| echo "Linux: ${{ needs.build-linux.result }}" | |
| echo "Windows: ${{ needs.build-windows.result }}" | |
| exit 1 | |
| fi |