|
| 1 | +name: Build and Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, develop ] |
| 6 | + tags: |
| 7 | + - 'v*' |
| 8 | + pull_request: |
| 9 | + branches: [ main, develop ] |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +env: |
| 13 | + CMAKE_VERSION: "3.28.0" |
| 14 | + QT_VERSION: "6.9.3" |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + # Windows MSVC builds |
| 23 | + - name: "Windows MSVC 2022 x64" |
| 24 | + os: windows-2022 |
| 25 | + preset: "windows-msvc-x64-release" |
| 26 | + cmake_generator: "Visual Studio 17 2022" |
| 27 | + cmake_platform: "x64" |
| 28 | + qt_arch: "win64_msvc2022_64" |
| 29 | + artifact_prefix: "windows-msvc-x64" |
| 30 | + |
| 31 | + # macOS builds |
| 32 | + - name: "macOS x86_64 (Intel)" |
| 33 | + os: macos-13 |
| 34 | + preset: "macos-x64-release" |
| 35 | + cmake_generator: "Ninja" |
| 36 | + cmake_build_type: "Release" |
| 37 | + qt_arch: "clang_64" |
| 38 | + artifact_prefix: "macos-x64" |
| 39 | + |
| 40 | + # Linux builds |
| 41 | + - name: "Linux x64" |
| 42 | + os: ubuntu-22.04 |
| 43 | + preset: "linux-x64-release" |
| 44 | + cmake_generator: "Ninja" |
| 45 | + cmake_build_type: "Release" |
| 46 | + qt_arch: "linux_gcc_64" |
| 47 | + artifact_prefix: "linux-x64" |
| 48 | + |
| 49 | + # ARM Linux builds |
| 50 | + - name: "ARM Linux (aarch64)" |
| 51 | + os: ubuntu-22.04 |
| 52 | + preset: "linux-arm64-release" |
| 53 | + cmake_generator: "Ninja" |
| 54 | + cmake_build_type: "Release" |
| 55 | + qt_arch: "linux_gcc_arm64" |
| 56 | + artifact_prefix: "linux-arm64" |
| 57 | + |
| 58 | + runs-on: ${{ matrix.os }} |
| 59 | + name: ${{ matrix.name }} |
| 60 | + |
| 61 | + steps: |
| 62 | + - name: Checkout code |
| 63 | + uses: actions/checkout@v4 |
| 64 | + with: |
| 65 | + fetch-depth: 0 |
| 66 | + |
| 67 | + - name: Install Qt (Windows) |
| 68 | + if: runner.os == 'Windows' |
| 69 | + uses: jurplel/install-qt-action@v4 |
| 70 | + with: |
| 71 | + version: ${{ env.QT_VERSION }} |
| 72 | + arch: ${{ matrix.qt_arch }} |
| 73 | + cache: 'true' |
| 74 | + |
| 75 | + - name: Install Qt (macOS) |
| 76 | + if: runner.os == 'macOS' |
| 77 | + uses: jurplel/install-qt-action@v4 |
| 78 | + with: |
| 79 | + version: ${{ env.QT_VERSION }} |
| 80 | + arch: ${{ matrix.cmake_platform == 'arm64' && 'mac_arm64' || 'mac_x64' }} |
| 81 | + modules: 'qtbase qtgui qtwidgets' |
| 82 | + cache: 'true' |
| 83 | + |
| 84 | + - name: Install Qt (Linux) |
| 85 | + if: runner.os == 'Linux' |
| 86 | + run: | |
| 87 | + sudo apt-get update |
| 88 | + sudo apt-get install -y qt6-base-dev qt6-base-dev-tools |
| 89 | +
|
| 90 | + - name: Install dependencies (Windows) |
| 91 | + if: runner.os == 'Windows' |
| 92 | + run: | |
| 93 | + choco install ninja cmake -y |
| 94 | +
|
| 95 | + - name: Install dependencies (macOS) |
| 96 | + if: runner.os == 'macOS' |
| 97 | + run: | |
| 98 | + brew install ninja cmake |
| 99 | +
|
| 100 | + - name: Install dependencies (Linux) |
| 101 | + if: runner.os == 'Linux' |
| 102 | + run: | |
| 103 | + sudo apt-get install -y ninja-build cmake build-essential |
| 104 | +
|
| 105 | + - name: Create build directory |
| 106 | + run: cmake -E make_directory ${{ github.workspace }}/build |
| 107 | + |
| 108 | + - name: Configure CMake (Windows) |
| 109 | + if: runner.os == 'Windows' |
| 110 | + shell: cmd |
| 111 | + run: | |
| 112 | + cd ${{ github.workspace }}/build |
| 113 | + cmake -G "${{ matrix.cmake_generator }}" ^ |
| 114 | + -A ${{ matrix.cmake_platform }} ^ |
| 115 | + -DCMAKE_BUILD_TYPE=Release ^ |
| 116 | + -DBUILD_EXAMPLES=ON ^ |
| 117 | + -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" ^ |
| 118 | + .. |
| 119 | +
|
| 120 | + - name: Configure CMake (non-Windows) |
| 121 | + if: runner.os != 'Windows' |
| 122 | + run: | |
| 123 | + cd ${{ github.workspace }}/build |
| 124 | + cmake -G "${{ matrix.cmake_generator }}" \ |
| 125 | + -DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \ |
| 126 | + -DBUILD_EXAMPLES=ON \ |
| 127 | + -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" \ |
| 128 | + .. |
| 129 | +
|
| 130 | + - name: Build |
| 131 | + run: cmake --build ${{ github.workspace }}/build --config Release --parallel |
| 132 | + |
| 133 | + - name: Install |
| 134 | + run: cmake --install ${{ github.workspace }}/build --config Release |
| 135 | + |
| 136 | + - name: Create package (Windows) |
| 137 | + if: runner.os == 'Windows' |
| 138 | + shell: cmd |
| 139 | + run: | |
| 140 | + cd ${{ github.workspace }}/build |
| 141 | + cpack -C Release -G NSIS |
| 142 | +
|
| 143 | + - name: Create package (macOS) |
| 144 | + if: runner.os == 'macOS' |
| 145 | + run: | |
| 146 | + cd ${{ github.workspace }}/build |
| 147 | + cpack -C Release -G DragNDrop |
| 148 | + cpack -C Release -G TGZ |
| 149 | +
|
| 150 | + - name: Create package (Linux) |
| 151 | + if: runner.os == 'Linux' |
| 152 | + run: | |
| 153 | + cd ${{ github.workspace }}/build |
| 154 | + cpack -C Release -G DEB |
| 155 | + cpack -C Release -G RPM |
| 156 | + cpack -C Release -G TGZ |
| 157 | +
|
| 158 | + - name: List artifacts |
| 159 | + run: Get-ChildItem ${{ github.workspace }}/build/ -Force | Format-List |
| 160 | + |
| 161 | + - name: Upload artifacts |
| 162 | + uses: actions/upload-artifact@v4 |
| 163 | + with: |
| 164 | + name: ${{ matrix.artifact_prefix }}-packages |
| 165 | + path: ${{ github.workspace }}/build/QTradingView-* |
| 166 | + retention-days: 30 |
| 167 | + |
| 168 | + - name: Generate checksums |
| 169 | +# if: startsWith(github.ref, 'refs/tags/') |
| 170 | + run: | |
| 171 | + cd ${{ github.workspace }}/build |
| 172 | + find . -maxdepth 1 -name "QTradingView-*" -type f -exec sh -c 'sha256sum "$1" > "$1.sha256"' _ {} \; |
| 173 | +
|
| 174 | + - name: G enerate checksums (Windows) |
| 175 | + if: runner.os == 'Windows' |
| 176 | + shell: pwsh |
| 177 | + run: | |
| 178 | + Get-ChildItem -File "QTradingView-*" | ForEach-Object { |
| 179 | + Get-FileHash $_.FullName -Algorithm SHA256 | |
| 180 | + ForEach-Object { $_.Hash | Out-File ($_.Path + ".sha256") -Encoding ascii } |
| 181 | + } |
| 182 | +
|
| 183 | + - name: Generate checksums (Linux/macOS) |
| 184 | + if: runner.os != 'Windows' |
| 185 | + run: | |
| 186 | + cd ${{ github.workspace }}/build |
| 187 | + find . -maxdepth 1 -name "QTradingView-*" -type f -exec sh -c 'sha256sum "$1" > "$1.sha256"' _ {} \; |
| 188 | + |
| 189 | +
|
| 190 | + - name: Upload checksums |
| 191 | +# if: startsWith(github.ref, 'refs/tags/') |
| 192 | + uses: actions/upload-artifact@v4 |
| 193 | + with: |
| 194 | + name: ${{ matrix.artifact_prefix }}-checksums |
| 195 | + path: ${{ github.workspace }}/build/*.sha256 |
| 196 | + retention-days: 30 |
| 197 | + |
| 198 | + release: |
| 199 | + needs: build |
| 200 | + runs-on: ubuntu-latest |
| 201 | +# if: startsWith(github.ref, 'refs/tags/') |
| 202 | + name: Create Release |
| 203 | + |
| 204 | + steps: |
| 205 | + - name: Checkout code |
| 206 | + uses: actions/checkout@v4 |
| 207 | + |
| 208 | + - name: Download all artifacts |
| 209 | + uses: actions/download-artifact@v4 |
| 210 | + with: |
| 211 | + path: artifacts |
| 212 | + |
| 213 | + - name: Create Release |
| 214 | + uses: softprops/action-gh-release@v1 |
| 215 | + with: |
| 216 | + draft: false |
| 217 | + prerelease: false |
| 218 | + generate_release_notes: true |
| 219 | + files: artifacts/**/* |
| 220 | + env: |
| 221 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 222 | + |
| 223 | + test: |
| 224 | + strategy: |
| 225 | + matrix: |
| 226 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 227 | + runs-on: ${{ matrix.os }} |
| 228 | + name: Test on ${{ matrix.os }} |
| 229 | + |
| 230 | + steps: |
| 231 | + - name: Checkout code |
| 232 | + uses: actions/checkout@v4 |
| 233 | + |
| 234 | + - name: Install Qt (Windows) |
| 235 | + if: runner.os == 'Windows' |
| 236 | + uses: jurplel/install-qt-action@v4 |
| 237 | + with: |
| 238 | + version: ${{ env.QT_VERSION }} |
| 239 | + modules: 'qtbase qtgui qtwidgets' |
| 240 | + |
| 241 | + - name: Install Qt (macOS) |
| 242 | + if: runner.os == 'macOS' |
| 243 | + uses: jurplel/install-qt-action@v4 |
| 244 | + with: |
| 245 | + version: ${{ env.QT_VERSION }} |
| 246 | + modules: 'qtbase qtgui qtwidgets' |
| 247 | + |
| 248 | + - name: Install Qt (Linux) |
| 249 | + if: runner.os == 'Linux' |
| 250 | + run: | |
| 251 | + sudo apt-get update |
| 252 | + sudo apt-get install -y qt6-base-dev |
| 253 | +
|
| 254 | + - name: Install dependencies |
| 255 | + if: runner.os != 'Windows' |
| 256 | + run: | |
| 257 | + if [ "$RUNNER_OS" == "macOS" ]; then |
| 258 | + brew install cmake ninja |
| 259 | + else |
| 260 | + sudo apt-get install -y cmake ninja-build |
| 261 | + fi |
| 262 | +
|
| 263 | + - name: Install dependencies (Windows) |
| 264 | + if: runner.os == 'Windows' |
| 265 | + run: | |
| 266 | + choco install cmake ninja nsis -y |
| 267 | +
|
| 268 | + - name: Configure and build |
| 269 | + run: | |
| 270 | + cmake -B build -DBUILD_EXAMPLES=ON |
| 271 | + cmake --build build |
| 272 | +
|
| 273 | + - name: Run tests |
| 274 | + run: | |
| 275 | + cd build |
| 276 | + ctest --output-on-failure || true |
0 commit comments