update-on-release #157
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Update YugabyteDB version" | |
on: | |
repository_dispatch: | |
types: | |
- update-on-release | |
jobs: | |
update-version: | |
if: github.event.client_payload.prerelease == 'false' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: "Configure git" | |
run: | | |
git config user.name 'YugaByte CI' | |
git config user.email '[email protected]' | |
- name: "Extract version number from tag" | |
id: extract-version | |
run: | | |
tag_name="${{ github.event.client_payload.release }}" | |
echo "Extracting version number from the tag '${tag_name}'." | |
version_number="${tag_name/v/}" | |
# Keep dots and count the string length | |
dot_count="$(res="${version_number//[^.]/}"; echo "${#res}")" | |
if [[ "${dot_count}" -eq 2 ]]; then | |
version_number="${version_number}.0" | |
fi | |
if [[ "$(res="${version_number//[^.]/}"; echo "${#res}")" -ne 3 ]]; then | |
echo "The tag '${tag_name}' is invalid. Expected format: 'v1.2.3' or 'v1.2.3.5'." 1>&2 | |
exit 1 | |
fi | |
echo "Extracted the version number '${version_number}'." | |
echo "yb_version=${version_number}" >> "$GITHUB_ENV" | |
- name: "Switch to correct branch" | |
id: switch-branch | |
run: | | |
# We use the yb_release_train as the branch in this repo | |
# This allows us to map multiple '2.2' release branches to a single set of helm charts | |
branch_name="${{github.event.client_payload.yb_release_train}}" | |
if git branch -r | grep -qE "origin/${branch_name}$"; then | |
# branch already exists so check it out | |
git checkout ${branch_name} | |
else | |
# First time creating charts for this release | |
# This won't start working 'correctly' till 2.4 | |
# till then, we will need to manually create the new branches and seed them with | |
# sufficiently old version numbers (the update script won't go down versions) | |
git checkout -b ${branch_name} origin/master | |
fi | |
echo "Extracted the branch: '${branch_name}'" | |
echo "yb_branch=${branch_name}" >> "$GITHUB_ENV" | |
- name: "Check python version and install dependencies" | |
run: | | |
python3 --version | |
pip3 install requests | |
- name: "Update the version" | |
id: update-version | |
continue-on-error: true | |
run: | | |
.ci/update_version.sh "${yb_version}" | |
- name: "Push the changes" | |
if: steps.update-version.outcome == 'success' | |
run: | | |
git status | |
git diff | |
git add ./stable/yugabyte/Chart.yaml ./stable/yugaware/Chart.yaml \ | |
./stable/yugabyte/values.yaml ./stable/yugaware/values.yaml ./stable/yugabyte/app-readme.md | |
git commit -m "Update the version to ${yb_version}" | |
git push origin "${yb_branch}" | |
- name: "Show git status in case of failure" | |
if: steps.update-version.outcome == 'failure' | |
run: | | |
git status | |
git diff | |
exit 1 | |
- name: "Switch to master branch" | |
id: switch-to-master-branch | |
run: | | |
git checkout master | |
- name: "Update the master version if needed." | |
id: update-master-version | |
continue-on-error: true | |
run: | | |
# Following script updates files only if higher version is passed. | |
.ci/update_version.sh "${yb_version}" | |
- name: "Push the changes to master branch" | |
if: steps.update-master-version.outcome == 'success' | |
run: | | |
git status | |
git diff | |
git add ./stable/yugabyte/Chart.yaml ./stable/yugaware/Chart.yaml \ | |
./stable/yugabyte/values.yaml ./stable/yugaware/values.yaml ./stable/yugabyte/app-readme.md | |
git commit -m "Update the version to ${yb_version}" | |
git push origin HEAD:master | |
- name: "Show git status in case of failure" | |
if: steps.update-master-version.outcome == 'failure' | |
run: | | |
git status | |
git diff | |
exit 1 |