44 workflow_call :
55 inputs :
66 is_helm_chart :
7- description : ' Specify if this is a Helm Chart repository'
7+ description : " Specify if this is a Helm Chart repository"
88 required : false
99 type : boolean
1010 default : false
1111 release_version :
1212 type : string
13- description : ' The version to release'
13+ description : " The version to release"
1414 required : true
1515 skip_branch_check :
16- description : ' Skip the branch check'
16+ description : " Skip the branch check"
1717 required : false
1818 type : boolean
1919 default : false
2020 base_branch :
21- description : ' The base branch to use'
21+ description : " The base branch to use"
2222 required : false
2323 type : string
2424 default : main
@@ -28,11 +28,10 @@ permissions:
2828 pull-requests : write
2929
3030concurrency :
31- group : ' ${{ github.workflow }}-${{ github.ref || github.head_ref }}'
31+ group : " ${{ github.workflow }}-${{ github.ref || github.head_ref }}"
3232 cancel-in-progress : true
3333
3434env :
35- GA_VERSION : " main"
3635 GITHUB_USER : " datavisyn-bot"
3736 WORKFLOW_BRANCH : " main"
3837 GITHUB_TOKEN : ${{ secrets.DATAVISYN_BOT_REPO_TOKEN }}
@@ -61,37 +60,43 @@ jobs:
6160 echo "Error: base_branch must be 'main' when skip_branch_check is false."
6261 exit 1
6362 fi
64- # checkout specific repository
65- - name : checkout repository
63+ - name : Checkout repository
6664 uses : actions/checkout@v5
6765 with :
6866 token : ${{ secrets.CHECKOUT_TOKEN || github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
69- # checkout this workflow repository to get actions
70- - name : checkout github-workflows repository
67+ - name : Checkout github-workflows repository
7168 uses : actions/checkout@v5
7269 with :
7370 repository : datavisyn/github-workflows
7471 ref : ${{ env.WORKFLOW_BRANCH }}
7572 path : ./tmp/github-workflows
76- - name : check actor
73+ - name : Check actor
7774 uses : ./tmp/github-workflows/.github/actions/check-actor
7875 with :
7976 dv_devops : ${{ vars.DV_DEVOPS }}
8077 allowed_users : ${{ vars.DV_CAN_RELEASE }}
8178 actor : ${{ github.actor }}
8279 qms_are_allowed : " false"
8380
84- - name : check for package.json
81+ - name : Check for package.json
8582 id : check-package-json
8683 run : |
8784 if [ -f "package.json" ]; then
88- echo "is_package_json =true" >> "$GITHUB_OUTPUT"
85+ echo "has_package_json =true" >> "$GITHUB_OUTPUT"
8986 else
90- echo "is_package_json =false" >> "$GITHUB_OUTPUT"
87+ echo "has_package_json =false" >> "$GITHUB_OUTPUT"
9188 fi
9289
93- - name : get release version from input
94- if : ${{ inputs.skip_branch_check == false }}
90+ - name : Check for pyproject.toml
91+ id : check-pyproject-toml
92+ run : |
93+ if [ -f "pyproject.toml" ]; then
94+ echo "has_pyproject_toml=true" >> "$GITHUB_OUTPUT"
95+ else
96+ echo "has_pyproject_toml=false" >> "$GITHUB_OUTPUT"
97+ fi
98+
99+ - name : Get release version from input
95100 id : get-release-version-from-input
96101 run : |
97102 input_release_version="${{ inputs.release_version }}"
@@ -102,27 +107,26 @@ jobs:
102107 exit 1
103108 fi
104109
105- # Check if package.json exists and validate the version against it
106- if [ "${{ steps.check-package-json.outputs.is_package_json }}" == "true" ]; then
107- file_release_version="$(jq -r '.version' package.json | cut -d '-' -f 1)"
108- file_release_version="${file_release_version//[^0-9.]}"
109- echo "file_release_version=$file_release_version"
110- file_major=$(echo "$file_release_version" | cut -d'.' -f1)
111- file_minor=$(echo "$file_release_version" | cut -d'.' -f2)
112- file_patch=$(echo "$file_release_version" | cut -d'.' -f3)
110+ # Extract major, minor, and patch versions of the input version
111+ input_major=$(echo "$input_release_version" | cut -d'.' -f1)
112+ input_minor=$(echo "$input_release_version" | cut -d'.' -f2)
113+ input_patch=$(echo "$input_release_version" | cut -d'.' -f3)
113114
114- echo "Stable release version: $file_major.$file_minor.$file_patch"
115-
116- input_major=$(echo "$input_release_version" | cut -d'.' -f1)
117- input_minor=$(echo "$input_release_version" | cut -d'.' -f2)
118- input_patch=$(echo "$input_release_version" | cut -d'.' -f3)
115+ # Utility function to validate versioning rules
116+ validate_version() {
117+ input_major=$1
118+ input_minor=$2
119+ input_patch=$3
120+ file_major=$4
121+ file_minor=$5
122+ file_patch=$6
119123
120124 if [ "$input_major" -eq "$file_major" ]; then
121125 if [ "$input_minor" -eq "$file_minor" ]; then
122126 if [ "$input_patch" -eq "$file_patch" ]; then
123127 echo "Valid patch version input"
124128 else
125- echo "Error: Patch version must match the package.json version without the -SNAPSHOT suffix."
129+ echo "Error: Patch version must match the file version without the -SNAPSHOT or .dev0 suffix."
126130 exit 1
127131 fi
128132 elif [ "$input_minor" -gt "$file_minor" ] && [ "$input_patch" -eq 0 ]; then
@@ -137,21 +141,54 @@ jobs:
137141 echo "Error: Version input is invalid based on semantic versioning rules."
138142 exit 1
139143 fi
144+ }
145+
146+ # Call the function for package.json (if needed)
147+ if [ "${{ steps.check-package-json.outputs.has_package_json }}" == "true" ]; then
148+ file_release_version="$(jq -r '.version' package.json | cut -d '-' -f 1)"
149+ file_release_version=${file_release_version//-SNAPSHOT/}
150+ echo "file_release_version=$file_release_version"
151+ file_major=$(echo "$file_release_version" | cut -d'.' -f1)
152+ file_minor=$(echo "$file_release_version" | cut -d'.' -f2)
153+ file_patch=$(echo "$file_release_version" | cut -d'.' -f3)
154+
155+ echo "Validating package.json version: $file_major.$file_minor.$file_patch"
156+
157+ validate_version "$input_major" "$input_minor" "$input_patch" "$file_major" "$file_minor" "$file_patch"
158+ fi
159+
160+ # Call the function for pyproject.toml (if needed)
161+ if [ "${{ steps.check-pyproject-toml.outputs.has_pyproject_toml }}" == "true" ]; then
162+ file_release_version="$(grep -oP 'version\s*=\s*[\"\x27]\K[^\"\x27]+' pyproject.toml | cut -d '-' -f 1)"
163+ file_release_version=${file_release_version//.dev0/}
164+ echo "file_release_version=$file_release_version"
165+ file_major=$(echo "$file_release_version" | cut -d'.' -f1)
166+ file_minor=$(echo "$file_release_version" | cut -d'.' -f2)
167+ file_patch=$(echo "$file_release_version" | cut -d'.' -f3)
168+
169+ echo "Validating pyproject.toml version: $file_major.$file_minor.$file_patch"
170+
171+ validate_version "$input_major" "$input_minor" "$input_patch" "$file_major" "$file_minor" "$file_patch"
140172 fi
141173
142174 echo "New version is $input_major.$input_minor.$input_patch"
143175 echo "RELEASE_VERSION=$input_release_version" >> "$GITHUB_ENV"
144-
145- - name : create release branch
176+
177+ - name : Create release branch
146178 run : |
147179 git config user.name "$GITHUB_ACTOR"
148180 git config user.email "<>"
149181 git checkout -b release-"$RELEASE_VERSION"
150182 - name : Update package.json
151- if : ${{ steps.check-package-json.outputs.is_package_json == 'true' }}
183+ if : ${{ steps.check-package-json.outputs.has_package_json == 'true' }}
152184 run : |
153185 sed -i "s/^\(\s*\)\"version\".*/\1\"version\": \"$RELEASE_VERSION\",/" package.json
154186 git add package.json
187+ - name : Update pyproject.toml
188+ if : ${{ steps.check-pyproject-toml.outputs.has_pyproject_toml == 'true' }}
189+ run : |
190+ sed -i "s/^version = \".*\"/version = \"$RELEASE_VERSION\"/" pyproject.toml
191+ git add pyproject.toml
155192 - name : Add Helm repository
156193 if : ${{ inputs.is_helm_chart == true }}
157194 run : |
@@ -160,7 +197,7 @@ jobs:
160197 # TODO: make this an input of the workflow.
161198 helm repo add apache-airflow https://airflow.apache.org
162199 helm repo add bitnami https://charts.bitnami.com/bitnami
163- - name : change charts and subcharts version
200+ - name : Change charts and subcharts version
164201 if : ${{ inputs.is_helm_chart == true }}
165202 run : |
166203 cd deploy/helm
@@ -190,7 +227,7 @@ jobs:
190227 done
191228
192229 git add .
193- - name : update imageTag and repository_tag in values files
230+ - name : Update imageTag and repository_tag in values files
194231 if : ${{ inputs.is_helm_chart == true }}
195232 run : |
196233 cd deploy/helm
@@ -255,12 +292,12 @@ jobs:
255292 -d "$(jq -n --arg tag_name "$TAG_NAME" \
256293 --arg target_commitish "${{ github.ref_name }}" \
257294 '{tag_name: $tag_name, target_commitish: $target_commitish}')")
258-
295+
259296 RELEASE_NOTES=$(echo "$response" | jq -r '.body')
260297
261- echo "$RELEASE_NOTES" > release_notes.txt
298+ echo "$RELEASE_NOTES" > release_notes.txt
262299
263- - name : create pr
300+ - name : Create pr
264301 run : |
265302 PR_NOTES=$(cat release_notes.txt)
266303 curl -L \
0 commit comments