CMake Linux Build #107
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage. | |
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml | |
name: CMake Linux Build | |
on: | |
# push: | |
# branches: [ "main" ] | |
# pull_request: | |
# branches: [ "main" ] | |
workflow_dispatch: | |
env: | |
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | |
BUILD_TYPE: Release | |
jobs: | |
build: | |
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. | |
# You can convert this to a matrix build if you need cross-platform coverage. | |
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Download and Install CMake | |
run: | | |
curl -LO https://github.com/Kitware/CMake/releases/download/v3.21.3/cmake-3.21.3-linux-x86_64.tar.gz | |
tar -xzvf cmake-3.21.3-linux-x86_64.tar.gz | |
sudo mv cmake-3.21.3-linux-x86_64 /usr/local/cmake | |
echo 'export PATH="/usr/local/cmake/bin:$PATH"' >> ~/.bashrc | |
source ~/.bashrc | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libcurl4-openssl-dev libprotobuf-dev protobuf-compiler libmysqlclient-dev # 安装依赖 | |
sudo apt-get install uuid-dev | |
- name: Install GCC 13 | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y software-properties-common | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y | |
sudo apt-get update | |
sudo apt-get install -y gcc-13 g++-13 | |
- name: Set GCC 13 as default compiler | |
run: | | |
echo "CC=gcc-13" >> $GITHUB_ENV | |
echo "CXX=g++-13" >> $GITHUB_ENV | |
- name: Verify GCC version | |
run: | | |
gcc --version | |
$CC --version | |
$CXX --version | |
- name: Install Boost.Interprocess | |
run: | | |
sudo apt update | |
sudo apt install libboost-all-dev | |
dpkg-query -L libboost-all-dev | |
- name: Install MySQL Connector/C | |
run: sudo apt-get update && sudo apt-get install -y libmysqlclient-dev && dpkg-query -L libmysqlclient-dev | |
- name: Download and build hiredis | |
run: | | |
git clone https://github.com/redis/hiredis.git | |
cd hiredis | |
make | |
sudo make install | |
- name: Remove any existing protobuf installation | |
run: | | |
sudo apt-get remove -y protobuf-compiler | |
# 下载并安装 Protobuf 3.13 | |
- name: Download protobuf 3.13 | |
run: | | |
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/protobuf-all-3.13.0.tar.gz | |
tar -xvzf protobuf-all-3.13.0.tar.gz | |
cd protobuf-3.13.0 | |
./configure | |
make | |
sudo make install | |
sudo ldconfig | |
- name: Verify Protobuf Installation | |
run: | | |
protoc --version | |
ldconfig -p | grep protobuf | |
- name: Download and build curl | |
run: | | |
sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev && dpkg-query -L libcurl4-openssl-dev | |
- name: Configure CMake | |
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. | |
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | |
run: | | |
mkdir build | |
cd build | |
cmake .. | |
make | |