forked from freedomofpress/securedrop-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_version.sh
executable file
·31 lines (25 loc) · 1.06 KB
/
update_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
#!/bin/bash
## Usage: ./update_version.sh <version>
set -e
readonly NEW_VERSION=$1
if [ -z "$NEW_VERSION" ]; then
echo "You must specify the new version!"
exit 1
fi
# Get the old version from securedrop_client/__init__.py
old_version_regex='^__version__ = "(.*)"$'
[[ "$(cat securedrop_client/__init__.py)" =~ $old_version_regex ]]
OLD_VERSION=${BASH_REMATCH[1]}
if [ -z "$OLD_VERSION" ]; then
echo "Couldn't find the old version: does this script need to be updated?"
exit 1
fi
# Update the version in securedrop_client/__init__.py and setup.py
if [[ "$OSTYPE" == "darwin"* ]]; then
# The empty '' after sed -i is required on macOS to indicate no backup file should be saved.
sed -i '' "s@$(echo "${OLD_VERSION}" | sed 's/\./\\./g')@$NEW_VERSION@g" securedrop_client/__init__.py
sed -i '' "s@$(echo "${OLD_VERSION}" | sed 's/\./\\./g')@$NEW_VERSION@g" setup.py
else
sed -i "s@$(echo "${OLD_VERSION}" | sed 's/\./\\./g')@$NEW_VERSION@g" securedrop_client/__init__.py
sed -i "s@$(echo "${OLD_VERSION}" | sed 's/\./\\./g')@$NEW_VERSION@g" setup.py
fi