From a3ea53d696fdf8f4f27e4e7c69997b503ddacd37 Mon Sep 17 00:00:00 2001 From: Jayasankar J P Date: Tue, 18 Aug 2026 08:56:16 +0000 Subject: [PATCH 1/4] adiding ci-cd #1 --- .github/workflows/ci.yml | 234 +++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 10 +- README.md | 62 ++++++----- 3 files changed, 276 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3b268f6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,234 @@ +name: CI & Library Install + +on: + push: + branches: [ main, master ] + tags: [ 'v*' ] + pull_request: + branches: [ main, master ] + +jobs: + # ========================================================================= + # 1. Native OS Builds (Windows & Linux Ubuntu) + # ========================================================================= + native-builds: + name: Native (${{ matrix.os }} - ${{ matrix.build_type }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest] + build_type: [Release, Debug] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Extract Version from Git Tag + shell: bash + run: | + if [[ "${GITHUB_REF}" == refs/tags/* ]]; then + VER="${GITHUB_REF_NAME#v}" + else + VER="1.0.0" + fi + echo "VERSION=${VER}" >> $GITHUB_ENV + echo "Building version: ${VER}" + + - name: Configure CMake + run: > + cmake -B build + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/install_dir + + - name: Build Library & Tests + run: cmake --build build --config ${{ matrix.build_type }} + + - name: Run CTest Suite + run: ctest --test-dir build -C ${{ matrix.build_type }} --output-on-failure + + - name: Install Library + run: cmake --install build --config ${{ matrix.build_type }} + + - name: Create Versioned Archive (Linux tar.gz) + if: runner.os == 'Linux' + run: | + cd ${{ runner.temp }} + tar -czvf logger-cpp-v${{ env.VERSION }}-${{ matrix.os }}-${{ matrix.build_type }}.tar.gz -C install_dir . + + - name: Create Versioned Archive (Windows zip) + if: runner.os == 'Windows' + shell: powershell + run: | + cd ${{ runner.temp }} + Compress-Archive -Path install_dir\* -DestinationPath logger-cpp-v$env:VERSION-${{ matrix.os }}-${{ matrix.build_type }}.zip + + - name: Upload Versioned Linux Archive + if: runner.os == 'Linux' + uses: actions/upload-artifact@v4 + with: + name: logger-cpp-v${{ env.VERSION }}-${{ matrix.os }}-${{ matrix.build_type }}.tar.gz + path: ${{ runner.temp }}/logger-cpp-v${{ env.VERSION }}-${{ matrix.os }}-${{ matrix.build_type }}.tar.gz + + - name: Upload Versioned Windows Archive + if: runner.os == 'Windows' + uses: actions/upload-artifact@v4 + with: + name: logger-cpp-v${{ env.VERSION }}-${{ matrix.os }}-${{ matrix.build_type }}.zip + path: ${{ runner.temp }}/logger-cpp-v${{ env.VERSION }}-${{ matrix.os }}-${{ matrix.build_type }}.zip + + # ========================================================================= + # 2. Linux Distributions Matrix (Ubuntu, Debian, Fedora, Alpine, Arch) + # ========================================================================= + linux-distros: + name: Distro (${{ matrix.distro }}) + runs-on: ubuntu-latest + container: + image: ${{ matrix.image }} + strategy: + fail-fast: false + matrix: + include: + - distro: ubuntu-22.04 + image: ubuntu:22.04 + pkg_cmd: apt-get update && apt-get install -y cmake build-essential tar git + - distro: ubuntu-24.04 + image: ubuntu:24.04 + pkg_cmd: apt-get update && apt-get install -y cmake build-essential tar git + - distro: debian-latest + image: debian:latest + pkg_cmd: apt-get update && apt-get install -y cmake build-essential tar git + - distro: fedora-latest + image: fedora:latest + pkg_cmd: dnf install -y cmake gcc-c++ make tar git + - distro: alpine-latest + image: alpine:latest + pkg_cmd: apk add --no-cache cmake make g++ build-base linux-headers tar git bash + - distro: archlinux-latest + image: archlinux:latest + pkg_cmd: pacman -Syu --noconfirm cmake gcc make tar git + + steps: + - name: Install Toolchain & Dependencies + run: ${{ matrix.pkg_cmd }} + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Extract Version from Git Tag + shell: bash + run: | + if [[ "${GITHUB_REF}" == refs/tags/* ]]; then + VER="${GITHUB_REF_NAME#v}" + else + VER="1.0.0" + fi + echo "VERSION=${VER}" >> $GITHUB_ENV + + - name: Configure CMake + run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/install_dir + + - name: Build Library & Tests + run: cmake --build build + + - name: Run CTest Suite + run: ctest --test-dir build --output-on-failure + + - name: Install Library + run: cmake --install build + + - name: Create Versioned Tarball (.tar.gz) + run: | + cd /tmp + tar -czvf logger-cpp-v${{ env.VERSION }}-${{ matrix.distro }}-x86_64.tar.gz -C install_dir . + + - name: Upload Versioned Distro Archive + uses: actions/upload-artifact@v4 + with: + name: logger-cpp-v${{ env.VERSION }}-${{ matrix.distro }}-x86_64.tar.gz + path: /tmp/logger-cpp-v${{ env.VERSION }}-${{ matrix.distro }}-x86_64.tar.gz + + # ========================================================================= + # 3. Raspberry Pi & ARM Architectures (ARMv7 32-bit & AArch64 64-bit) + # ========================================================================= + raspberry-pi-arm: + name: Raspberry Pi (${{ matrix.arch }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - arch: armv7 + distro: ubuntu22.04 + - arch: aarch64 + distro: ubuntu22.04 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Extract Version from Git Tag + shell: bash + run: | + if [[ "${GITHUB_REF}" == refs/tags/* ]]; then + VER="${GITHUB_REF_NAME#v}" + else + VER="1.0.0" + fi + echo "VERSION=${VER}" >> $GITHUB_ENV + + - name: Run Build, Test, Install & Packaging on ARM Runner (${{ matrix.arch }}) + uses: uraimo/run-on-arch-action@v2.8.0 + with: + arch: ${{ matrix.arch }} + distro: ${{ matrix.distro }} + githubToken: ${{ github.token }} + env: | + VERSION: ${{ env.VERSION }} + install: | + apt-get update + apt-get install -y cmake g++ make tar + run: | + ulimit -s unlimited || true + cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O0" -DCMAKE_INSTALL_PREFIX=/tmp/install_dir + cmake --build build + ctest --test-dir build --output-on-failure + cmake --install build + + cd /tmp + tar -czvf logger-cpp-v${VERSION}-raspberrypi-${{ matrix.arch }}.tar.gz -C install_dir . + + - name: Upload Versioned Raspberry Pi Tarball + uses: actions/upload-artifact@v4 + with: + name: logger-cpp-v${{ env.VERSION }}-raspberrypi-${{ matrix.arch }}.tar.gz + path: /tmp/logger-cpp-v${{ env.VERSION }}-raspberrypi-${{ matrix.arch }}.tar.gz + + # ========================================================================= + # 4. Automatic GitHub Release Publishing (Triggered on Git Tag Push: v*) + # ========================================================================= + create-github-release: + name: Create GitHub Release + if: startsWith(github.ref, 'refs/tags/') + needs: [native-builds, linux-distros, raspberry-pi-arm] + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Download All Build Artifacts + uses: actions/download-artifact@v4 + with: + path: release_artifacts + + - name: Collect & Flatten Binary Archives + run: | + mkdir release_dist + find release_artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec cp {} release_dist/ \; + ls -la release_dist/ + + - name: Publish Official GitHub Release + uses: softprops/action-gh-release@v2 + with: + files: release_dist/* + generate_release_notes: true diff --git a/CMakeLists.txt b/CMakeLists.txt index 28dbb44..d78e293 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,16 +24,20 @@ target_include_directories(Logger PUBLIC # ----------------------------- # Test Executable # ----------------------------- -add_executable(test +enable_testing() + +add_executable(logger_test test/Test.cpp ) -target_link_libraries(test PRIVATE Logger) +target_link_libraries(logger_test PRIVATE Logger) -set_target_properties(test PROPERTIES +set_target_properties(logger_test PROPERTIES OUTPUT_NAME "test.exe" ) +add_test(NAME LoggerTest COMMAND logger_test) + add_executable(benchmark test/Benchmark.cpp ) diff --git a/README.md b/README.md index bfd9a3e..9d8c671 100644 --- a/README.md +++ b/README.md @@ -19,47 +19,55 @@ cd logger-cpp --- -# ⚙️ Installation -## 📦 Install Dependency: cpp-utils +# ⚙️ Installation & Build -This project requires **cpp-utils**. +## 📋 Prerequisites +- C++17 compliant compiler (`g++`, `clang++`, or MSVC) +- CMake 3.15 or higher +--- + +## 📦 Option 1: Install from Release Binaries (Pre-built Archives) + +Download the pre-compiled archive for your OS/architecture from [GitHub Releases](https://github.com/jayasankar-jp/logger-cpp/releases). + +### Linux (Ubuntu / Debian / Fedora / Alpine / Arch / Raspberry Pi) ```bash -git clone https://github.com/jayasankar-jp/cpp-utils.git -cd cpp-utils -mkdir build -cd build -cmake .. -make -sudo make install +# Download and extract to system path or custom directory (e.g. /usr/local) +sudo tar -xzvf logger-cpp-v1.0.0-ubuntu-22.04-x86_64.tar.gz -C /usr/local ``` -## ✅ Build logger-cpp -Navigate to your project directory. +### Windows +Extract the downloaded `.zip` package to your desired directory (e.g., `C:\Program Files\Logger`). + +--- + +## 🛠️ Option 2: Build & Install from Source + ```bash git clone git@github.com:jayasankar-jp/logger-cpp.git cd logger-cpp -mkdir build -cd build -cmake .. -make -``` ---- +# Configure +cmake -B build -DCMAKE_BUILD_TYPE=Release -## ✅ Install +# Build +cmake --build build -```bash -sudo make install +# Install (Linux/macOS) +sudo cmake --install build + +# Install (Windows - Run as Administrator / Powershell) +cmake --install build --prefix "C:\Program Files\Logger" ``` -### 📦 Installed Files +### 📦 Installed Files Location -| Type | Path | -| ------------ | ------------------------------ | -| Library | `/usr/local/lib/libLogger.a` | -| Headers | `/usr/local/include/` | -| CMake Config | `/usr/local/lib/cmake/Logger/` | +| Type | Linux / macOS Path | Windows Default Path | +| ------------ | ------------------------------ | ----------------------------------- | +| Library | `/usr/local/lib/libLogger.a` | `/lib/Logger.lib` | +| Headers | `/usr/local/include/` | `/include/` | +| CMake Config | `/usr/local/lib/cmake/Logger/` | `/lib/cmake/Logger/` | --- From 266cbce45ba9f56641aca322bb3baafe07579bb2 Mon Sep 17 00:00:00 2001 From: Jayasankar J P Date: Tue, 18 Aug 2026 09:33:01 +0000 Subject: [PATCH 2/4] ci-cd #2 --- .github/workflows/ci.yml | 30 ++++++++++++++++++++++++++++++ CMakeLists.txt | 16 ++++++++++++++++ README.md | 19 ++++++++++++++++++- 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b268f6..b87e477 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,11 +35,24 @@ jobs: echo "VERSION=${VER}" >> $GITHUB_ENV echo "Building version: ${VER}" + - name: Checkout cpp-utils dependency + uses: actions/checkout@v4 + with: + repository: jayasankar-jp/cpp-utils + path: cpp-utils + + - name: Build & Install cpp-utils + run: | + cmake -B cpp-utils/build -S cpp-utils -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/install_dir + cmake --build cpp-utils/build --config ${{ matrix.build_type }} + cmake --install cpp-utils/build --config ${{ matrix.build_type }} + - name: Configure CMake run: > cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/install_dir + -DCMAKE_PREFIX_PATH=${{ runner.temp }}/install_dir - name: Build Library & Tests run: cmake --build build --config ${{ matrix.build_type }} @@ -115,6 +128,18 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Checkout cpp-utils dependency + uses: actions/checkout@v4 + with: + repository: jayasankar-jp/cpp-utils + path: cpp-utils + + - name: Build & Install cpp-utils + run: | + cmake -B cpp-utils/build -S cpp-utils -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local + cmake --build cpp-utils/build + cmake --install cpp-utils/build + - name: Extract Version from Git Tag shell: bash run: | @@ -190,6 +215,11 @@ jobs: apt-get install -y cmake g++ make tar run: | ulimit -s unlimited || true + git clone https://github.com/jayasankar-jp/cpp-utils.git cpp-utils + cmake -B cpp-utils/build -S cpp-utils -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O0" -DCMAKE_INSTALL_PREFIX=/usr/local + cmake --build cpp-utils/build + cmake --install cpp-utils/build + cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O0" -DCMAKE_INSTALL_PREFIX=/tmp/install_dir cmake --build build ctest --test-dir build --output-on-failure diff --git a/CMakeLists.txt b/CMakeLists.txt index d78e293..9e3c42b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,22 @@ project(Logger VERSION 1.0 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +# ----------------------------- +# Dependencies (cpp-utils) +# ----------------------------- +include(FetchContent) +find_package(cpp-utils QUIET) + +if(NOT cpp-utils_FOUND) + message(STATUS "cpp-utils not found locally. Fetching from GitHub repository...") + FetchContent_Declare( + cpp-utils + GIT_REPOSITORY https://github.com/jayasankar-jp/cpp-utils.git + GIT_TAG master + ) + FetchContent_MakeAvailable(cpp-utils) +endif() + # ----------------------------- # Library Target # ----------------------------- diff --git a/README.md b/README.md index 9d8c671..3ba949a 100644 --- a/README.md +++ b/README.md @@ -44,11 +44,14 @@ Extract the downloaded `.zip` package to your desired directory (e.g., `C:\Progr ## 🛠️ Option 2: Build & Install from Source +> 💡 **Note:** If `cpp-utils` is not installed on your system, CMake will **automatically fetch and build it** for you during configuration! + +### Quick Build & Install (Automatic Dependency Resolution) ```bash git clone git@github.com:jayasankar-jp/logger-cpp.git cd logger-cpp -# Configure +# Configure (Fetches cpp-utils automatically if needed) cmake -B build -DCMAKE_BUILD_TYPE=Release # Build @@ -56,6 +59,20 @@ cmake --build build # Install (Linux/macOS) sudo cmake --install build +``` + +--- + +### Optional: Pre-installing `cpp-utils` Manually +If you prefer to install `cpp-utils` onto your system beforehand: +```bash +git clone https://github.com/jayasankar-jp/cpp-utils.git +cd cpp-utils +cmake -B build -DCMAKE_BUILD_TYPE=Release +cmake --build build +sudo cmake --install build +cd .. +``` # Install (Windows - Run as Administrator / Powershell) cmake --install build --prefix "C:\Program Files\Logger" From 62de684b094d8f4c1b9d1fed2392b40f74397488 Mon Sep 17 00:00:00 2001 From: Jayasankar J P Date: Tue, 18 Aug 2026 09:36:59 +0000 Subject: [PATCH 3/4] update --- CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e3c42b..062fa11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,12 +31,22 @@ add_library(Logger STATIC src/FileWriter.cpp ) -# Proper include visibility +# Proper include visibility & dependencies target_include_directories(Logger PUBLIC $ $ ) +if(TARGET internalLib) + target_link_libraries(Logger PUBLIC internalLib) + target_include_directories(Logger PUBLIC $) +elseif(TARGET cpp-utils::cpp-utils) + target_link_libraries(Logger PUBLIC cpp-utils::cpp-utils) +else() + # Fallback to prefix path includes if installed to custom prefix + target_include_directories(Logger PUBLIC $) +endif() + # ----------------------------- # Test Executable # ----------------------------- From b6101dd84880c69425ee40d0f0aebea6baf29bea Mon Sep 17 00:00:00 2001 From: Jayasankar J P Date: Tue, 18 Aug 2026 09:42:35 +0000 Subject: [PATCH 4/4] update ci #4 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b87e477..7a6e58f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -212,7 +212,7 @@ jobs: VERSION: ${{ env.VERSION }} install: | apt-get update - apt-get install -y cmake g++ make tar + apt-get install -y cmake g++ make tar git run: | ulimit -s unlimited || true git clone https://github.com/jayasankar-jp/cpp-utils.git cpp-utils