From bcce7d90e26f215f3f3cca5f1dc9e6ad38298983 Mon Sep 17 00:00:00 2001 From: GeffDev Date: Sat, 24 Feb 2024 08:52:21 +0800 Subject: [PATCH] add CI building pipeline --- .github/workflows/build.yml | 71 +++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 1 - 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..a0c4737 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,71 @@ +name: pennyunpacker + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + + matrix: + os: [ubuntu-latest, windows-latest] + build_type: [Release] + c_compiler: [clang, cl] + include: + - os: windows-latest + c_compiler: cl + cpp_compiler: cl + - os: ubuntu-latest + c_compiler: clang + cpp_compiler: clang++ + exclude: + - os: windows-latest + c_compiler: gcc + - os: windows-latest + c_compiler: clang + - os: ubuntu-latest + c_compiler: cl + + steps: + - uses: actions/checkout@v3 + + - name: Set reusable strings + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + + - name: Configure CMake + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -S ${{ github.workspace }} + + - name: Build + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + + - name: Test + working-directory: ${{ steps.strings.outputs.build-output-dir }} + run: ctest --build-config ${{ matrix.build_type }} + + - name: Upload win artifact + if: matrix.os == 'windows-latest' + uses: actions/upload-artifact@v4 + with: + name: pennyunpacker-windows + path: build/pennyunpacker.exe + + - name: Upload linux artifact + if: matrix.os == 'ubuntu-latest' + uses: actions/upload-artifact@v4 + with: + name: pennyunpacker-linux + path: build/pennyunpacker \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index b6297e0..de72c02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,6 @@ project(pennyunpacker VERSION 1.0 LANGUAGES C) #set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") set(CMAKE_C_STANDARD 17) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter") if (WIN32) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall")