-
Notifications
You must be signed in to change notification settings - Fork 6
63 lines (63 loc) · 2.65 KB
/
update-formula-version.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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@v2
- 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.tag }}"
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 "::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