|
| 1 | +name: Build Template (Windows + Linux) (PyInstaller Packages) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + is_release: |
| 7 | + required: false |
| 8 | + type: boolean |
| 9 | + default: false |
| 10 | + release_tag: |
| 11 | + required: false |
| 12 | + type: string |
| 13 | + default: "" |
| 14 | + |
| 15 | +jobs: |
| 16 | + build-windows: |
| 17 | + name: Build on Windows (PyInstaller EXE) |
| 18 | + runs-on: windows-latest # Use GitHub-hosted Windows runner |
| 19 | + steps: |
| 20 | + - name: Checkout code |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + submodules: recursive |
| 24 | + fetch-depth: 0 # Needed for git history, versioning, and submodules |
| 25 | + |
| 26 | + - name: Download latest Graphviz Windows ZIP from GitLab |
| 27 | + run: | |
| 28 | + $release = (Invoke-RestMethod -Uri "https://gitlab.com/api/v4/projects/4207231/releases")[0] |
| 29 | + $version = $release.tag_name |
| 30 | + Write-Host "Latest version: $version" |
| 31 | + $url = "https://gitlab.com/api/v4/projects/4207231/packages/generic/graphviz-releases/$version/windows_10_cmake_Release_Graphviz-$version-win64.zip" |
| 32 | + Write-Host "Downloading from: $url" |
| 33 | + Invoke-WebRequest $url -OutFile graphviz.zip |
| 34 | + Expand-Archive graphviz.zip -DestinationPath "$env:GITHUB_WORKSPACE\graphviz" |
| 35 | + Get-ChildItem "$env:GITHUB_WORKSPACE\graphviz" -Recurse -Directory |
| 36 | + echo "GRAPHVIZ_ROOT=$env:GITHUB_WORKSPACE\graphviz\Graphviz-$version-win64" >> $env:GITHUB_ENV |
| 37 | + echo "$env:GITHUB_WORKSPACE\graphviz\Graphviz-$version-win64\bin" >> $env:GITHUB_PATH |
| 38 | + Write-Host $GRAPHVIZ_ROOT |
| 39 | + Write-Host $env:GRAPHVIZ_ROOT |
| 40 | + shell: powershell |
| 41 | + |
| 42 | + - name: Setup Python |
| 43 | + uses: actions/setup-python@v4 |
| 44 | + with: |
| 45 | + python-version: '3.11' |
| 46 | + |
| 47 | + - name: Install PyGraphviz |
| 48 | + run: | |
| 49 | + Get-ChildItem "$env:GRAPHVIZ_ROOT" -Recurse -Directory |
| 50 | +
|
| 51 | + $includePath="$env:GRAPHVIZ_ROOT\include" |
| 52 | + $libPath="$env:GRAPHVIZ_ROOT\lib" |
| 53 | + |
| 54 | + Write-Host "Using Graphviz include: $includePath" |
| 55 | + Write-Host "Using Graphviz lib: $libPath" |
| 56 | + |
| 57 | + $env:INCLUDE=$includePath |
| 58 | + $env:LIB=$libPath |
| 59 | + |
| 60 | + Write-Host "Using INCLUDE: $env:INCLUDE" |
| 61 | + Write-Host "Using LIB: $env:LIB" |
| 62 | + |
| 63 | + python -m pip install --upgrade pip |
| 64 | + pip install pygraphviz |
| 65 | + shell: powershell |
| 66 | + |
| 67 | + - name: Install dependencies |
| 68 | + run: | |
| 69 | + python -m pip install --upgrade pip |
| 70 | + pip install -r requirements.txt |
| 71 | + pip install pyinstaller pyinstaller-versionfile |
| 72 | + shell: powershell |
| 73 | + |
| 74 | + - name: Set dynamic version |
| 75 | + run: | |
| 76 | + $branch = "${env:GITHUB_HEAD_REF}" |
| 77 | + if (-not $branch) { $branch = "${env:GITHUB_REF}" -replace 'refs/heads/', '' } |
| 78 | + $commit = (git rev-parse --short HEAD).Trim() |
| 79 | + $version = "$branch-$commit" |
| 80 | + echo $version > $env:GITHUB_WORKSPACE\VERSION |
| 81 | + shell: powershell |
| 82 | + |
| 83 | + - name: Build EXE with PyInstaller |
| 84 | + run: | |
| 85 | + pyinstaller $env:GITHUB_WORKSPACE\.spec --noconfirm |
| 86 | + shell: powershell |
| 87 | + |
| 88 | + - name: Rename artifact if release |
| 89 | + if: inputs.is_release |
| 90 | + run: | |
| 91 | + Rename-Item -Path dist/PlumberManager.exe -NewName "PlumberManager-${{ inputs.release_tag }}-windows.exe" |
| 92 | +
|
| 93 | + - name: Upload artifact |
| 94 | + uses: actions/upload-artifact@v4 |
| 95 | + with: |
| 96 | + name: PlumberManager-Windows |
| 97 | + path: dist/PlumberManager*.exe |
| 98 | + |
| 99 | + build-linux: |
| 100 | + name: Build on Linux (PyInstaller AppImage) |
| 101 | + runs-on: ubuntu-latest # Ubuntu runner, will use Rocky Linux container |
| 102 | + container: |
| 103 | + image: rockylinux:8 # Use Rocky Linux 8 for broad compatibility |
| 104 | + steps: |
| 105 | + |
| 106 | + - name: Install build tools |
| 107 | + run: | |
| 108 | + dnf install -y dnf-plugins-core |
| 109 | + dnf install -y epel-release |
| 110 | + dnf config-manager --set-enabled devel |
| 111 | + dnf install -y git file |
| 112 | + dnf install -y python3.11 python3.11-pip python3.11-devel |
| 113 | + dnf install -y graphviz graphviz-devel |
| 114 | + dnf install -y gcc gcc-c++ |
| 115 | + dnf install -y libxkbcommon libxkbcommon-x11 xcb-util-wm libglvnd-egl |
| 116 | + dnf install -y xcb-util-keysyms xcb-util-renderutil vulkan-loader |
| 117 | + dnf install -y xcb-util-cursor libglvnd libglvnd-glx xcb-util-image |
| 118 | + dnf install -y mesa-libGL gtk3 cairo-gobject gdk-pixbuf2 libatomic |
| 119 | +
|
| 120 | + - name: Checkout code |
| 121 | + uses: actions/checkout@v4 |
| 122 | + with: |
| 123 | + submodules: recursive |
| 124 | + fetch-depth: 0 # Needed for git history, versioning, and submodules |
| 125 | + |
| 126 | + - name: Install Python dependencies |
| 127 | + run: | |
| 128 | + python3.11 -m pip install --upgrade pip |
| 129 | + python3.11 -m pip install -r requirements.txt |
| 130 | + python3.11 -m pip install pyinstaller pyinstaller-versionfile |
| 131 | + shell: bash |
| 132 | + |
| 133 | + - name: Set dynamic version |
| 134 | + run: | |
| 135 | + branch="${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}" |
| 136 | + commit="${GITHUB_SHA:0:7}" |
| 137 | + version="$branch-$commit" |
| 138 | + echo "$version" > $GITHUB_WORKSPACE/VERSION |
| 139 | + shell: bash |
| 140 | + |
| 141 | + - name: Build Linux binary with PyInstaller |
| 142 | + run: | |
| 143 | + cd $GITHUB_WORKSPACE |
| 144 | + python3.11 -m PyInstaller $GITHUB_WORKSPACE/.spec --noconfirm |
| 145 | + echo "Current dir: $(pwd)" |
| 146 | + ls -R |
| 147 | + shell: bash |
| 148 | + |
| 149 | + - name: Rename binaries for release |
| 150 | + if: inputs.is_release |
| 151 | + run: | |
| 152 | + mv dist/PlumberManager PlumberManager-${{ inputs.release_tag }}-rocky8 |
| 153 | +
|
| 154 | + - uses: actions/upload-artifact@v4 |
| 155 | + with: |
| 156 | + name: Upload Linux artifact PlumberManager-Linux-ELF |
| 157 | + path: dist/PlumberManager* |
| 158 | + |
| 159 | + - name: Package as AppImage |
| 160 | + run: | |
| 161 | + dnf install -y file |
| 162 | + cd $GITHUB_WORKSPACE |
| 163 | + curl -Lo appimagetool https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage |
| 164 | + chmod +x appimagetool |
| 165 | + mkdir -p AppDir/usr/bin |
| 166 | + cp -r dist/PlumberManager* AppDir/usr/bin/ |
| 167 | + chmod -R +x AppDir/usr/bin |
| 168 | + ln -s usr/bin/PlumberManager AppDir/AppRun |
| 169 | + cp "$GITHUB_WORKSPACE/resources/icon_256.png" AppDir/plumbermanager.png |
| 170 | + cat > AppDir/plumbermanager.desktop <<EOF |
| 171 | + [Desktop Entry] |
| 172 | + Type=Application |
| 173 | + Name=PlumberManager |
| 174 | + Exec=PlumberManager |
| 175 | + Icon=plumbermanager |
| 176 | + Categories=Utility |
| 177 | + EOF |
| 178 | + ./appimagetool --appimage-extract-and-run AppDir PlumberManager-x86_64.AppImage |
| 179 | + echo "Current dir: $(pwd)" |
| 180 | + ls -R |
| 181 | + shell: bash |
| 182 | + |
| 183 | + - name: Rename binaries for release |
| 184 | + if: inputs.is_release |
| 185 | + run: | |
| 186 | + mv PlumberManager-x86_64.AppImage PlumberManager-${{ inputs.release_tag }}-linux.AppImage |
| 187 | +
|
| 188 | + - uses: actions/upload-artifact@v4 |
| 189 | + with: |
| 190 | + name: Upload Linux artifact PlumberManager-Linux-AppImage |
| 191 | + path: PlumberManager*.AppImage |
0 commit comments