-
Notifications
You must be signed in to change notification settings - Fork 5
/
bumpversion.sh
executable file
·57 lines (46 loc) · 2.39 KB
/
bumpversion.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
. "$(dirname ${BASH_SOURCE:-$0})/config.inc"
# Read the version number from the file
version=$(grep 'IMAGE_VER' config.inc | cut -d '"' -f 2)
# Remove the 'v' prefix
version=${version#v}
# Split the version number by the delimiter '.'
major=$(echo $version | cut -d '.' -f 1)
minor=$(echo $version | cut -d '.' -f 2)
revision=$(echo $version | cut -d '.' -f 3)
build_sha=$(echo $version | cut -d '.' -f 4)
echo ""
echo "Major: " $major
echo "Minor: " $minor
echo "Revision: " $revision
echo "Config Build Sha: " $build_sha
# Run flake8 against all code in the `source_code` directory
CURRENT_BUILD_SHA=$(find . -type f -name '*.wasm' | sort -d | xargs -I{} sha1sum add_time_metric.diff build.sh requirements.txt Dockerfile wasmscore.py {} | sha1sum | cut -c 1-7 | awk '{print $1}')
echo "Actual Build Sha: " $CURRENT_BUILD_SHA
# Update major version and build sha
if [[ $1 == "Major" || $1 == "major" ]]; then
sed -i "s/\(IMAGE_VERSION=.*\.\)[0-9a-fA-F]\+/\1$CURRENT_BUILD_SHA/" config.inc
awk -F'.' -v OFS='.' '/IMAGE_VERSION/ {split($1,a, "v"); a[1]++; $1= "IMAGE_VERSION=\"" "v" a[1];}1' config.inc >temp && mv temp config.inc
awk -F'.' -v OFS='.' '/IMAGE_VERSION/ {$2=0; print} !/IMAGE_VERSION/ {print}' config.inc >temp && mv temp config.inc
awk -F'.' -v OFS='.' '/IMAGE_VERSION/ {$3=0; print} !/IMAGE_VERSION/ {print}' config.inc >temp && mv temp config.inc
# Update minor version and build sha
elif [[ $1 == "Minor" || $1 == "minor" ]]; then
sed -i "s/\(IMAGE_VERSION=.*\.\)[0-9a-fA-F]\+/\1$CURRENT_BUILD_SHA/" config.inc
awk -F'.' -v OFS='.' '/IMAGE_VERSION/ {$2++; print} !/IMAGE_VERSION/ {print}' config.inc >temp && mv temp config.inc
awk -F'.' -v OFS='.' '/IMAGE_VERSION/ {$3=0; print} !/IMAGE_VERSION/ {print}' config.inc >temp && mv temp config.inc
# Update patch version and build sha
elif [[ $1 == "Patch" || $1 == "patch" ]]; then
sed -i "s/\(IMAGE_VERSION=.*\.\)[0-9a-fA-F]\+/\1$CURRENT_BUILD_SHA/" config.inc
awk -F'.' -v OFS='.' '/IMAGE_VERSION/ {$3++; print} !/IMAGE_VERSION/ {print}' config.inc >temp && mv temp config.inc
# Only update the build sha
elif [[ $1 == "" ]]; then
sed -i "s/\(IMAGE_VERSION=.*\.\)[0-9a-fA-F]\+/\1$CURRENT_BUILD_SHA/" config.inc
elif [[ $1 != "" ]]; then
echo ""
echo "Invalid argument"
fi
echo ""
echo "Final Version: " $(grep 'IMAGE_VER' config.inc | cut -d '"' -f 2)
echo ""
echo "Note: git clean -f -x -d" $(git clean -f -x -d --dry-run)
echo ""