|
| 1 | +name: Nekoray build matrix - cmake |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + tag: |
| 7 | + description: "Release Tag" |
| 8 | + required: true |
| 9 | + publish: |
| 10 | + description: "Publish: If want ignore" |
| 11 | + required: false |
| 12 | + artifact-pack: |
| 13 | + description: "artifact-pack: If want ignore" |
| 14 | + required: false |
| 15 | +jobs: |
| 16 | + build-go: |
| 17 | + permissions: |
| 18 | + contents: read |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + - cross_os: public_res |
| 23 | + cross_arch: public_res |
| 24 | + go_version: "1.24.3" |
| 25 | + - cross_os: windows |
| 26 | + cross_arch: amd64 |
| 27 | + go_version: "1.24.3" |
| 28 | + - cross_os: linux |
| 29 | + cross_arch: amd64 |
| 30 | + go_version: "1.24.3" |
| 31 | + - cross_os: darwin |
| 32 | + cross_arch: amd64 |
| 33 | + go_version: "1.24.3" |
| 34 | + - cross_os: darwin |
| 35 | + cross_arch: arm64 |
| 36 | + go_version: "1.24.3" |
| 37 | + fail-fast: false |
| 38 | + runs-on: ubuntu-latest |
| 39 | + steps: |
| 40 | + - name: Checking out sources |
| 41 | + uses: actions/checkout@v4.2.2 |
| 42 | + - name: Cache Common Download |
| 43 | + id: cache-common |
| 44 | + uses: actions/cache@v4.2.0 |
| 45 | + with: |
| 46 | + path: artifacts.tgz |
| 47 | + key: CommonCache-${{ matrix.cross_os }}-${{ matrix.cross_arch }}-${{ hashFiles('script/build_go.sh', 'core/*') }}-${{ matrix.go_version }} |
| 48 | + - name: Install Golang |
| 49 | + if: steps.cache-common.outputs.cache-hit != 'true' |
| 50 | + uses: actions/setup-go@v5.2.0 |
| 51 | + with: |
| 52 | + go-version: ${{ matrix.go_version }} |
| 53 | + cache-dependency-path: | |
| 54 | + core/server/go.sum |
| 55 | + core/updater/go.sum |
| 56 | + - name: Build golang parts |
| 57 | + if: steps.cache-common.outputs.cache-hit != 'true' |
| 58 | + shell: bash |
| 59 | + run: | |
| 60 | + [ ${{ matrix.cross_os }} == public_res ] || GOOS=${{ matrix.cross_os }} GOARCH=${{ matrix.cross_arch }} ./script/build_go.sh |
| 61 | + [ ${{ matrix.cross_os }} == public_res ] || exit 0 |
| 62 | + ./script/build_public_res.sh |
| 63 | + - name: Tar files |
| 64 | + if: steps.cache-common.outputs.cache-hit != 'true' |
| 65 | + run: tar czvf artifacts.tgz ./deployment |
| 66 | + - name: Uploading Artifact |
| 67 | + uses: actions/upload-artifact@v4.6.0 |
| 68 | + with: |
| 69 | + name: NekoRay-${{ github.sha }}-Common-${{ matrix.cross_os }}-${{ matrix.cross_arch }} |
| 70 | + path: artifacts.tgz |
| 71 | + build-cpp: |
| 72 | + permissions: |
| 73 | + contents: read |
| 74 | + needs: |
| 75 | + - build-go |
| 76 | + strategy: |
| 77 | + matrix: |
| 78 | + include: |
| 79 | + - platform: windows-latest |
| 80 | + qt_version: "6.9.0" |
| 81 | + target: amd64 |
| 82 | + - platform: ubuntu-22.04 |
| 83 | + qt_version: "6.9.0" |
| 84 | + target: amd64 |
| 85 | + - platform: macos-latest |
| 86 | + qt_version: "6.9.0" |
| 87 | + target: x86_64 |
| 88 | + - platform: macos-latest |
| 89 | + qt_version: "6.9.0" |
| 90 | + target: arm64 |
| 91 | + fail-fast: false |
| 92 | + runs-on: ${{ matrix.platform }} |
| 93 | + env: |
| 94 | + ACTIONS_ALLOW_UNSECURE_COMMANDS: true |
| 95 | + steps: |
| 96 | + - name: Checking out sources |
| 97 | + uses: actions/checkout@v4.2.2 |
| 98 | + with: |
| 99 | + submodules: "recursive" |
| 100 | + - name: Install mingw |
| 101 | + if: matrix.platform == 'windows-latest' |
| 102 | + uses: bwoodsend/setup-winlibs-action@v1.15 |
| 103 | + - name: Install ninja-build tool |
| 104 | + uses: seanmiddleditch/gha-setup-ninja@v5 |
| 105 | + |
| 106 | + - name: Download Artifacts |
| 107 | + uses: actions/download-artifact@v4.1.8 |
| 108 | + with: |
| 109 | + path: download-artifact |
| 110 | + # ========================================================================================================= Qt Install |
| 111 | + - name: Qt static Cache |
| 112 | + id: cache-static-Qt |
| 113 | + if: matrix.platform == 'windows-latest' |
| 114 | + uses: actions/cache@v4.2.0 |
| 115 | + with: |
| 116 | + path: qt6/build |
| 117 | + key: QtStaticCache-${{ matrix.platform }}-${{ matrix.target }}-Qt${{ matrix.qt_version }} |
| 118 | + - name: Install Qt Windows |
| 119 | + shell: powershell |
| 120 | + if: matrix.platform == 'windows-latest' && steps.cache-static-Qt.outputs.cache-hit != 'true' |
| 121 | + run: ./script/build_qt_static_windows.bat ${{ matrix.qt_version }} |
| 122 | + - name: Install Qt |
| 123 | + uses: jurplel/install-qt-action@v4.1.1 |
| 124 | + if: matrix.platform != 'windows-latest' |
| 125 | + with: |
| 126 | + version: ${{ matrix.qt_version }} |
| 127 | + setup-python: true |
| 128 | + cache: true |
| 129 | + cache-key-prefix: QtCache-${{ matrix.platform }}-${{ matrix.target }} |
| 130 | + # ========================================================================================================= Build deps |
| 131 | + - name: Cache Download |
| 132 | + id: cache-deps |
| 133 | + uses: actions/cache@v4.2.0 |
| 134 | + with: |
| 135 | + path: libs/deps |
| 136 | + key: DepsCache-${{ matrix.platform }}-${{ matrix.target }}-${{ hashFiles('script/build_deps_*.sh') }}-Qt${{ matrix.qt_version }} |
| 137 | + - name: Build Dependencies |
| 138 | + shell: bash |
| 139 | + if: steps.cache-deps.outputs.cache-hit != 'true' |
| 140 | + run: ./script/build_deps_all.sh ${{ matrix.target }} |
| 141 | + # ========================================================================================================= Generate MakeFile and Build |
| 142 | + - name: Windows - Generate MakeFile and Build |
| 143 | + shell: bash |
| 144 | + if: matrix.platform == 'windows-latest' |
| 145 | + env: |
| 146 | + CC: gcc.exe |
| 147 | + CXX: g++.exe |
| 148 | + run: | |
| 149 | + export CMAKE_PREFIX_PATH=$PWD/qt6/build/lib/cmake |
| 150 | + mkdir build |
| 151 | + cd build |
| 152 | + cmake -GNinja -DQT_VERSION_MAJOR=6 -DCMAKE_CXX_FLAGS="-static -DNDEBUG -s" .. |
| 153 | + ninja -j2 |
| 154 | + cd .. |
| 155 | + ./script/deploy_windows64.sh |
| 156 | + - name: Linux - Generate MakeFile and Build |
| 157 | + shell: bash |
| 158 | + if: matrix.platform == 'ubuntu-22.04' |
| 159 | + run: | |
| 160 | + sudo apt update && sudo apt upgrade -y |
| 161 | + mkdir build |
| 162 | + cd build |
| 163 | + cmake -GNinja -DQT_VERSION_MAJOR=6 -DCMAKE_BUILD_TYPE=Release .. |
| 164 | + ninja |
| 165 | + cd .. |
| 166 | + ./script/deploy_linux64.sh |
| 167 | + - name: macOS - Generate MakeFile and Build |
| 168 | + shell: bash |
| 169 | + if: matrix.platform == 'macos-latest' |
| 170 | + run: | |
| 171 | + mkdir build |
| 172 | + cd build |
| 173 | + cmake -GNinja -DQT_VERSION_MAJOR=6 -DCMAKE_BUILD_TYPE=Release -DNKR_PACKAGE_MACOS=1 -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_OSX_ARCHITECTURES=${{ matrix.target }} .. |
| 174 | + ninja |
| 175 | + cd .. |
| 176 | + ./script/deploy_macos.sh ${{ matrix.target }} |
| 177 | + # ========================================================================================================= Deployments |
| 178 | + - name: Tar files |
| 179 | + shell: bash |
| 180 | + run: tar czvf artifacts.tgz ./deployment |
| 181 | + - name: Uploading Artifact |
| 182 | + uses: actions/upload-artifact@v4.6.0 |
| 183 | + with: |
| 184 | + name: NekoRay-${{ github.sha }}-${{ matrix.platform }}-${{ matrix.target }}-Qt${{ matrix.qt_version }} |
| 185 | + path: artifacts.tgz |
| 186 | + publish: |
| 187 | + name: Pack & Publish Release |
| 188 | + if: github.event.inputs.artifact-pack != 'y' |
| 189 | + runs-on: ubuntu-latest |
| 190 | + needs: |
| 191 | + - build-cpp |
| 192 | + permissions: |
| 193 | + contents: write |
| 194 | + actions: read |
| 195 | + steps: |
| 196 | + - name: Checking out sources |
| 197 | + uses: actions/checkout@v4.2.2 |
| 198 | + - name: Download Artifacts |
| 199 | + uses: actions/download-artifact@v4.1.8 |
| 200 | + with: |
| 201 | + path: download-artifact |
| 202 | + - name: Pack |
| 203 | + run: | |
| 204 | + curl -Lo - https://github.com/tcnksm/ghr/releases/download/v0.16.2/ghr_v0.16.2_linux_amd64.tar.gz | tar xzv |
| 205 | + mv ghr*linux_amd64/ghr . |
| 206 | + source script/env_deploy.sh |
| 207 | + find . -name artifacts.tgz | xargs -n1 tar xvzf |
| 208 | + cd deployment |
| 209 | + rm -rf *.pdb |
| 210 | + #### |
| 211 | + bash ../script/pack_debian.sh ${{ github.event.inputs.tag }} |
| 212 | + mv nekoray.deb $version_standalone-debian-x64.deb |
| 213 | + rm -rf nekoray |
| 214 | + #### |
| 215 | + mv linux64 nekoray |
| 216 | + zip -9 -r $version_standalone-linux64.zip nekoray |
| 217 | + rm -rf nekoray |
| 218 | + #### |
| 219 | + mv windows64 nekoray |
| 220 | + zip -9 -r $version_standalone-windows64.zip nekoray |
| 221 | + rm -rf nekoray |
| 222 | + #### |
| 223 | + mkdir Nekoray |
| 224 | + mv macos-arm64/nekoray.app Nekoray/nekoray.app |
| 225 | + zip -9 --symlinks -r $version_standalone-macos-arm64.zip Nekoray |
| 226 | + rm -rf macos-arm64 |
| 227 | + rm -rf Nekoray |
| 228 | + #### |
| 229 | + mkdir Nekoray |
| 230 | + mv macos-amd64/nekoray.app Nekoray/nekoray.app |
| 231 | + zip -9 --symlinks -r $version_standalone-macos-amd64.zip Nekoray |
| 232 | + rm -rf macos-amd64 |
| 233 | + rm -rf Nekoray |
| 234 | + - name: Clean Up |
| 235 | + run: | |
| 236 | + cd deployment |
| 237 | + rm -rf windows-arm64 |
| 238 | + rm -rf linux-arm64 |
| 239 | + rm -rf linux64 |
| 240 | + rm -rf windows64 |
| 241 | + rm -rf macos-amd64 |
| 242 | + rm -rf macos-arm64 |
| 243 | + rm -rf public_res |
| 244 | + rm -rf *.pdb |
| 245 | + - name: Uploading Artifact |
| 246 | + uses: actions/upload-artifact@v4.6.0 |
| 247 | + with: |
| 248 | + name: Deployment-${{ github.sha }} |
| 249 | + path: deployment |
| 250 | + - name: PreRelease |
| 251 | + if: github.event.inputs.publish == 'p' |
| 252 | + run: | |
| 253 | + ./ghr -prerelease -delete -t "${{ github.token }}" -n "${{ github.event.inputs.tag }}" "${{ github.event.inputs.tag }}" deployment |
| 254 | + - name: Release |
| 255 | + if: github.event.inputs.publish == '' |
| 256 | + run: | |
| 257 | + ./ghr -delete -t "${{ github.token }}" -n "${{ github.event.inputs.tag }}" "${{ github.event.inputs.tag }}" deployment |
0 commit comments