Skip to content

Commit fa4ee4d

Browse files
committed
Added version updating script
Adapted a version updating script from the mapbox-directions-swift repository, for use when releasing a new version.
1 parent f98cade commit fa4ee4d

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

scripts/update-version.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
set -o pipefail
5+
set -u
6+
7+
function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; }
8+
function finish { >&2 echo -en "\033[0m"; }
9+
trap finish EXIT
10+
11+
if [ $# -eq 0 ]; then
12+
echo "Usage: v<semantic version>"
13+
exit 1
14+
fi
15+
16+
SEM_VERSION=$1
17+
SEM_VERSION=${SEM_VERSION/#v}
18+
SHORT_VERSION=${SEM_VERSION%-*}
19+
MINOR_VERSION=${SEM_VERSION%.*}
20+
YEAR=$(date '+%Y')
21+
22+
step "Version ${SEM_VERSION}"
23+
24+
step "Updating Xcode targets to version ${SHORT_VERSION}"
25+
26+
xcrun agvtool bump -all
27+
xcrun agvtool new-marketing-version "${SHORT_VERSION}"
28+
29+
step "Updating CocoaPods podspecs to version ${SEM_VERSION}"
30+
31+
find . -type f -name '*.podspec' -exec sed -i '' "s/^ *s.version *=.*$/ s.version = \"${SEM_VERSION}\"/" {} +
32+
33+
# Skip updating the installation instructions for patch releases or prereleases.
34+
if [[ $SHORT_VERSION == $SEM_VERSION && $SHORT_VERSION == *.0 ]]; then
35+
step "Updating readmes to version ${SEM_VERSION}"
36+
sed -i '' -E "s/~> *[^']+/~> ${MINOR_VERSION}/g; s/.git\", from: \"*[^\"]+/.git\", from: \"${SEM_VERSION}/g" README.md
37+
elif [[ $SHORT_VERSION != $SEM_VERSION ]]; then
38+
step "Updating readmes to version ${SEM_VERSION}"
39+
sed -i '' -E "s/:tag => 'v[^']+'/:tag => 'v${SEM_VERSION}'/g; s/\"mapbox\/turf-swift\" \"v[^\"]+\"/\"mapbox\/turf-swift\" \"v${SEM_VERSION}\"/g; s/\.exact\(\"*[^\"]+/.exact(\"${SEM_VERSION}/g" README.md
40+
fi
41+
42+
step "Updating copyright year to ${YEAR}"
43+
44+
sed -i '' -E "s/© ([0-9]{4})[–-][0-9]{4}/© \\1–${YEAR}/g" LICENSE.md

0 commit comments

Comments
 (0)