build: make sync-version.sh auto-increment build number
This commit is contained in:
parent
d1bf9a76c8
commit
b6c64db6f8
@ -1,9 +1,21 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Extract current version from pubspec.yaml if not provided
|
if [ -n "$1" ]; then
|
||||||
# but here the user requested: version: 1.1.5+2
|
TARGET_VERSION="$1"
|
||||||
TARGET_VERSION="1.1.5+2"
|
else
|
||||||
|
# Extract current version from pubspec.yaml
|
||||||
|
CURRENT_VERSION=$(grep "^version: " pubspec.yaml | awk '{print $2}')
|
||||||
|
|
||||||
|
if [[ "$CURRENT_VERSION" == *"+"* ]]; then
|
||||||
|
BASE_VERSION=$(echo "$CURRENT_VERSION" | cut -d'+' -f1)
|
||||||
|
BUILD_NUM=$(echo "$CURRENT_VERSION" | cut -d'+' -f2)
|
||||||
|
NEXT_BUILD_NUM=$((BUILD_NUM + 1))
|
||||||
|
TARGET_VERSION="${BASE_VERSION}+${NEXT_BUILD_NUM}"
|
||||||
|
else
|
||||||
|
TARGET_VERSION="${CURRENT_VERSION}+1"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
DATE=$(date +%Y-%m-%d)
|
DATE=$(date +%Y-%m-%d)
|
||||||
COMMIT=$(git rev-parse --short HEAD)
|
COMMIT=$(git rev-parse --short HEAD)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user