-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbump-version.sh
executable file
·57 lines (46 loc) · 1.5 KB
/
bump-version.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
57
#!/bin/bash
set -euo pipefail
git diff-index --quiet HEAD || { echo "error: dirty repository"; exit 1; }
current_version=$(tr -d '\n' < VERSION)
IFS='.' read -ra version_array <<< "$current_version"
major="${version_array[0]}"
minor="${version_array[1]}"
bugfix="${version_array[2]}"
action="${1:-0}"
if [[ "$action" == "major" ]]; then
major=$((major + 1))
elif [[ "$action" == "minor" ]]; then
minor=$((minor + 1))
elif [[ "$action" == "bugfix" ]]; then
bugfix=$((bugfix + 1))
else
echo "Expected argument: major, minor or bugfix"
exit 1
fi
# Ensure we won't leave a dirty repository if the script is interrupted.
trap 'git reset HEAD . > /dev/null && git checkout HEAD . > /dev/null' INT TERM HUP EXIT
new_version="$major.$minor.$bugfix"
echo "Bumping version to $new_version"
files=(
"VERSION"
"README.md"
"SimpleMDM-Swift.podspec"
)
echo
for file in "${files[@]}"; do
echo "Updating version in $file..."
sed -i '' -e "s/$current_version/$new_version/" "$file"
done
echo
echo "Updating documentation..."
swift doc generate Sources --module-name SimpleMDM-Swift --format html --output docs --base-url https://guillaumealgis.github.io/SimpleMDM-Swift/
echo
echo "Committing changes..."
git add .
git commit -m "Bump version $current_version -> $new_version"
git tag -m "$new_version" "$new_version"
git --no-pager show --summary
echo
echo "Don't forget to release the new version of the Pod by running"
echo " git push; git push --tags"
echo " pod trunk push SimpleMDM-Swift.podspec"