From e733fadb4511ebbf37c1939e841c3858c1194a70 Mon Sep 17 00:00:00 2001 From: Ayaz Salikhov Date: Mon, 12 Jan 2026 17:31:09 +0000 Subject: [PATCH] ci: Pass version explicitly and don't rely on tags (#2904) --- .github/actions/cmake/action.yml | 7 +++++ .github/workflows/nightly.yml | 28 +++++++++++-------- .github/workflows/release.yml | 3 ++- .github/workflows/reusable-build-test.yml | 14 +++++----- .github/workflows/reusable-build.yml | 33 ++++++++++++----------- cmake/ClioVersion.cmake | 21 ++++----------- 6 files changed, 55 insertions(+), 51 deletions(-) diff --git a/.github/actions/cmake/action.yml b/.github/actions/cmake/action.yml index b02cabd97..96898d704 100644 --- a/.github/actions/cmake/action.yml +++ b/.github/actions/cmake/action.yml @@ -37,6 +37,10 @@ inputs: description: Whether to generate Debian package required: true default: "false" + version: + description: Version of the clio_server binary + required: false + default: "" runs: using: composite @@ -67,6 +71,9 @@ runs: # This way it works both for PRs and pushes to branches. GITHUB_BRANCH_NAME: "${{ github.head_ref || github.ref_name }}" GITHUB_HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}" + # + # If tag is being pushed, or it's a nightly release, we use that version. + FORCE_CLIO_VERSION: ${{ inputs.version }} run: | cmake \ -B "${BUILD_DIR}" \ diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index b1529190c..50e690fcd 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -28,8 +28,20 @@ defaults: shell: bash jobs: + get_date: + name: Get Date + runs-on: ubuntu-latest + outputs: + date: ${{ steps.get_date.outputs.date }} + steps: + - name: Get current date + id: get_date + run: | + echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT + build-and-test: name: Build and Test + needs: get_date strategy: fail-fast: false @@ -67,9 +79,11 @@ jobs: upload_clio_server: true download_ccache: false upload_ccache: false + version: nightly-${{ needs.get_date.outputs.date }} package: name: Build debian package + needs: get_date uses: ./.github/workflows/reusable-build.yml with: @@ -83,11 +97,13 @@ jobs: static: true upload_clio_server: false package: true + version: nightly-${{ needs.get_date.outputs.date }} targets: package analyze_build_time: false analyze_build_time: name: Analyze Build Time + needs: get_date strategy: fail-fast: false @@ -114,17 +130,7 @@ jobs: upload_clio_server: false targets: all analyze_build_time: true - - get_date: - name: Get Date - runs-on: ubuntu-latest - outputs: - date: ${{ steps.get_date.outputs.date }} - steps: - - name: Get current date - id: get_date - run: | - echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT + version: nightly-${{ needs.get_date.outputs.date }} nightly_release: needs: [build-and-test, package, get_date] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 158107a42..85f3c8763 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,7 +43,7 @@ jobs: upload_clio_server: true download_ccache: false upload_ccache: false - expected_version: ${{ github.event_name == 'push' && github.ref_name || '' }} + version: ${{ github.event_name == 'push' && github.ref_name || '' }} package: name: Build debian package @@ -60,6 +60,7 @@ jobs: static: true upload_clio_server: false package: true + version: ${{ github.event_name == 'push' && github.ref_name || '' }} targets: package analyze_build_time: false diff --git a/.github/workflows/reusable-build-test.yml b/.github/workflows/reusable-build-test.yml index bf9d82515..d3cbe543d 100644 --- a/.github/workflows/reusable-build-test.yml +++ b/.github/workflows/reusable-build-test.yml @@ -63,18 +63,18 @@ on: type: string default: all - expected_version: - description: Expected version of the clio_server binary - required: false - type: string - default: "" - package: description: Whether to generate Debian package required: false type: boolean default: false + version: + description: Version of the clio_server binary + required: false + type: string + default: "" + jobs: build: uses: ./.github/workflows/reusable-build.yml @@ -90,8 +90,8 @@ jobs: upload_clio_server: ${{ inputs.upload_clio_server }} targets: ${{ inputs.targets }} analyze_build_time: false - expected_version: ${{ inputs.expected_version }} package: ${{ inputs.package }} + version: ${{ inputs.version }} test: needs: build diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index 2025fd168..729c41043 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -60,17 +60,17 @@ on: required: true type: boolean - expected_version: - description: Expected version of the clio_server binary - required: false - type: string - default: "" - package: description: Whether to generate Debian package required: false type: boolean + version: + description: Version of the clio_server binary + required: false + type: string + default: "" + secrets: CODECOV_TOKEN: required: false @@ -93,10 +93,6 @@ jobs: - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 with: fetch-depth: 0 - # We need to fetch tags to have correct version in the release - # The workaround is based on https://github.com/actions/checkout/issues/1467 - fetch-tags: true - ref: ${{ github.ref }} - name: Prepare runner uses: XRPLF/actions/prepare-runner@65da1c59e81965eeb257caa3587b9d45066fb925 @@ -139,6 +135,7 @@ jobs: static: ${{ inputs.static }} time_trace: ${{ inputs.analyze_build_time }} package: ${{ inputs.package }} + version: ${{ inputs.version }} - name: Build Clio uses: ./.github/actions/build-clio @@ -218,15 +215,19 @@ jobs: if: ${{ inputs.code_coverage }} uses: ./.github/actions/code-coverage - - name: Verify expected version - if: ${{ inputs.expected_version != '' }} + - name: Verify version is expected + if: ${{ inputs.version != '' }} env: - INPUT_EXPECTED_VERSION: ${{ inputs.expected_version }} + INPUT_VERSION: ${{ inputs.version }} run: | set -e - EXPECTED_VERSION="clio-${INPUT_EXPECTED_VERSION}" - actual_version=$(./build/clio_server --version) - if [[ "$actual_version" != "$EXPECTED_VERSION" ]]; then + EXPECTED_VERSION="clio-${INPUT_VERSION}" + if [[ ${{ inputs.build_type }} == "Debug" ]]; then + EXPECTED_VERSION="${EXPECTED_VERSION}+DEBUG" + fi + + actual_version=$(./build/clio_server --version | head -n 1) + if [[ "${actual_version}" != "${EXPECTED_VERSION}" ]]; then echo "Expected version '${EXPECTED_VERSION}', but got '${actual_version}'" exit 1 fi diff --git a/cmake/ClioVersion.cmake b/cmake/ClioVersion.cmake index 6d61e1d70..8bab301d4 100644 --- a/cmake/ClioVersion.cmake +++ b/cmake/ClioVersion.cmake @@ -27,24 +27,13 @@ message(STATUS "Git branch: ${GIT_BUILD_BRANCH}") message(STATUS "Git commit hash: ${GIT_COMMIT_HASH}") message(STATUS "Build date: ${BUILD_DATE}") -set(GIT_COMMAND describe --tags --exact-match) -execute_process( - COMMAND ${GIT_EXECUTABLE} ${GIT_COMMAND} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE TAG - RESULT_VARIABLE RC - ERROR_VARIABLE ERR - OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE -) +if (DEFINED ENV{FORCE_CLIO_VERSION} AND NOT "$ENV{FORCE_CLIO_VERSION}" STREQUAL "") + message(STATUS "Using explicitly provided '${FORCE_CLIO_VERSION}' as Clio version") -if (RC EQUAL 0) - message(STATUS "Found tag '${TAG}' in git. Will use it as Clio version") - - set(CLIO_VERSION "${TAG}") - set(DOC_CLIO_VERSION "${TAG}") + set(CLIO_VERSION "$ENV{FORCE_CLIO_VERSION}") + set(DOC_CLIO_VERSION "$ENV{FORCE_CLIO_VERSION}") else () - message(STATUS "Error finding tag in git: ${ERR}") - message(STATUS "Will use 'YYYYMMDDHMS--' as Clio version") + message(STATUS "Using 'YYYYMMDDHMS--' as Clio version") string(SUBSTRING ${GIT_COMMIT_HASH} 0 7 GIT_COMMIT_HASH_SHORT)