Implement settings
This commit is contained in:
41
flutter/_utils/inc_buildnum.sh
Executable file
41
flutter/_utils/inc_buildnum.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
# shellcheck disable=SC2002 # disable useless-cat warning
|
||||
|
||||
set -o nounset # disallow usage of unset vars ( set -u )
|
||||
set -o errexit # Exit immediately if a pipeline returns non-zero. ( set -e )
|
||||
set -o errtrace # Allow the above trap be inherited by all functions in the script. ( set -E )
|
||||
set -o pipefail # Return value of a pipeline is the value of the last (rightmost) command to exit with a non-zero status
|
||||
IFS=$'\n\t' # Set $IFS to only newline and tab.
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
cr=$'\n'
|
||||
|
||||
function black() { if [ -t 1 ] && [ -n "$(tput colors)" ] && [ "$(tput colors)" -ge 8 ]; then echo -e "\\x1B[30m$1\\x1B[0m"; else echo "$1"; fi }
|
||||
function red() { if [ -t 1 ] && [ -n "$(tput colors)" ] && [ "$(tput colors)" -ge 8 ]; then echo -e "\\x1B[31m$1\\x1B[0m"; else echo "$1"; fi; }
|
||||
function green() { if [ -t 1 ] && [ -n "$(tput colors)" ] && [ "$(tput colors)" -ge 8 ]; then echo -e "\\x1B[32m$1\\x1B[0m"; else echo "$1"; fi; }
|
||||
function yellow(){ if [ -t 1 ] && [ -n "$(tput colors)" ] && [ "$(tput colors)" -ge 8 ]; then echo -e "\\x1B[33m$1\\x1B[0m"; else echo "$1"; fi; }
|
||||
function blue() { if [ -t 1 ] && [ -n "$(tput colors)" ] && [ "$(tput colors)" -ge 8 ]; then echo -e "\\x1B[34m$1\\x1B[0m"; else echo "$1"; fi; }
|
||||
function purple(){ if [ -t 1 ] && [ -n "$(tput colors)" ] && [ "$(tput colors)" -ge 8 ]; then echo -e "\\x1B[35m$1\\x1B[0m"; else echo "$1"; fi; }
|
||||
function cyan() { if [ -t 1 ] && [ -n "$(tput colors)" ] && [ "$(tput colors)" -ge 8 ]; then echo -e "\\x1B[36m$1\\x1B[0m"; else echo "$1"; fi; }
|
||||
function white() { if [ -t 1 ] && [ -n "$(tput colors)" ] && [ "$(tput colors)" -ge 8 ]; then echo -e "\\x1B[37m$1\\x1B[0m"; else echo "$1"; fi; }
|
||||
|
||||
|
||||
|
||||
|
||||
path_to_pubspec="$(dirname "$0")/../pubspec.yaml"
|
||||
current_version=$(awk '/^version:/ {print $2}' $path_to_pubspec)
|
||||
current_version_without_build=$(echo "$current_version" | sed 's/\+.*//')
|
||||
|
||||
gitcount="$(git log | grep "^commit" | wc -l | xargs)"
|
||||
new_version="$current_version_without_build+$gitcount"
|
||||
|
||||
echo "Setting pubspec.yaml version $current_version to $new_version"
|
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# macOS sed (requires a space after -i)
|
||||
sed -i '' -e "s/version: $current_version/version: $new_version/g" $path_to_pubspec
|
||||
else
|
||||
# GNU sed (requires no space after -i)
|
||||
sed -i'' -e "s/version: $current_version/version: $new_version/g" $path_to_pubspec
|
||||
fi
|
Reference in New Issue
Block a user