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