Skip to content

Commit d2d314a

Browse files
committed
Workflow to bump version on each commit
1 parent 0c245eb commit d2d314a

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

.github/workflows/bump_version.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: bump version
2+
# Upstream uses last portion of the version as a unique part to differentiate builds
3+
# created from different commits. Last part (or VERSION_TWEAK) is basically a number
4+
# of commits since the last tag (computed automatically by git).
5+
# That works well for them, since they release from the same branch: e.g. 24.8,
6+
# adding stuff to it and eventually pushing out the release.
7+
#
8+
# For Altinity we use different branches, and we don't put upstream tags to our repo.
9+
# Hence we can't rely on this automatic behaviour from git.
10+
#
11+
# So in order to generate new version, whenever it makes sense, and to make it different from
12+
# upstream's (Altinity versions have VERSION_TWEAK >= upsteam's versions VERSION_TWEAK)
13+
# we increment existing VERSION_TWEAK by 1 each time.
14+
15+
env:
16+
# version suffix to use in cmake/autogenerated_versions_new.txt
17+
# due to current content of that file, anything different than 'altinitystable'
18+
# will prepended to the VERSION_DESCRIBE-part.
19+
# e.g. VERSION_TYPE: 'new' ==> VERSION_DESCRIBE='24.8.1.23.altinitystable-new'
20+
VERSION_TYPE: altinitystable
21+
22+
on:
23+
push:
24+
branches:
25+
# At the moment it seems wise to not execute on release branches:
26+
# this workflow produces a new commit with a new version value,
27+
# which might conflict with (already started by another workflow)
28+
# build & release process, potentially cancelling it and
29+
# re-triggering and re-doing of all of the builds and delaying the release.
30+
- 'customizations/**'
31+
32+
jobs:
33+
bump-version:
34+
runs-on: [ubuntu-latest]
35+
steps:
36+
- name: checkout repo
37+
uses: actions/checkout@v4
38+
39+
- name: Update cmake/autogenerated_versions.txt
40+
run: |
41+
awk 'match($0, /^(SET\(VERSION_TWEAK) ([0-9])+(.*\))/, m) { print(m[1] " " strtonum($2) + 1 "" m[3]) ; next } 1' \
42+
cmake/autogenerated_versions.txt > cmake/autogenerated_versions_new.txt
43+
mv cmake/autogenerated_versions_new.txt cmake/autogenerated_versions.txt
44+
cat cmake/autogenerated_versions.txt
45+
# update rest of the version info (mostly VERSION_DESCRIBE and VERSION_STRING)
46+
python3 tests/ci/version_helper.py --update-cmake --version-type='altinitystable'
47+
48+
- name: push updated cmake/autogenerated_versions.txt
49+
run: |
50+
# export version info as multiple variables
51+
source <(python3 tests/ci/version_helper.py --export --version-type='altinitystable')
52+
git \
53+
54+
-c user.name=altinity-robot \
55+
-c commit.gpgsign=false
56+
git commit -a -m "Bumped version to $CLICKHOUSE_VERSION_DESCRIBE" cmake/autogenerated_versions.txt
57+
git push

tests/ci/version_helper.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
SET(VERSION_MAJOR {major})
2929
SET(VERSION_MINOR {minor})
3030
SET(VERSION_PATCH {patch})
31+
SET(VERSION_TWEAK {tweak})
32+
SET(VERSION_FLAVOUR {flavour})
3133
SET(VERSION_GITHASH {githash})
3234
SET(VERSION_DESCRIBE {describe})
3335
SET(VERSION_STRING {string})
@@ -177,10 +179,11 @@ def as_dict(self) -> VERSIONS:
177179
"major": self.major,
178180
"minor": self.minor,
179181
"patch": self.patch,
180-
"tweak": self.tweak,
181182
"githash": self.githash,
182183
"describe": self.describe,
183184
"string": self.string,
185+
"tweak": self._tweak or "",
186+
"flavour": self._flavour or "",
184187
}
185188

186189
def as_tuple(self) -> Tuple[int, int, int, int]:

0 commit comments

Comments
 (0)