Skip to content

Commit a449597

Browse files
authored
chore: use github ref name to update next version (#2297)
Signed-off-by: Jose I. Paris <[email protected]>
1 parent 4106d30 commit a449597

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

.github/workflows/utils/bump-project-version.sh

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,28 @@ if [[ -n "${1}" ]]; then
2121
project_yaml="${1}"
2222
fi
2323

24-
# Load the previous version and bump appropriately
25-
version=$(cat "${project_yaml}" | awk '/^projectVersion:/ {
26-
version = $2;
27-
if (version ~ /-rc/) {
28-
# Handle release candidate versions (e.g., v1.0.0-rc.1 -> v1.0.0-rc.2)
29-
split(version, parts, /-rc\./);
30-
rc_num = parts[2] + 1;
31-
print parts[1] "-rc." rc_num;
32-
}
33-
else {
34-
# Load the previous version and BUMP THE MINOR
35-
# Handle minor version bumps (e.g., v1.0.0 -> v1.1.0)
36-
split(version, ver_parts, /\./);
37-
ver_parts[2] = ver_parts[2] + 1;
38-
print ver_parts[1] "." ver_parts[2] ".0";
39-
}
40-
}')
24+
if [[ -n "$GITHUB_REF_NAME" ]]; then
25+
# Bump from provided version tag
26+
version=$(echo $GITHUB_REF_NAME | awk -F'[ .]' '{print $1"."$2+1"."0}')
27+
else
28+
# Load the previous version and bump appropriately
29+
version=$(cat "${project_yaml}" | awk '/^projectVersion:/ {
30+
version = $2;
31+
if (version ~ /-rc/) {
32+
# Handle release candidate versions (e.g., v1.0.0-rc.1 -> v1.0.0-rc.2)
33+
split(version, parts, /-rc\./);
34+
rc_num = parts[2] + 1;
35+
print parts[1] "-rc." rc_num;
36+
}
37+
else {
38+
# Load the previous version and BUMP THE MINOR
39+
# Handle minor version bumps (e.g., v1.0.0 -> v1.1.0)
40+
split(version, ver_parts, /\./);
41+
ver_parts[2] = ver_parts[2] + 1;
42+
print ver_parts[1] "." ver_parts[2] ".0";
43+
}
44+
}')
45+
fi
4146

4247
# Update the project yaml file
4348
sed -i "s#^projectVersion:.*#projectVersion: ${version}#g" "${project_yaml}"

0 commit comments

Comments
 (0)