Skip to content

Commit b0a7066

Browse files
authored
chore(ci): Add Maestro update script in the workflow (#4777)
* chore(ci): Add Maestro update script in the workflow * Only match non-preview versions * skip changelog * skip the tag prefix
1 parent 4b49b57 commit b0a7066

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

.github/workflows/update-deps.yml

+11
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,14 @@ jobs:
7575
changelog-entry: false
7676
secrets:
7777
api-token: ${{ secrets.CI_DEPLOY_KEY }}
78+
79+
maestro:
80+
uses: getsentry/github-workflows/.github/workflows/updater.yml@v2
81+
with:
82+
path: scripts/update-maestro.sh
83+
name: Maestro
84+
pattern: '^v[0-9.]+$' # only match non-preview versions
85+
pr-strategy: update
86+
changelog-entry: false
87+
secrets:
88+
api-token: ${{ secrets.CI_DEPLOY_KEY }}

scripts/update-maestro.sh

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [ $# -lt 1 ]; then
5+
echo "Usage: $0 {get-version|get-repo|set-version <new_version>}"
6+
exit 1
7+
fi
8+
9+
# yml files to search and update MAESTRO_VERSION
10+
files=(
11+
"$(dirname "$0")/../.github/workflows/e2e.yml"
12+
"$(dirname "$0")/../.github/workflows/sample-application.yml"
13+
)
14+
15+
# Regex to match lines like: MAESTRO_VERSION: '1.40.0'
16+
regex="MAESTRO_VERSION: ['\"]([0-9]+\.[0-9]+\.[0-9]+)['\"]"
17+
18+
# maestro has a prefix in the repo, but we want to remove it for the version in the yml files
19+
tagPrefix='v'
20+
21+
first_match=""
22+
23+
for file in "${files[@]}"; do
24+
while IFS= read -r line; do
25+
if [[ $line =~ $regex ]]; then
26+
first_match="${BASH_REMATCH[1]}"
27+
break 2
28+
fi
29+
done < "$file"
30+
done
31+
32+
if [[ -z "$first_match" && "$1" != "get-repo" ]]; then
33+
echo "Failed to find the MAESTRO_VERSION in any of the following files:"
34+
for file in "${files[@]}"; do
35+
echo " - $file"
36+
done
37+
exit 1
38+
fi
39+
40+
case $1 in
41+
get-version)
42+
echo "$first_match"
43+
;;
44+
45+
get-repo)
46+
echo "https://github.com/mobile-dev-inc/Maestro.git"
47+
;;
48+
49+
set-version)
50+
if [ $# -ne 2 ]; then
51+
echo "Usage: $0 set-version <new_version>"
52+
exit 1
53+
fi
54+
new_version=$2
55+
# remove $tagPrefix from the $version by skipping the first `strlen($tagPrefix)` characters
56+
if [[ "$new_version" == "$tagPrefix"* ]]; then
57+
new_version="${new_version:${#tagPrefix}}"
58+
fi
59+
for file in "${files[@]}"; do
60+
updated=false
61+
tmpfile=$(mktemp)
62+
while IFS= read -r line; do
63+
if [[ $line =~ $regex ]]; then
64+
new_line=" MAESTRO_VERSION: '${new_version}'"
65+
echo "$new_line" >> "$tmpfile"
66+
updated=true
67+
else
68+
echo "$line" >> "$tmpfile"
69+
fi
70+
done < "$file"
71+
if $updated; then
72+
mv "$tmpfile" "$file"
73+
echo "✅ Updated $file to MAESTRO_VERSION: '$new_version'"
74+
else
75+
rm "$tmpfile"
76+
echo "⚠️ No MAESTRO_VERSION found in $file"
77+
fi
78+
done
79+
;;
80+
81+
*)
82+
echo "Unknown argument $1"
83+
echo "Usage: $0 {get-version|get-repo|set-version <new_version>}"
84+
exit 1
85+
;;
86+
esac

0 commit comments

Comments
 (0)