update-on-release #69
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 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 "yb_version=${version_number}" >> "$GITHUB_ENV" | |
- name: "Update the version of yugabytedb formula" | |
id: update-yb-formula | |
run: | | |
.ci/update_formula_version.sh "${yb_version}" | |
- name: "Run brew audit on changed formula files" | |
id: run-audit | |
run: | | |
# https://github.com/orgs/Homebrew/discussions/4864 | |
brew tap-new homebrew-releaser/test --no-git | |
for file in ${{steps.update-yb-formula.outputs.modified_files}}; do | |
if [[ "${file}" =~ .*\/Formula\/yugabytedb(@[0-9]+\.[0-9]+)?\.rb ]]; then | |
cp -r ${file} $(brew --repository)/Library/Taps/homebrew-releaser/homebrew-test/Formula/. | |
brew audit --strict --online --formula "$(basename ${file%.rb})" | |
fi | |
done | |
brew untap homebrew-releaser/test | |
- name: "Push the changes" | |
id: push-changes | |
run: | | |
git status | |
git diff | |
git add ${{steps.update-yb-formula.outputs.modified_files}} | |
git commit -m "Update the version to ${yb_version}" | |
git push origin ${{ github.ref }} | |
- name: "Push the changes to a branch" | |
if: failure() && (steps.run-audit.outcome == 'failure' || steps.push-changes.outcome == 'failure') | |
run: | | |
git status | |
git diff | |
git add ${{steps.update-yb-formula.outputs.modified_files}} | |
git commit -m "Update the version to ${yb_version}" | |
branch_name="update-${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 |