|
19 | 19 |
|
20 | 20 |
|
21 | 21 | ## Usage |
22 | | -# bash update-version.sh <type> |
23 | | -# where <type> is either `major`, `minor`, `patch` |
| 22 | +# bash update-version.sh |
| 23 | +# Promotes patch version, version format : v<Year>.<Month>.<patch> |
24 | 24 |
|
25 | 25 | set -e |
26 | 26 |
|
27 | | -# Grab argument for release type |
28 | | -RELEASE_TYPE=$1 |
| 27 | +# Overwrite argument value to always trigger a patch release |
| 28 | +RELEASE_TYPE="patch" |
29 | 29 |
|
30 | 30 | # Get current version and calculate next versions |
31 | | -CURRENT_TAG=`git tag | grep -xE 'v[0-9\.]+' | sort --version-sort | tail -n 1 | tr -d 'v'` |
| 31 | +CURRENT_TAG=`git tag | grep -xE "v$(date '+%Y\.%m')\.[0-9]+" | sort --version-sort | tail -n 1 | tr -d 'v'` |
| 32 | +# In case no tag exists for this month |
| 33 | +if [ -z "${CURRENT_TAG}" ]; then |
| 34 | + CURRENT_TAG="$(date '+%Y.%m').-1" |
| 35 | +fi |
32 | 36 | CURRENT_MAJOR=`echo $CURRENT_TAG | awk '{split($0, a, "."); print a[1]}'` |
33 | 37 | CURRENT_MINOR=`echo $CURRENT_TAG | awk '{split($0, a, "."); print a[2]}'` |
34 | 38 | CURRENT_PATCH=`echo $CURRENT_TAG | awk '{split($0, a, "."); print a[3]}'` |
35 | | -CURRENT_SHORT_TAG=${CURRENT_MAJOR}.${CURRENT_MINOR} |
36 | | -NEXT_MAJOR=$((CURRENT_MAJOR + 1)) |
37 | | -NEXT_MINOR=$((CURRENT_MINOR + 1)) |
38 | 39 | NEXT_PATCH=$((CURRENT_PATCH + 1)) |
39 | 40 | NEXT_FULL_TAG="" |
40 | 41 | NEXT_SHORT_TAG="" |
41 | 42 |
|
42 | | -# Determine release type |
43 | | -if [ "$RELEASE_TYPE" == "major" ]; then |
44 | | - NEXT_FULL_TAG="${NEXT_MAJOR}.0.0" |
45 | | - NEXT_SHORT_TAG="${NEXT_MAJOR}.0" |
46 | | -elif [ "$RELEASE_TYPE" == "minor" ]; then |
47 | | - NEXT_FULL_TAG="${CURRENT_MAJOR}.${NEXT_MINOR}.0" |
48 | | - NEXT_SHORT_TAG="${CURRENT_MAJOR}.${NEXT_MINOR}" |
49 | | -elif [ "$RELEASE_TYPE" == "patch" ]; then |
| 43 | +if [ "$RELEASE_TYPE" == "patch" ]; then |
50 | 44 | NEXT_FULL_TAG="${CURRENT_MAJOR}.${CURRENT_MINOR}.${NEXT_PATCH}" |
51 | 45 | NEXT_SHORT_TAG="${CURRENT_MAJOR}.${CURRENT_MINOR}" |
52 | 46 | else |
53 | 47 | echo "Incorrect release type; use 'major', 'minor', or 'patch' as an argument" |
54 | 48 | exit 1 |
55 | 49 | fi |
| 50 | +if [[ "$CURRENT_PATCH" == "-1" ]]; then |
| 51 | + echo "Preparing release [$NEXT_FULL_TAG]" |
| 52 | +else |
| 53 | + echo "Preparing release [$CURRENT_TAG -> $NEXT_FULL_TAG]" |
| 54 | +fi |
56 | 55 |
|
57 | | -echo "Preparing '$RELEASE_TYPE' release [$CURRENT_TAG -> $NEXT_FULL_TAG]" |
| 56 | +echo "${NEXT_FULL_TAG}" > VERSION |
58 | 57 |
|
59 | | -echo ${NEXT_FULL_TAG} > VERSION |
| 58 | +# Set gpuCI auto-releaser shell variable to an empty string |
| 59 | +REL_TYPE="" |
0 commit comments