Skip to content

Merge pull request #59 from albertziegenhagel/pmc #279

Merge pull request #59 from albertziegenhagel/pmc

Merge pull request #59 from albertziegenhagel/pmc #279

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: write
deployments: write
jobs:
build:
name: ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.compiler }}
runs-on: ${{ matrix.run-on }}
strategy:
fail-fast: false
matrix:
run-on: [ubuntu-latest, windows-latest]
compiler: [any]
include:
- run-on: windows-latest
triplet: x64-windows-static-release
arch: x86_64
platform: windows
compiler: msvc
- run-on: ubuntu-latest
triplet: x64-linux-release
arch: x86_64
platform: linux
compiler: gcc
- run-on: ubuntu-latest
triplet: x64-linux-release
arch: x86_64
platform: linux
compiler: clang
exclude:
- compiler: any
env:
VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}
VCPKG_GIT_COMMIT_ID: "8eb57355a4ffb410a2e94c07b4dca2dffbee8e50"
steps:
- name: Install gcc-13
if: runner.os == 'Linux'
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gcc-13 g++-13
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60 --slave /usr/bin/g++ g++ /usr/bin/g++-13
- name: Install clang-17(dev)
if: runner.os == 'Linux' && matrix.compiler == 'clang'
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main'
sudo apt update
sudo apt install clang-17
echo "CC=clang-17" >> $GITHUB_ENV
echo "CXX=clang++-17" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
lfs: 'false'
- name: Create LFS file list
shell: pwsh
run: git lfs ls-files -l | ForEach-Object { $_.split(" ")[0] } | Sort-Object | Out-File .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v4
id: lfs-cache
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1
- name: Git LFS Pull
run: git lfs pull
- uses: lukka/get-cmake@latest
with:
cmakeVersion: "~3.25.0"
ninjaVersion: "^1.11.1"
- uses: TheMrMilchmann/setup-msvc-dev@v2
if: runner.os == 'Windows'
with:
arch: x64
- name: Setup vcpkg (windows)
if: runner.os == 'Windows'
run: |
cd "C:\"
if(Test-Path C:\vcpkg) { rm -r -Force "C:\vcpkg" }
git clone --depth 1 --branch "2023.10.19" https://github.com/microsoft/vcpkg.git
- name: Restore vcpkg-tool (windows)
if: runner.os == 'Windows'
id: restore-vcpkg-tool
uses: actions/cache/restore@v3
with:
path: C:\vcpkg\vcpkg.exe
key: windows-cache-vcpkg-tool
- name: Build vcpkg-tool (windows)
if: runner.os == 'Windows' && steps.restore-vcpkg-tool.outputs.cache-hit != 'true'
run: |
cd "C:\"
if(Test-Path C:\vcpkg-tool) { rm -r -Force "C:\vcpkg-tool" }
git clone --depth 1 --branch gha-upload-fixes https://github.com/albertziegenhagel/vcpkg-tool.git
cd "C:\vcpkg-tool"
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release
ninja
cp .\vcpkg.exe C:\vcpkg\
- name: Store vcpkg-tool (windows)
if: runner.os == 'Windows' && steps.restore-vcpkg-tool.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: C:\vcpkg\vcpkg.exe
key: ${{ steps.restore-vcpkg-tool.outputs.cache-primary-key }}
- name: Setup GHA cache
if: runner.os == 'Windows'
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Setup vcpkg (non-windows)
if: runner.os != 'Windows'
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: "${{ env.VCPKG_GIT_COMMIT_ID }}"
- name: Build & Test project (Windows)
if: runner.os == 'Windows'
run: |
cd '${{ github.workspace }}'
$env:VCPKG_BINARY_SOURCES="clear;x-gha,readwrite"
cmake --preset ci . -G Ninja -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake -DCMAKE_BUILD_TYPE=Release "-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}" "-DVCPKG_INSTALL_OPTIONS=--debug"
cmake --build --preset ci .
ctest --preset ci
- name: Build & Test project (default)
uses: lukka/run-cmake@v10
if: runner.os == 'Linux'
with:
configurePreset: "ci"
configurePresetAdditionalArgs: "['-DCMAKE_BUILD_TYPE=Release', '-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}', '-DVCPKG_VERBOSE=ON', '-DVCPKG_INSTALL_OPTIONS=--debug']"
buildPreset: "ci"
testPreset: "ci"
- name: Install
run: |
cmake --install ${{ github.workspace }}/build/ci --component server --prefix ${{ github.workspace }}/install/server
cmake --install ${{ github.workspace }}/build/ci --component tools --prefix ${{ github.workspace }}/install/tools
- name: Create build info
shell: pwsh
run: |
"ref: ${{ github.ref_name }}`n" + `
"commit: ${{ github.sha }}`n" + `
"date: $(Get-Date -UFormat '%FT%T%Z' -AsUTC)" | Out-File -Path "${{ github.workspace }}/install/info.txt"
cp ${{ github.workspace }}/install/info.txt ${{ github.workspace }}/install/server/bin/
cp ${{ github.workspace }}/install/info.txt ${{ github.workspace }}/install/tools/bin/
- name: Upload server binaries
uses: actions/upload-artifact@v4
if: runner.os != 'Linux' || matrix.compiler == 'gcc'
with:
name: snail-server-${{ matrix.arch }}-${{ matrix.platform }}
path: |
${{ github.workspace }}/install/server/bin/snail-server*
${{ github.workspace }}/install/server/bin/info.txt
- name: Upload tool binaries
uses: actions/upload-artifact@v4
if: runner.os != 'Linux' || matrix.compiler == 'gcc'
with:
name: snail-tools-${{ matrix.arch }}-${{ matrix.platform }}
path: |
${{ github.workspace }}/install/tools/bin/app_*
${{ github.workspace }}/install/tools/bin/info.txt
deploy-head:
name: "Deploy head"
needs: build
if: github.ref == 'refs/heads/main'
uses: ./.github/workflows/deploy-head.yml