summaryrefslogtreecommitdiff
path: root/ci/ci-release-build.sh
blob: ca60a4a370f6b7e47a873ddcfe807d48dfbc058f (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
#!/usr/bin/env bash
set -euo pipefail

# Makes sure that is_release_build is only set to yes in a release commit. A
# release commit must be titled: "Release $MAJOR.$MINOR". Also checks that the
# release version in the build system matches the commit msg.

# if running under PAPR, use the branch/PR HEAD actually
# being tested rather than the merge sha
HEAD=${PAPR_COMMIT:-HEAD}

git log --format=%B -n 1 $HEAD > log.txt
trap "rm -f version.m4 log.txt" EXIT

if grep -q ^is_release_build=yes configure.ac; then
    echo "*** is_release_build is set to yes ***"

    # assemble a short m4 macro file to evaluate 'package_version'
    cat > version.m4 <<EOF
m4_divert(-1)
m4_changequote([, ])
EOF

    grep m4_define configure.ac | grep _version >> version.m4

    cat >> version.m4 <<EOF
m4_divert(0)m4_dnl
package_version
EOF
    V=$(m4 -P version.m4)
    if [ -z "$V" ]; then
        echo "ERROR: couldn't read package_version"
        exit 1
    fi
    echo "OK: release version is $V"

    # check if the commit title indicates a release and has the correct version
    if ! grep -q "^Release $V" log.txt; then
        echo "ERROR: release commit doesn't match version"
        echo "Commit message:"
        cat log.txt
        echo "Build version: $V"
        exit 1
    fi
    echo "OK: release commit matches version"

    if grep -q "^LIBOSTREE_$V" src/libostree/libostree-devel.sym; then
        echo "ERROR: devel syms still references release version"
        exit 1
    fi
    echo "OK: devel syms no longer reference release version"

else
    echo "*** is_release_build is set to no ***"

    if grep -qE "^Release [0-9]+\.[0-9]+" log.txt; then
        echo "ERROR: release commit does not have is_release_build=yes"
        exit 1
    fi
    echo "OK: commit is not a release"
fi