-
Notifications
You must be signed in to change notification settings - Fork 5
/
pod-release.sh
executable file
·56 lines (43 loc) · 1.61 KB
/
pod-release.sh
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
#!/bin/bash
# release.sh
# NOTE: This is the old way releasing this framework to Cocoapods.
# from now on install gem install bundler && brew install git-flow
# and then run bundle exec fastlane release_production framework:SHSearchBar version:"<YOUR_VERSION_HERE>"
set -x # verbose loggging with variable expansion
set -e # switch ON exit on errors
cleanup() {
echo "Script exitted with code $?"
}
trap "cleanup" EXIT
NEW_APP_VERSION=$1
PODSPEC=$2
# Check for missing app version
if [[ $# -eq 0 ]]; then
echo "Usage: $0 <new app version> <path to podspec> <spec repo name>" >&2
exit 1
fi
# Allows only 1-3 digit semantic versioning strings
if [[ ! $NEW_APP_VERSION =~ ^([0-9]+\.){1,2}([0-9]+)$ ]]; then
echo "Permitted version formats: $0 1.2.3 ./FrameworkName.podspec flinc-specs || $0 1.2 ./FrameworkName.podspec SpecRepoName" >&2
exit 1
fi
# Check for file existence
if [[ ! -e "$PODSPEC" ]]; then
echo "Podspec file $PODSPEC does not exist!"
exit 1
fi
# Check if the app builds
pod lib lint --allow-warnings
# Update podspec version - rplace in place (-i) create NO backup file ('')
CURRENT_VERSION=$(sed -n '/\(s.version *= *\)/ p' $PODSPEC | awk -F\' '{print $2}')
sed -i '' -e "s/$CURRENT_VERSION/$NEW_APP_VERSION/g" "$PODSPEC"
# Command chain I
git add "$PODSPEC" && git commit -m "Release $NEW_APP_VERSION" && git tag -f "$NEW_APP_VERSION" && git push
# Opt out of exit on fail - git push --tag sometimes returns non-zero exit state but successfully pushed the new tag
set +e
# Command chain II
git push --tag
# Opt in again to exit on error
set -e
# Command chain III
pod trunk push "$PODSPEC"