summaryrefslogtreecommitdiff
path: root/tools/read-version
blob: 690666b5de9d4d7f730d3b942c9b1e488148b82c (plain)
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
#!/bin/sh

set -e

if [ -e "setup.py" ]
then
    ROOT_DIR="$PWD"
elif [ -e "../setup.py" ]
then
    ROOT_DIR="$PWD/../"
else
    echo "Unable to locate 'setup.py' file that should" \
          "exist in the cloud-init root directory."
    exit 1
fi

CHNG_LOG="$ROOT_DIR/ChangeLog"

if [ ! -e "$CHNG_LOG" ]
then
    echo "Unable to find 'ChangeLog' file located at $CHNG_LOG"
    exit 1
fi

VERSION=$(grep -P "\d+.\d+.\d+:" $CHNG_LOG  | cut -f1 -d ":" | head -n 1)
echo $VERSION