This repository has been archived by the owner on Aug 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate_release.sh
executable file
·58 lines (53 loc) · 2.2 KB
/
update_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
57
58
#!/bin/bash
# This script is just for me to update releases easier and is run from my Linux
# laptop. It's not part of the normal release, not copied on updates, and
# isn't necessary for installation.
commit=true
while [ $# -gt 0 ]; do
case $1 in
-n|--no-commit)
commit='' ;;
*)
echo "Unknown option, $1" >&2
exit 1
;;
esac; shift
done
cd $(realpath $(dirname $0))
if ! git status |& grep -qF 'nothing to commit, working tree clean'; then
echo 'Your working directory is dirty. Please commit changes.' >&2
exit 1
fi
read -p 'Version of the new update: ' new_version
if ! echo "$new_version" | grep -q '^[0-9]\.[0-9]\.[0-9]$'; then
echo "Version must match bare semver standards for major.minor.patch (e.g. 0.1.2)" >&2
exit 2
fi
if ! grep -qF " $new_version - " Update-ArcDPS.ps1; then
read -p 'Enter update text for the new version: ' update_text
update_text_lines=$(echo "$update_text" | fold -s -w68)
update_text_firstline=$(echo "$update_text_lines" | head -1)
if [ $(echo "$update_text_lines" | wc -l) -gt 1 ]; then
update_text_remainder=$(echo "$update_text_lines" | tail -n +2)
sed -i '/^ Version History:$/a'"\ $update_text_remainder" Update-ArcDPS.ps1
fi
sed -i '/^ Version History:$/a'"\ $new_version - $update_text_firstline" Update-ArcDPS.ps1
fi
sed -i 's/\$scriptversion = .*/\$scriptversion = '"'$new_version'"'/' Update-ArcDPS.ps1
sed -i 's/SCRIPT VERSION: .*/SCRIPT VERSION: '"$new_version"'/' Update-ArcDPS.ps1
sed -i 's/\/[0-9]\.[0-9]\.[0-9]\//\/'"$new_version"'\//g' Bootstrap-ArcDPS.ps1
sed -i 's/\$installing_version = .*/\$installing_version = '"'$new_version'"'/' Bootstrap-ArcDPS.ps1
sed -i 's/\/[0-9]\.[0-9]\.[0-9]\//\/'"$new_version"'\//g' docs/README.md
if [ -n "$commit" ]; then
git add Update-ArcDPS.ps1
git add Bootstrap-ArcDPS.ps1
git add docs/README.md
git commit -m "Bumping to version $new_version"
if [ -n "$update_text" ]; then
git tag -s $new_version -m "Releasing version $new_version" -m "$update_text"
else
git tag -s $new_version -m "Releasing version $new_version"
fi
git push
git push --tags
fi