nekoray_Mahdi-zarei/.github/workflows/build.yml
2025-07-07 17:17:16 +03:30

266 lines
9.4 KiB
YAML

name: Nekoray build matrix - cmake
on:
workflow_dispatch:
inputs:
tag:
description: "Release Tag"
required: true
publish:
description: "Publish: If want ignore"
required: false
artifact-pack:
description: "artifact-pack: If want ignore"
required: false
jobs:
build-go:
permissions:
contents: read
strategy:
matrix:
include:
- cross_os: public_res
cross_arch: public_res
go_version: "1.24.4"
- cross_os: windows
cross_arch: amd64
go_version: "1.24.4"
- cross_os: linux
cross_arch: amd64
go_version: "1.24.4"
- cross_os: darwin
cross_arch: amd64
go_version: "1.24.4"
- cross_os: darwin
cross_arch: arm64
go_version: "1.24.4"
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Checking out sources
uses: actions/checkout@v4.2.2
- name: Cache Common Download
id: cache-common
uses: actions/cache@v4.2.3
with:
path: artifacts.tgz
key: CommonCache-${{ matrix.cross_os }}-${{ matrix.cross_arch }}-${{ hashFiles('script/build_go.sh', 'core/*') }}-${{ matrix.go_version }}
- name: Install Golang
if: steps.cache-common.outputs.cache-hit != 'true'
uses: actions/setup-go@v5.5.0
with:
go-version: ${{ matrix.go_version }}
cache-dependency-path: |
core/server/go.sum
core/updater/go.sum
- name: Build golang parts
if: steps.cache-common.outputs.cache-hit != 'true'
shell: bash
run: |
[ ${{ matrix.cross_os }} == public_res ] || GOOS=${{ matrix.cross_os }} GOARCH=${{ matrix.cross_arch }} ./script/build_go.sh
[ ${{ matrix.cross_os }} == public_res ] || exit 0
./script/build_public_res.sh
- name: Tar files
if: steps.cache-common.outputs.cache-hit != 'true'
run: tar czvf artifacts.tgz ./deployment
- name: Uploading Artifact
uses: actions/upload-artifact@v4.6.2
with:
name: NekoRay-${{ github.sha }}-Common-${{ matrix.cross_os }}-${{ matrix.cross_arch }}
path: artifacts.tgz
build-cpp:
permissions:
contents: read
needs:
- build-go
strategy:
matrix:
include:
- platform: windows-latest
qt_version: "6.9.1"
target: amd64
- platform: ubuntu-22.04
qt_version: "6.9.1"
target: amd64
- platform: macos-latest
qt_version: "6.9.1"
target: x86_64
- platform: macos-latest
qt_version: "6.9.1"
target: arm64
fail-fast: false
runs-on: ${{ matrix.platform }}
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
steps:
- name: Checking out sources
uses: actions/checkout@v4.2.2
with:
submodules: "recursive"
- name: Install mingw
if: matrix.platform == 'windows-latest'
uses: bwoodsend/setup-winlibs-action@v1.15
- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@v6
- name: Download Artifacts
uses: actions/download-artifact@v4.3.0
with:
path: download-artifact
# ========================================================================================================= Qt Install
- name: Qt static Cache
id: cache-static-Qt
if: matrix.platform == 'windows-latest'
uses: actions/cache@v4.2.3
with:
path: qt6/build
key: QtStaticCache-${{ matrix.platform }}-${{ matrix.target }}-Qt${{ matrix.qt_version }}
- name: Install Qt Windows
shell: powershell
if: matrix.platform == 'windows-latest' && steps.cache-static-Qt.outputs.cache-hit != 'true'
run: ./script/build_qt_static_windows.bat ${{ matrix.qt_version }}
- name: Install Qt
uses: jurplel/install-qt-action@v4.3.0
if: matrix.platform != 'windows-latest'
with:
version: ${{ matrix.qt_version }}
setup-python: true
cache: true
cache-key-prefix: QtCache-${{ matrix.platform }}-${{ matrix.target }}
# ========================================================================================================= Build deps
- name: Cache Download
id: cache-deps
uses: actions/cache@v4.2.3
with:
path: libs/deps
key: DepsCache-${{ matrix.platform }}-${{ matrix.target }}-${{ hashFiles('script/build_deps_*.sh') }}-Qt${{ matrix.qt_version }}
- name: Build Dependencies
shell: bash
if: steps.cache-deps.outputs.cache-hit != 'true'
run: ./script/build_deps_all.sh ${{ matrix.target }}
# ========================================================================================================= Generate MakeFile and Build
- name: Windows - Generate MakeFile and Build
shell: bash
if: matrix.platform == 'windows-latest'
env:
CC: gcc.exe
CXX: g++.exe
run: |
export CMAKE_PREFIX_PATH=$PWD/qt6/build/lib/cmake
mkdir build
cd build
cmake -GNinja -DQT_VERSION_MAJOR=6 -DCMAKE_CXX_FLAGS="-static -DNDEBUG -s" ..
ninja -j2
cd ..
./script/deploy_windows64.sh
- name: Build Installer with NSIS
shell: cmd
if: matrix.platform == 'windows-latest'
run: |
cp .\script\windows_installer.nsi .
makensis windows_installer.nsi
cp NekoraySetup.exe deployment/
- name: Linux - Generate MakeFile and Build
shell: bash
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt update && sudo apt upgrade -y
mkdir build
cd build
cmake -GNinja -DQT_VERSION_MAJOR=6 -DCMAKE_BUILD_TYPE=Release ..
ninja
cd ..
./script/deploy_linux64.sh
- name: macOS - Generate MakeFile and Build
shell: bash
if: matrix.platform == 'macos-latest'
run: |
mkdir build
cd build
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 }} ..
ninja
cd ..
./script/deploy_macos.sh ${{ matrix.target }}
# ========================================================================================================= Deployments
- name: Tar files
shell: bash
run: tar czvf artifacts.tgz ./deployment
- name: Uploading Artifact
uses: actions/upload-artifact@v4.6.2
with:
name: NekoRay-${{ github.sha }}-${{ matrix.platform }}-${{ matrix.target }}-Qt${{ matrix.qt_version }}
path: artifacts.tgz
publish:
name: Pack & Publish Release
if: github.event.inputs.artifact-pack != 'y'
runs-on: ubuntu-latest
needs:
- build-cpp
permissions:
contents: write
actions: read
steps:
- name: Checking out sources
uses: actions/checkout@v4.2.2
- name: Download Artifacts
uses: actions/download-artifact@v4.3.0
with:
path: download-artifact
- name: Pack
run: |
curl -Lo - https://github.com/tcnksm/ghr/releases/download/v0.16.2/ghr_v0.16.2_linux_amd64.tar.gz | tar xzv
mv ghr*linux_amd64/ghr .
source script/env_deploy.sh
find . -name artifacts.tgz | xargs -n1 tar xvzf
cd deployment
rm -rf *.pdb
####
bash ../script/pack_debian.sh ${{ github.event.inputs.tag }}
mv nekoray.deb $version_standalone-debian-x64.deb
rm -rf nekoray
####
mv linux64 nekoray
zip -9 -r $version_standalone-linux64.zip nekoray
rm -rf nekoray
####
mv NekoraySetup.exe $version_standalone-windows64-installer.exe
mv windows64 nekoray
zip -9 -r $version_standalone-windows64.zip nekoray
rm -rf nekoray
####
mkdir Nekoray
mv macos-arm64/nekoray.app Nekoray/nekoray.app
zip -9 --symlinks -r $version_standalone-macos-arm64.zip Nekoray
rm -rf macos-arm64
rm -rf Nekoray
####
mkdir Nekoray
mv macos-amd64/nekoray.app Nekoray/nekoray.app
zip -9 --symlinks -r $version_standalone-macos-amd64.zip Nekoray
rm -rf macos-amd64
rm -rf Nekoray
- name: Clean Up
run: |
cd deployment
rm -rf windows-arm64
rm -rf linux-arm64
rm -rf linux64
rm -rf windows64
rm -rf macos-amd64
rm -rf macos-arm64
rm -rf public_res
rm -rf *.pdb
- name: Uploading Artifact
uses: actions/upload-artifact@v4.6.2
with:
name: Deployment-${{ github.sha }}
path: deployment
- name: PreRelease
if: github.event.inputs.publish == 'p'
run: |
./ghr -prerelease -delete -t "${{ github.token }}" -n "${{ github.event.inputs.tag }}" "${{ github.event.inputs.tag }}" deployment
- name: Release
if: github.event.inputs.publish == ''
run: |
./ghr -delete -t "${{ github.token }}" -n "${{ github.event.inputs.tag }}" "${{ github.event.inputs.tag }}" deployment