summaryrefslogtreecommitdiff
path: root/prepare_release.sh
blob: 7ee82811132f063805e8e1d9e0198972f1728cad (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
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
#!/bin/sh

set -e

PROJECT_VERSION="$1"

if [ -z "$1" ]; then
    echo "No version supplied"
    exit 1
fi

if ! command -v "black" &>/dev/null; then
    echo "please install black for formatting the python wrapper"
    exit 1
fi

if ! command -v "gofumpt" &>/dev/null; then
    echo "please install gofumpt for formatting the go code"
    exit 1
fi

if [ "$(git tag -l "${PROJECT_VERSION}")" ]; then
    echo "Version: ${PROJECT_VERSION} already has a tag"
    exit 1
fi

# First check if th
if [[ $(git diff) ]]; then
   echo "There are changes, commit them before releasing"
   exit 1
fi

# Format all go files
git ls-files | grep '.go$' | xargs -I {} gofumpt -w {} >/dev/null
if [[ $(git diff) ]]; then
    git add -u
    git commit -m "Format: Run Gofumpt"
fi

# Format all Python files
git ls-files | grep '.py$' | xargs -I {} black --quiet {} >/dev/null
if [[ $(git diff) ]]; then
    git add -u
    git commit -m "Format: Run Black"
fi

# Replace version number
# replace in internal/version
sed -i "s/const Version = ".*"/const Version = \"${PROJECT_VERSION}\"/" internal/version/version.go
sed -i "s/__version__ = ".*"/__version__ = \"${PROJECT_VERSION}\"/" wrappers/python/setup.py
sed -i "s/__version__ = ".*"/__version__ = \"${PROJECT_VERSION}\"/" wrappers/python/eduvpn_common/__init__.py

git add -u
git commit -m "Version: Update to ${PROJECT_VERSION}"