aboutsummaryrefslogtreecommitdiffstats
path: root/utils/release/tag.sh
blob: 6c5039d2de29f4c9bcc719e88bef7c02e38f0592 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/sh
#===-- tag.sh - Tag the LLVM release candidates ----------------------------===#
#
#                     The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License.
#
#===------------------------------------------------------------------------===#
#
# Create branches and release candidates for the LLVM release.
#
#===------------------------------------------------------------------------===#

set -e

release=""
rc=""
rebranch="no"
projects="llvm cfe dragonegg test-suite compiler-rt libcxx clang-tools-extra polly lldb lld"

base_url="https://llvm.org/svn/llvm-project"

function usage() {
    echo "usage: `basename $0` -release <num> [-rebranch]"
    echo "usage: `basename $0` -release <num> -rc <num>"
    echo " "
    echo "  -release <num>  The version number of the release"
    echo "  -rc <num>       The release candidate number"
    echo "  -rebranch       Remove existing branch, if present, before branching"
    echo "  -final          Tag final release candidate"
}

function tag_version() {
    set -x
    for proj in  $projects; do
        if svn ls $base_url/$proj/branches/release_$release > /dev/null 2>&1 ; then
            if [ $rebranch = "no" ]; then
                continue
            fi
            svn remove -m "Removing old release_$release branch for rebranching." \
                $base_url/$proj/branches/release_$release
        fi
        svn copy -m "Creating release_$release branch" \
            $base_url/$proj/trunk \
            $base_url/$proj/branches/release_$release
    done
    set +x
}

function tag_release_candidate() {
    set -x
    for proj in $projects ; do
        if ! svn ls $base_url/$proj/tags/RELEASE_$release > /dev/null 2>&1 ; then
            svn mkdir -m "Creating release directory for release_$release." $base_url/$proj/tags/RELEASE_$release
        fi
        if ! svn ls $base_url/$proj/tags/RELEASE_$release/$rc > /dev/null 2>&1 ; then
            svn copy -m "Creating release candidate $rc from release_$release branch" \
                $base_url/$proj/branches/release_$release \
                $base_url/$proj/tags/RELEASE_$release/$rc
        fi
    done
    set +x
}

while [ $# -gt 0 ]; do
    case $1 in
        -release | --release )
            shift
            release=$1
            ;;
        -rc | --rc )
            shift
            rc="rc$1"
            ;;
        -rebranch | --rebranch )
            rebranch="yes"
            ;;
        -final | --final )
            rc="final"
            ;;
        -h | --help | -help )
            usage
            exit 0
            ;;
        * )
            echo "unknown option: $1"
            usage
            exit 1
            ;;
    esac
    shift
done

if [ "x$release" = "x" ]; then
    echo "error: need to specify a release version"
    echo
    usage
    exit 1
fi

release=`echo $release | sed -e 's,\.,,g'`

if [ "x$rc" = "x" ]; then
    tag_version
else
    tag_release_candidate
fi

exit 0