Skip to content

Commit 83ac986

Browse files
add swift package to updater
1 parent fb61848 commit 83ac986

File tree

1 file changed

+35
-10
lines changed

1 file changed

+35
-10
lines changed

scripts/update-cocoa.sh

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,52 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
file="$(dirname "$0")/../SentryCapacitor.podspec"
5-
content=$(cat $file)
6-
regex="('Sentry/HybridSDK', *)'([0-9\.]+)'"
7-
if ! [[ $content =~ $regex ]]; then
8-
echo "Failed to find the plugin version in $file"
9-
exit 1
10-
fi
4+
podFile="$(dirname "$0")/../SentryCapacitor.podspec"
5+
swiftFile="$(dirname "$0")/../Package.swift"
116

127
case $1 in
138
get-version)
14-
echo ${BASH_REMATCH[2]}
9+
if [[ -f "$podFile" ]]; then
10+
podContent=$(cat $podFile)
11+
podRegex="('Sentry/HybridSDK', *)'([0-9\.]+)'"
12+
if [[ $podContent =~ $podRegex ]]; then
13+
echo ${BASH_REMATCH[2]}
14+
exit 0
15+
fi
16+
fi
17+
echo "Failed to find sentry-cocoa version in either $podFile"
18+
exit 1
1519
;;
1620
get-repo)
1721
echo "https://github.com/getsentry/sentry-cocoa.git"
1822
;;
1923
set-version)
20-
newValue="${BASH_REMATCH[1]}'$2'"
21-
echo "${content/${BASH_REMATCH[0]}/$newValue}" >$file
24+
# Update podspec file
25+
if [[ -f "$podFile" ]]; then
26+
podContent=$(cat $podFile)
27+
podRegex="('Sentry/HybridSDK', *)'([0-9\.]+)'"
28+
if [[ $podContent =~ $podRegex ]]; then
29+
newValue="${BASH_REMATCH[1]}'$2'"
30+
echo "${podContent/${BASH_REMATCH[0]}/$newValue}" >$podFile
31+
echo "Updated $podFile with version $2"
32+
fi
33+
fi
34+
35+
# Update Package.swift file
36+
if [[ -f "$swiftFile" ]]; then
37+
echo "Updating $swiftFile"
38+
swiftContent=$(cat $swiftFile)
39+
swiftRegex='(getsentry\/sentry-cocoa\", from: \")([0-9.]+)'
40+
if [[ $swiftContent =~ $swiftRegex ]]; then
41+
newValue="${BASH_REMATCH[1]}$2"
42+
echo "${swiftContent/${BASH_REMATCH[0]}/$newValue}" >$swiftFile
43+
echo "Updated $swiftFile with version $2"
44+
fi
45+
fi
2246
;;
2347
*)
2448
echo "Unknown argument $1"
49+
echo "Usage: $0 {get-version|get-repo|set-version <version>}"
2550
exit 1
2651
;;
2752
esac

0 commit comments

Comments
 (0)