From a5596449858a55ccb5e25446fe3978a73cb74dd6 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Sun, 22 Sep 2024 09:22:46 +0200 Subject: [PATCH 1/4] NuGet spec formatting --- nuget/libcpr.nuspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nuget/libcpr.nuspec b/nuget/libcpr.nuspec index e47a8c08e..1169ebf4e 100644 --- a/nuget/libcpr.nuspec +++ b/nuget/libcpr.nuspec @@ -13,7 +13,7 @@ https://github.com/libcpr C++ Requests: Curl for People, a spiritual port of Python Requests. Native, native - english - + english + \ No newline at end of file From 0e2fcb7569c4728f56e7c445e5a7a07bb42fcde1 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Sun, 22 Sep 2024 09:23:39 +0200 Subject: [PATCH 2/4] Workflow dispatch support for deb build CI --- .github/workflows/build-deb.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index cff419b5b..56794b2a6 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -1,8 +1,12 @@ name: Build Debian Package on: push: - tags: - - 1.** + tags: [ '[0-9]+.[0-9]+.[0-9]+' ] + workflow_dispatch: + inputs: + version: + description: 'The optional semantic version number. If not supplied the branch/tag will be used.' + type: string pull_request: jobs: @@ -23,10 +27,18 @@ jobs: - name: "Install building tools" run: sudo apt install -y cmake debmake devscripts debhelper + - name: Set version based on input + if: ${{ inputs.version }} + run: echo "RELEASE_VERSION=${{ inputs.version }}" >> "$GITHUB_ENV" + - name: Set version based on ref + if: ${{ !inputs.version }} + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> "$GITHUB_ENV" + - name: Print Version + run: echo "deb version will be '${{ env.RELEASE_VERSION }}'" # Build package of runtime library - name: "Package build of runtime library" env: - VERSION: ${{ github.ref_name }} + VERSION: ${{ env.RELEASE_VERSION }} run: bash cpr/package-build/build-package.sh cpr - name: "Upload deb-packages" From e59d3260b973da71d98f00892f7534d1e7f13541 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Sun, 22 Sep 2024 13:10:01 +0200 Subject: [PATCH 3/4] Setting deb version based on CMake version --- .github/workflows/build-deb.yml | 10 ++++++++-- CMakeLists.txt | 8 ++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 56794b2a6..2b7627022 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -26,13 +26,19 @@ jobs: run: sudo apt install -y libssl-dev libcurl4-openssl-dev - name: "Install building tools" run: sudo apt install -y cmake debmake devscripts debhelper - + # Set version number - name: Set version based on input if: ${{ inputs.version }} run: echo "RELEASE_VERSION=${{ inputs.version }}" >> "$GITHUB_ENV" - name: Set version based on ref if: ${{ !inputs.version }} - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> "$GITHUB_ENV" + run: | + mkdir -p cpr/build + pushd cpr/build + cmake .. -DCPR_BUILD_VERSION_OUTPUT_ONLY=ON + echo "RELEASE_VERSION=$(cat version.txt)" >> $GITHUB_ENV + popd + rm -rf cpr/build - name: Print Version run: echo "deb version will be '${{ env.RELEASE_VERSION }}'" # Build package of runtime library diff --git a/CMakeLists.txt b/CMakeLists.txt index ea6991f77..7d2d83941 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,7 @@ cpr_option(CPR_ENABLE_CPPCHECK "Set to ON to enable Cppcheck static analysis. Re cpr_option(CPR_BUILD_TESTS "Set to ON to build cpr tests." OFF) cpr_option(CPR_BUILD_TESTS_SSL "Set to ON to build cpr ssl tests" ${CPR_BUILD_TESTS}) cpr_option(CPR_BUILD_TESTS_PROXY "Set to ON to build proxy tests. They fail in case there is no valid proxy server available in proxy_tests.cpp" OFF) +cpr_option(CPR_BUILD_VERSION_OUTPUT_ONLY "Set to ON to only export the version into 'build/version.txt' and exit" OFF) cpr_option(CPR_SKIP_CA_BUNDLE_SEARCH "Skip searching for Certificate Authority certs. Turn ON for systems like iOS where file access is restricted and prevents https from working." OFF) cpr_option(CPR_USE_BOOST_FILESYSTEM "Set to ON to use the Boost.Filesystem library. This is useful, on, e.g., Apple platforms, where std::filesystem may not always be available when targeting older OS versions." OFF) cpr_option(CPR_DEBUG_SANITIZER_FLAG_THREAD "Enables the ThreadSanitizer for debug builds." OFF) @@ -75,6 +76,13 @@ cpr_option(CPR_DEBUG_SANITIZER_FLAG_UB "Enables the UndefinedBehaviorSanitizer f cpr_option(CPR_DEBUG_SANITIZER_FLAG_ALL "Enables all sanitizers for debug builds except the ThreadSanitizer since it is incompatible with the other sanitizers." OFF) message(STATUS "=======================================================") +# Save the project version as txt file for deb and NuGet builds +if(CPR_BUILD_VERSION_OUTPUT_ONLY) + message(STATUS "Printing version and exiting...") + file(WRITE "${CMAKE_BINARY_DIR}/version.txt" "${PROJECT_VERSION}") + return() +endif() + if (CPR_FORCE_USE_SYSTEM_CURL) message(WARNING "The variable CPR_FORCE_USE_SYSTEM_CURL is deprecated, please use CPR_USE_SYSTEM_CURL instead") set(CPR_USE_SYSTEM_CURL ${CPR_FORCE_USE_SYSTEM_CURL}) From 1639ed3e81ced6fe459eb4f78c1495745c704d96 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Sun, 22 Sep 2024 13:13:06 +0200 Subject: [PATCH 4/4] Not building deb package on PRs --- .github/workflows/build-deb.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 2b7627022..cadc95b7d 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -7,7 +7,6 @@ on: version: description: 'The optional semantic version number. If not supplied the branch/tag will be used.' type: string - pull_request: jobs: package-ubuntu-latest-amd64: