diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 0f909a3d0..ccd2049a5 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -1,9 +1,12 @@ name: Build Debian Package on: push: - tags: - - 1.** - pull_request: + 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 jobs: package-ubuntu-latest-amd64: @@ -21,12 +24,26 @@ jobs: - name: "Install cpr dependencies" run: sudo apt install -y libssl-dev libcurl4-openssl-dev - name: "Install building tools" - run: sudo apt install cmake debmake devscripts debhelper - + 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: | + 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 - 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" diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ad7803dc..1bc0967b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,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_DEBUG_SANITIZER_FLAG_THREAD "Enables the ThreadSanitizer for debug builds." OFF) cpr_option(CPR_DEBUG_SANITIZER_FLAG_ADDR "Enables the AddressSanitizer for debug builds." OFF) cpr_option(CPR_DEBUG_SANITIZER_FLAG_LEAK "Enables the LeakSanitizer for debug builds." OFF) @@ -54,6 +55,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() + include(GNUInstallDirs) include(FetchContent) include(cmake/code_coverage.cmake) 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