diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..fa3699b --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,59 @@ +name: CI Builds + +on: + # execute on every PR made targeting the branches bellow + pull_request: + branches: + - main + + # execute on every push + push: + + # execute on trigger + repository_dispatch: + types: [examples-build] + +jobs: + build-osmp-examples: + name: Build OSMP Examples + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Get CMake + uses: lukka/get-cmake@latest + + - name: Cache vcpkg + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/vcpkg_cache + key: vcpkg-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json', 'CMakePresets.json') }} + + - name: Setup vcpkg + uses: lukka/run-vcpkg@v11 + with: + vcpkgJsonGlob: '**/examples/vcpkg.json' + vcpkgConfigurationJsonGlob: '**/examples/vcpkg-configuration.json' + + - name: Build examples + uses: lukka/run-cmake@v10 + env: + VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/vcpkg_cache,readwrite + with: + cmakeListsTxtPath: "${{ github.workspace }}/examples/CMakeLists.txt" + configurePreset: vcpkg + buildPreset: vcpkg + buildPresetAdditionalArgs: "['--config Release']" + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: Examples-${{ runner.os }} + path: examples/build/**/*.fmu diff --git a/.github/workflows/protobuf.yml b/.github/workflows/protobuf.yml deleted file mode 100644 index bad79f5..0000000 --- a/.github/workflows/protobuf.yml +++ /dev/null @@ -1,108 +0,0 @@ -name: ProtoBuf CI Builds - -env: - PROTOBUF_VERSION: 3.20.1 - PROTOBUF_VARIANT: '-all' # Use '-all' prior to 22.0, '' after - ABSEIL_VERSION: 20230802.1 - -on: - push: - branches: - - '**' - paths-ignore: [ .github/**, .gitmodules ] - tags-ignore: - - '**' - pull_request: - branches: [ master ] - repository_dispatch: - types: [examples-build] - -# this is a test - -jobs: - build-osmp-examples: - name: Build OSMP examples - - runs-on: ubuntu-22.04 - - steps: - - name: Checkout OSI - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.8' - - - name: Cache Dependencies - id: cache-depends - uses: actions/cache@v4 - with: - path: protobuf-${{ env.PROTOBUF_VERSION }} - key: ${{ runner.os }}-v2-depends - - - name: Download ProtoBuf ${{ env.PROTOBUF_VERSION }} - if: steps.cache-depends.outputs.cache-hit != 'true' - run: curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v${{env.PROTOBUF_VERSION}}/protobuf${{env.PROTOBUF_VARIANT}}-${{env.PROTOBUF_VERSION}}.tar.gz && tar xzvf protobuf${{env.PROTOBUF_VARIANT}}-${{env.PROTOBUF_VERSION}}.tar.gz - - - name: Download Abseil ${{ env.ABSEIL_VERSION }} - if: steps.cache-depends.outputs.cache-hit != 'true' && env.PROTOBUF_VARIANT == '' - run: curl -OL https://github.com/abseil/abseil-cpp/archive/refs/tags/${{env.ABSEIL_VERSION}}.tar.gz && tar xzvf ${{env.ABSEIL_VERSION}}.tar.gz && rm -rf protobuf-${{env.PROTOBUF_VERSION}}/third_party/abseil-cpp && mv abseil-cpp-${{env.ABSEIL_VERSION}} protobuf-${{env.PROTOBUF_VERSION}}/third_party/abseil-cpp - - - name: Build ProtoBuf ${{ env.PROTOBUF_VERSION }} via autotools - if: steps.cache-depends.outputs.cache-hit != 'true' && env.PROTOBUF_VARIANT == '-all' - working-directory: protobuf-${{ env.PROTOBUF_VERSION }} - run: ./configure DIST_LANG=cpp --prefix=/usr && make - - - name: Build ProtoBuf ${{ env.PROTOBUF_VERSION }} via cmake - if: steps.cache-depends.outputs.cache-hit != 'true' && env.PROTOBUF_VARIANT == '' - working-directory: protobuf-${{ env.PROTOBUF_VERSION }} - run: cmake -DCMAKE_CXX_STANDARD=17 -Dprotobuf_BUILD_SHARED_LIBS=ON -Dprotobuf_BUILD_TESTS=OFF . && cmake --build . --config Release -j 4 - - - name: Install ProtoBuf ${{ env.PROTOBUF_VERSION }} - working-directory: protobuf-${{ env.PROTOBUF_VERSION }} - run: sudo make install && sudo ldconfig - - - name: Prepare C++ Build - working-directory: examples - run: mkdir build - - - name: Configure C++ Build - working-directory: examples/build - run: cmake ${{ env.PROTOBUF_VARIANT =='' && '-DCMAKE_CXX_STANDARD=17' }} .. - - - name: Build C++ - working-directory: examples/build - run: cmake --build . --config Release -j 4 - - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: Examples - path: examples/build - - update_interface_release: - name: Update OSI release - runs-on: ubuntu-22.04 - needs: [build-osmp-examples] - if: ${{ github.event.client_payload }} - steps: - - name: Collect previous artifacts - uses: actions/download-artifact@v4 - with: - name: Examples - path: examples/build - - name: Zip artifacts - uses: TheDoctor0/zip-release@0.7.6 - with: - filename: Examples.zip - path: examples/build - - name: Upload artifacts to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.MACHINE_USER_PAT }} - file: Examples.zip - tag: ${{ github.event.client_payload.tag }} - repo_name: ${{ github.event.client_payload.source_repo }} diff --git a/examples/CMakePresets.json b/examples/CMakePresets.json index cc69dea..2a5e479 100644 --- a/examples/CMakePresets.json +++ b/examples/CMakePresets.json @@ -15,5 +15,15 @@ "VCPKG_TARGET_TRIPLET": "x64-windows-static-md" } } + ], + "buildPresets": [ + { + "name": "vcpkg", + "configurePreset": "vcpkg" + }, + { + "name": "vcpkg-windows", + "configurePreset": "vcpkg-windows" + } ] }