release.sh 1.4 KB
Newer Older
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
#!/bin/bash

exists()
{
  command -v "$1" >/dev/null 2>&1
}

yesno () {
    if exists whiptail; then
        whiptail --yesno "$1" 10 60
        return
    elif exists dialog; then
        dialog --yesno "$1" 10 60
        return
    fi

    read -p "$1 (y/N)" answer
    case ${answer:0:1} in
        y|Y )
            return 0
        ;;
        * )
            return 1
        ;;
    esac
}

set -e

if [ "$1" = "" ]; then
    echo "Usage: $0 <version>"
    exit 1
fi
version="$1"
Thom Wiggers's avatar
Thom Wiggers committed
35
version_sane="$(echo $version | sed -Ee 's/^[0-9]\.[0-9]{1,}\.[0-9]{1,}$/YES/')"
36
37
38
39
40
41
42
43
44
if [ "$version_sane" != "YES" ]; then
    echo "Version should be in the format '1.23.45'"
    exit 1
fi
version_major=${version%.*}

echo "Changing directory to root of repository"
cd "${0%/*}"

Thom Wiggers's avatar
Thom Wiggers committed
45
46
47
echo "Making sure we're up-to-date"
git fetch --tags

48
49
50
51
52
53
54
55
echo "Changing to branch 'release/$version_major'"
git checkout "release/$version_major"

tag="$(git tag --contains)"
branch="$(git symbolic-ref --quiet --short HEAD || git rev-parse --short HEAD)"
if [ "$tag" = "v$version" ]; then
    echo "Already tagged!"
else
Thom Wiggers's avatar
Thom Wiggers committed
56
    echo "Creating new tag 'v$version'"
57
58
59
    git tag --annotate "v$version"
fi

Thom Wiggers's avatar
Thom Wiggers committed
60
61
62
if yesno "Do you want to push the tag to the repository?"; then
    echo "Pushing tags:"
    git push --tags
Thom Wiggers's avatar
Thom Wiggers committed
63
64
    echo "Don't forget to fill in the release description on the website:"
    echo "https://gitlab.science.ru.nl/thalia/concrexit/tags/v$version/release/edit"
65
fi