From 9479eb24a4867f8981ac94d26b00a27f6aeb5e0f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 29 Jul 2025 20:58:23 +0000 Subject: [PATCH 1/2] Initial plan From ef8441a6747ef6dc44eb5f5f9d922ad608e27082 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 29 Jul 2025 21:05:49 +0000 Subject: [PATCH 2/2] Implement dynamic version fetching for CMake and Catch2 Co-authored-by: niteshpurohit <2043084+niteshpurohit@users.noreply.github.com> --- .github/workflows/docker-publish.yml | 18 ++++++++++++++++++ Dockerfile | 20 +++++++++++++------- README.md | 14 ++++++++++++++ 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 7db2457..0471d38 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -37,6 +37,21 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + # Fetch latest versions of CMake and Catch2 + - name: Get latest CMake version + id: cmake_version + run: | + CMAKE_VERSION=$(curl -s https://api.github.com/repos/Kitware/CMake/releases/latest | jq -r '.tag_name') + echo "version=$CMAKE_VERSION" >> $GITHUB_OUTPUT + echo "Latest CMake version: $CMAKE_VERSION" + + - name: Get latest Catch2 version + id: catch2_version + run: | + CATCH2_VERSION=$(curl -s https://api.github.com/repos/catchorg/Catch2/releases/latest | jq -r '.tag_name') + echo "version=$CATCH2_VERSION" >> $GITHUB_OUTPUT + echo "Latest Catch2 version: $CATCH2_VERSION" + # Install the cosign tool except on PR # https://github.com/sigstore/cosign-installer - name: Install cosign @@ -82,6 +97,9 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max + build-args: | + CMAKE_VERSION=${{ steps.cmake_version.outputs.version }} + CATCH2_VERSION=${{ steps.catch2_version.outputs.version }} # Sign the resulting Docker image digest except on PRs. # This will only write to the public Rekor transparency log when the Docker diff --git a/Dockerfile b/Dockerfile index f4fe4c6..d911902 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,30 @@ FROM gcc:latest +# Build arguments for versions (with defaults for backward compatibility) +ARG CMAKE_VERSION=v4.0.3 +ARG CATCH2_VERSION=v3.8.1 + # Set the working directory WORKDIR /app # Install CMake RUN apt-get update && apt-get install -y wget && \ ARCH=$(uname -m) && \ + CMAKE_VER_NO_V=${CMAKE_VERSION#v} && \ if [ "$ARCH" = "aarch64" ]; then \ - wget -q https://github.com/Kitware/CMake/releases/download/v4.0.3/cmake-4.0.3-linux-aarch64.sh; \ + wget -q https://github.com/Kitware/CMake/releases/download/${CMAKE_VERSION}/cmake-${CMAKE_VER_NO_V}-linux-aarch64.sh; \ else \ - wget -q https://github.com/Kitware/CMake/releases/download/v4.0.3/cmake-4.0.3-linux-x86_64.sh; \ + wget -q https://github.com/Kitware/CMake/releases/download/${CMAKE_VERSION}/cmake-${CMAKE_VER_NO_V}-linux-x86_64.sh; \ fi && \ - chmod +x cmake-4.0.3-linux-*.sh && \ - ./cmake-4.0.3-linux-*.sh --skip-license --prefix=/usr/local && \ + chmod +x cmake-${CMAKE_VER_NO_V}-linux-*.sh && \ + ./cmake-${CMAKE_VER_NO_V}-linux-*.sh --skip-license --prefix=/usr/local && \ ln -s /usr/local/bin/cmake /usr/bin/cmake # Install Catch2 -RUN wget -q https://github.com/catchorg/Catch2/archive/refs/tags/v3.8.1.zip && \ - unzip v3.8.1.zip && \ - cd Catch2-3.8.1 && \ +RUN CATCH2_VER_NO_V=${CATCH2_VERSION#v} && \ + wget -q https://github.com/catchorg/Catch2/archive/refs/tags/${CATCH2_VERSION}.zip && \ + unzip ${CATCH2_VERSION}.zip && \ + cd Catch2-${CATCH2_VER_NO_V} && \ cmake -Bbuild -H. -DBUILD_TESTING=OFF && \ cmake --build build/ --target install diff --git a/README.md b/README.md index 5383e78..4dc6c60 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,20 @@ To build the image locally, run the following command: docker build -t cpp-runner . ``` +### Building with specific versions + +The image automatically uses the latest releases of CMake and Catch2 when built through GitHub Actions. For local builds, you can specify versions using build arguments: + +```bash +# Build with specific versions +docker build --build-arg CMAKE_VERSION=v3.29.0 --build-arg CATCH2_VERSION=v3.7.1 -t cpp-runner . + +# Build with default versions (same as just docker build -t cpp-runner .) +docker build --build-arg CMAKE_VERSION=v4.0.3 --build-arg CATCH2_VERSION=v3.8.1 -t cpp-runner . +``` + +The GitHub Actions workflow automatically fetches and uses the latest released versions of both dependencies. + ## License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.