forked from moh-kenya/ts-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release_version.sh
executable file
·43 lines (30 loc) · 1.01 KB
/
release_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
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
set -e
VERSION_FILE="core/__init__.py"
SOURCE_COMMIT=$(git rev-parse HEAD)
export SOURCE_COMMIT=${SOURCE_COMMIT:0:8}
PROJECT_VERSION=$(cat $VERSION_FILE \
| grep API_VERSION \
| head -1 \
| awk -F= '{ print $2 }' \
| sed "s/[',]//g" \
| tr -d '[[:space:]]')
TAG="$PROJECT_VERSION-$SOURCE_COMMIT"
./set_build_version.sh
git checkout -b release
git add $VERSION_FILE
git commit -m "Release version $PROJECT_VERSION"
git tag "$TAG"
git remote set-url origin ${GIT_REPO_URL}
git push origin --tags
docker pull $DOCKER_IMAGE_ID
docker tag $DOCKER_IMAGE_ID $DOCKER_IMAGE_NAME:$TAG
docker push $DOCKER_IMAGE_NAME:$TAG
if [[ "$INCREASE_MAINTENANCE_VERSION" = true ]]; then
git checkout master
NEW_PROJECT_VERSION=$(echo "${PROJECT_VERSION}" | awk -F. -v OFS=. '{$NF++;print}')
sed -i "s/API_VERSION = '$PROJECT_VERSION'/API_VERSION = '$NEW_PROJECT_VERSION'/" $VERSION_FILE
git add $VERSION_FILE
git commit -m "[skip ci] Increase maintenance version to $NEW_PROJECT_VERSION"
git push origin master
fi