|
1 | 1 | #!/usr/bin/env bash |
2 | 2 | set -euo pipefail |
3 | 3 |
|
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" |
11 | 6 |
|
12 | 7 | case $1 in |
13 | 8 | 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 |
15 | 19 | ;; |
16 | 20 | get-repo) |
17 | 21 | echo "https://github.com/getsentry/sentry-cocoa.git" |
18 | 22 | ;; |
19 | 23 | 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 |
22 | 46 | ;; |
23 | 47 | *) |
24 | 48 | echo "Unknown argument $1" |
| 49 | + echo "Usage: $0 {get-version|get-repo|set-version <version>}" |
25 | 50 | exit 1 |
26 | 51 | ;; |
27 | 52 | esac |
0 commit comments