-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·33 lines (26 loc) · 1.02 KB
/
build.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
#!/bin/bash
FILE=$(realpath "$0")
FOLDER=$(dirname "$FILE")
VERSION=$(cat "$FOLDER/VERSION.json" | jq -r ".docker_image")
MAJOR=$(echo $VERSION | cut -d. -f1)
MINOR=$(echo $VERSION | cut -d. -f2)
REV=$(echo $VERSION | cut -d. -f3)
REV=$(( REV + 1 ))
NEW_VERSION="${MAJOR}.${MINOR}.${REV}"
cd "$FOLDER"
echo \
'//NOTE: This file is automatically generated by '"$FILE"'
package main
func GetMyVersion() string {
return "v'"$NEW_VERSION"'"
}'>"version.go"
if go build -o "$FOLDER/docker-compose/kafka-postman/kafka-postman"; then
cat "$FOLDER/VERSION.json" | jq '.docker_image |= "'"$NEW_VERSION"'"' > "$FOLDER/VERSION.json.tmp"
mv "$FOLDER/VERSION.json.tmp" "$FOLDER/VERSION.json"
cd "$FOLDER/docker-compose/kafka-postman"
sudo docker build . -t artifexil/kafka-postman:$NEW_VERSION -t artifexil/kafka-postman:latest
sudo docker push artifexil/kafka-postman:$NEW_VERSION
sudo docker push artifexil/kafka-postman:latest
cd "$FOLDER/docker-compose"
sudo docker stack deploy --compose-file docker-compose.yml kafka-postman
fi