11#! /usr/bin/env bash
22
3- # Bump the Chainloop project version to the next minor version to the version defined .chainloop.yml
3+ # Update the Chainloop project version in .chainloop.yml to the provided version + "+next"
44
55set -e
66
77die () {
88 echo >&2 " $@ "
9- echo " usage: bump-project-version.sh [configFile]"
9+ echo " usage: bump-project-version.sh <version> [configFile]"
1010 exit 1
1111}
1212
@@ -15,35 +15,18 @@ if [[ -n "${DEBUG}" ]]; then
1515 set -x
1616fi
1717
18+ [ " $# " -ge 1 ] || die " Version argument is required"
19+
20+ version=" ${1} "
1821project_yaml=" .chainloop.yml"
1922# manual override
20- if [[ -n " ${1 } " ]]; then
21- project_yaml=" ${1 } "
23+ if [[ -n " ${2 } " ]]; then
24+ project_yaml=" ${2 } "
2225fi
2326
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
27+ # Append "+next" to the version
28+ version_with_next=" ${version} +next"
4629
4730# Update the project yaml file
48- sed -i " s#^projectVersion:.*#projectVersion: ${version } #g" " ${project_yaml} "
31+ sed -i " s#^projectVersion:.*#projectVersion: ${version_with_next } #g" " ${project_yaml} "
4932
0 commit comments