From 64bec43ca3ab4895a4fb04f3dcf412127b1af246 Mon Sep 17 00:00:00 2001 From: kamchatka-volcano Date: Sat, 28 Sep 2024 20:39:44 +0500 Subject: [PATCH] -configured Docker to build Linux release; -added release ci config --- .github/workflows/build_and_test.yml | 7 +--- .github/workflows/release.yml | 56 ++++++++++++++++++++++++++++ Dockerfile | 28 ++++++++++++++ 3 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 Dockerfile diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index fd72b78..194827d 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -15,9 +15,6 @@ jobs: build: name: ${{ matrix.config.name }} runs-on: ${{ matrix.config.os }} - env: - CC: ${{ matrix.config.cc }} - CXX: ${{ matrix.config.cxx }} strategy: fail-fast: false @@ -56,7 +53,7 @@ jobs: - uses: ilammy/msvc-dev-cmd@v1 - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=ON -DENABLE_EXAMPLES=ON + run: cmake --preset=${{ matrix.config.cmake-preset }} -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=ON -DENABLE_EXAMPLES=ON - name: Build run: cmake --build ${{github.workspace}}/build --config Release @@ -73,7 +70,7 @@ jobs: find build/examples -type f -name "*.so" -exec cp {} examples-build \; find build/examples -type f -name "*.dll" -exec cp {} examples-build \; - - name: Upload build artifact + - name: Upload examples build artifact uses: actions/upload-artifact@v3 with: name: hypertextcpp-examples-${{ matrix.config.os }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ef9ad35 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +name: release + +on: + push: + branches: [ "master", "dev"] + : #tags: [ "v*" ] + + +jobs: + build-windows: + name: Build Windows version + runs-on: windows-latest + steps: + - name: Install ninja + run: choco install ninja + + - uses: actions/checkout@v4 + - uses: rui314/setup-mold@v1 + - uses: ilammy/msvc-dev-cmd@v1 + + - name: Configure CMake + run: cmake --preset=msvc-release -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release + + - name: Build + run: cmake --build ${{github.workspace}}/build --config Release + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: hypertextcpp-windows-latest + path: | + ${{github.workspace}}/build/hypertextcpp.exe + + release_hypertextcpp: + name: Release hypertextcpp + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v4 + + - name: Build linux version in Docker + run: DOCKER_BUILDKIT=1 docker build --build-arg cmake_preset=clang-release --output build . + + - name: Run unit tests + working-directory: ${{github.workspace}}/build/tests + run: ./test_hypertextcpp + + - name: Download hypertextcpp Windows build + id: pre_launch_tests + uses: actions/download-artifact@v3 + with: + name: hypertextcpp-windows-latest + path: build + - name: Test + shell: bash + run: ls build/hypertextcpp && ls build/hypertextcpp.exe \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6ca00c9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM alpine:3.18.3 AS hypertextcpp-build-container +ARG cmake_preset +RUN apk update && \ + apk add --no-cache \ + git \ + build-base \ + ccache \ + cmake \ + clang \ + clang-dev \ + mold \ + samurai + +WORKDIR /hypertextcpp_src +COPY external ./external/ +COPY src ./src/ +COPY tests ./tests/ +COPY CMakeLists.txt . +COPY CMakePresets.json . +RUN cmake --preset "$cmake_preset" -B build -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_EXE_LINKER_FLAGS="-static" -DENABLE_TESTS=ON -DENABLE_EXAMPLES=ON +RUN cmake --build build +RUN strip --strip-all build/hypertextcpp + + +FROM scratch AS hypertextcpp-build +COPY --from=hypertextcpp-build-container /hypertextcpp_src/build/hypertextcpp . +COPY --from=hypertextcpp-build-container /hypertextcpp_src/build/tests/test_hypertextcpp ./tests/ +COPY --from=hypertextcpp-build-container /hypertextcpp_src/build/examples ./examples/