diff --git a/.github/workflows/bump_version.yml b/.github/workflows/bump_version.yml new file mode 100644 index 000000000000..c0e0ef807447 --- /dev/null +++ b/.github/workflows/bump_version.yml @@ -0,0 +1,59 @@ +name: bump version +permissions: + contents: write +# Upstream uses last portion of the version as a unique part to differentiate builds +# created from different commits. Last part (or VERSION_TWEAK) is basically a number +# of commits since the last tag (computed automatically by git). +# That works well for them, since they release from the same branch: e.g. 24.8, +# adding stuff to it and eventually pushing out the release. +# +# For Altinity we use different branches, and we don't put upstream tags to our repo. +# Hence we can't rely on this automatic behaviour from git. +# +# So in order to generate new version, whenever it makes sense, and to make it different from +# upstream's (Altinity versions have VERSION_TWEAK >= upsteam's versions VERSION_TWEAK) +# we increment existing VERSION_TWEAK by 1 each time. + +env: + # version suffix to use in cmake/autogenerated_versions_new.txt + # due to current content of that file, anything different than 'altinitystable' + # will prepended to the VERSION_DESCRIBE-part. + # e.g. VERSION_TYPE: 'new' ==> VERSION_DESCRIBE='24.8.1.23.altinitystable-new' + VERSION_TYPE: altinitystable + +on: + push: + branches: + # At the moment it seems wise to not execute on release branches: + # this workflow produces a new commit with a new version value, + # which might conflict with (already started by another workflow) + # build & release process, potentially cancelling it and + # re-triggering and re-doing of all of the builds and delaying the release. + - 'customizations/**' + +jobs: + bump-version: + runs-on: [ubuntu-latest] + steps: + - name: checkout repo + uses: actions/checkout@v4 + + - name: Update cmake/autogenerated_versions.txt + run: | + awk 'match($0, /^(SET\(VERSION_TWEAK) ([0-9])+(.*\))/, m) { print(m[1] " " strtonum($2) + 1 "" m[3]) ; next } 1' \ + cmake/autogenerated_versions.txt > cmake/autogenerated_versions_new.txt + mv cmake/autogenerated_versions_new.txt cmake/autogenerated_versions.txt + cat cmake/autogenerated_versions.txt + # update rest of the version info (mostly VERSION_DESCRIBE and VERSION_STRING) + python3 tests/ci/version_helper.py --update-cmake --version-type=${{ env.VERSION_TYPE }} + + - name: push updated cmake/autogenerated_versions.txt + run: | + set -x + # export version info as multiple variables + source <(python3 tests/ci/version_helper.py --export --version-type='altinitystable') + git config --global user.email altinity-robot@users.noreply.github.com + git config --global user.name altinity-robot + git config --global commit.gpgsign false + git commit -m "Bumped version to $CLICKHOUSE_VERSION_DESCRIBE" -- cmake/autogenerated_versions.txt + git push diff --git a/tests/ci/version_helper.py b/tests/ci/version_helper.py index 84ad3a50d87c..bfcdbbcadd88 100755 --- a/tests/ci/version_helper.py +++ b/tests/ci/version_helper.py @@ -28,6 +28,8 @@ SET(VERSION_MAJOR {major}) SET(VERSION_MINOR {minor}) SET(VERSION_PATCH {patch}) +SET(VERSION_TWEAK {tweak}) +SET(VERSION_FLAVOUR {flavour}) SET(VERSION_GITHASH {githash}) SET(VERSION_DESCRIBE {describe}) SET(VERSION_STRING {string}) @@ -177,10 +179,11 @@ def as_dict(self) -> VERSIONS: "major": self.major, "minor": self.minor, "patch": self.patch, - "tweak": self.tweak, "githash": self.githash, "describe": self.describe, "string": self.string, + "tweak": self._tweak or "", + "flavour": self._flavour or "", } def as_tuple(self) -> Tuple[int, int, int, int]: