Skip to content

update-on-release

update-on-release #60

name: "Update formula version"
on:
repository_dispatch:
types:
- update-on-release
jobs:
update-version:
if: github.event.client_payload.prerelease == 'false'
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- 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: |
release_name="${{ github.event.client_payload.release }}"
echo "Extracting version number from the release_tag '${release_name}'."
version_number="${release_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 '${release_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 "::set-output name=yb_version::${version_number}"
- name: "Update the version of yugabytedb formula"
id: update-yb-formula
run: |
.ci/update_formula_version.sh '${{steps.extract-version.outputs.yb_version}}'
- name: "Run brew audit on changed formula files"
id: run-audit
run: |
for file in ${{steps.update-yb-formula.outputs.modified_files}}; do
if [[ "${file}" =~ .*\/Formula\/yugabytedb(@[0-9]+\.[0-9]+)?\.rb ]]; then
brew audit --strict --online "${file}"
fi
done
- name: "Push the changes"
run: |
git status
git diff
git add ${{steps.update-yb-formula.outputs.modified_files}}
git commit -m "Update the version to ${{steps.extract-version.outputs.yb_version}}"
git push origin ${{ github.ref }}
- name: "Push the changes to a branch"
if: failure() && steps.run-audit.outcome == 'failure'
run: |
git status
git diff
git add ${{steps.update-yb-formula.outputs.modified_files}}
git commit -m "Update the version to ${{steps.extract-version.outputs.yb_version}}"
branch_name="update-${{steps.extract-version.outputs.yb_version}}-${{github.run_id}}"
git push origin ${{ github.ref }}:${branch_name}
echo "The 'run-audit' step for modified files has failed, please check the logs of 'audit-run' step for more details" 1>&2
echo "The modified files are pushed to https://github.com/${{github.repository}}/tree/${branch_name}" 1>&2
exit 1