Skip to content

Commit

Permalink
add ci workflow : build
Browse files Browse the repository at this point in the history
  • Loading branch information
omegacoleman committed Jun 13, 2021
1 parent f6755b0 commit ee7ff66
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: build

on:
push:
branches: [ devel ]
pull_request:
branches: [ devel ]

jobs:
build-linux-x64:
runs-on: ubuntu-latest

strategy:
matrix:
build_type: [ Debug, Release ]

env:
BUILD_TYPE: ${{ matrix.build_type }}

steps:
- name: checkout
uses: actions/checkout@v2

- name: build
run: ./ci/build-ubuntu.sh

- name: upload_artifact
uses: actions/[email protected]
with:
path: ./output/*

build-windows-x64:
runs-on: windows-2019

strategy:
matrix:
build_type: [ Debug, Release ]

env:
BUILD_TYPE: ${{ matrix.build_type }}

steps:
- name: checkout
uses: actions/checkout@v2

- name: build
env:
GITHUB_SHA: ${{ github.sha }}
run: ci/build-win.bat

- name: upload_artifact
uses: actions/[email protected]
with:
path: ./output/*

build-darwin-x64:
runs-on: macos-latest

strategy:
matrix:
build_type: [ Debug, Release ]

env:
BUILD_TYPE: ${{ matrix.build_type }}

steps:
- name: checkout
uses: actions/checkout@v2

- name: build
run: ./ci/build-darwin.sh

- name: upload_artifact
uses: actions/[email protected]
with:
path: ./output/*
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/build
/install
/output
/vendor
compile_commands.json

3 changes: 3 additions & 0 deletions ci/brew-llvm.toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(CMAKE_C_COMPILER /usr/local/opt/llvm/bin/clang)
set(CMAKE_CXX_COMPILER /usr/local/opt/llvm/bin/clang++)

16 changes: 16 additions & 0 deletions ci/build-darwin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# use homebrew toolchain
brew update
brew install llvm

# build & install the project
mkdir -p build install
cmake -B ./build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=./install -DCMAKE_TOOLCHAIN_FILE=$(pwd)/ci/brew-llvm.toolchain.cmake
cmake --build ./build --config $BUILD_TYPE
cmake --install ./build --config $BUILD_TYPE

# package the binary
mkdir -p output
tar -C ./install/bin -czvf ./output/zrp-darwin-$BUILD_TYPE-$(git rev-parse --short HEAD).tar.gz zclient zserver

20 changes: 20 additions & 0 deletions ci/build-ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# setup cmake & g++-11
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get install -y build-essential software-properties-common git
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get install -y g++-11 cmake
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11

# build & install the project
mkdir -p build install
cmake -B ./build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=./install -DCMAKE_TOOLCHAIN_FILE=$(pwd)/ci/gcc-static.toolchain.cmake
cmake --build ./build --config $BUILD_TYPE
cmake --install ./build --config $BUILD_TYPE

# package the binary
mkdir -p output
tar -C ./install/bin -czvf ./output/zrp-linux-$BUILD_TYPE-$(git rev-parse --short HEAD).tar.gz zclient zserver

6 changes: 6 additions & 0 deletions ci/build-win.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mkdir build install output
cmake -B build -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DCMAKE_INSTALL_PREFIX=install
cmake --build build --config %BUILD_TYPE%
cmake --install build --config %BUILD_TYPE%
7z a -tzip output\zrp-windows-%BUILD_TYPE%-%GITHUB_SHA:~0,7%.zip .\install\bin\*

5 changes: 5 additions & 0 deletions ci/gcc-static.toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")

0 comments on commit ee7ff66

Please sign in to comment.