dist.sh 4.88 KB
Newer Older
Vivien Kraus's avatar
Vivien Kraus committed
1
2
#!/bin/sh

Vivien Kraus's avatar
Vivien Kraus committed
3
4
5
6
# HACKS!!!!
#
# Remove VALAFLAGS="--target-glib=2.50"

7
8
9
10
11
12
SOURCE_TOP=$(pwd)
CLEAN_TOP=$(cd .. && pwd)/clean
mkdir -p ../clean
chmod -R ugo+w ../clean || exit 1
rm -rf ../clean || exit 1
mkdir -p ../clean || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
13
rm -rf $SOURCE_TOP/dist || exit 1
14
15
16
17
18

cd $CLEAN_TOP
git clone $SOURCE_TOP . || exit 1

cd $SOURCE_TOP || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
19
rm -rf ../tarot-*.tar.gz ../tarot-*/ tarot-*.tar.gz
20
sh autogen.sh VALAFLAGS="--target-glib=2.50" || exit 1
21
./configure \
22
    CFLAGS="-Wall -Wextra -Werror -g $CFLAGS" \
Vivien Kraus's avatar
Vivien Kraus committed
23
    VALAFLAGS="--target-glib=2.50" \
Vivien Kraus's avatar
Vivien Kraus committed
24
    --prefix="$SOURCE_TOP/dist" \
Vivien Kraus's avatar
Vivien Kraus committed
25
    --enable-valgrind=yes \
Vivien Kraus's avatar
Vivien Kraus committed
26
    --enable-renderer=yes \
Vivien Kraus's avatar
Vivien Kraus committed
27
    --enable-generator=yes \
28
    --enable-tree-renderer=yes \
Vivien Kraus's avatar
Vivien Kraus committed
29
    --enable-silent-rules=yes \
30
31
    || (cat config.log ; exit 1) \
    || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
32
(cd lib && make -j 16 CFLAGS="-Wno-error -g $CFLAGS") || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
33
make -j 16 distcheck || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
34
make -j 8 check || exit 1
35
make -j 16 install install-html || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
36
make indent || exit 1
37
38
39
rm -rf ../../tarot-*.tar.gz ../../tarot-*/
cp tarot-*.tar.gz ../../ || exit 1
cd ../../ || exit 1
40
41
tar xf tarot-*.tar.gz || exit 1
cd tarot-* || exit 1
42
DIST_TOP=$(pwd)
Vivien Kraus's avatar
Vivien Kraus committed
43
cd $CLEAN_TOP || exit 1
44
OK="yes"
Vivien Kraus's avatar
Vivien Kraus committed
45
for source in $(find . -type f)
46
47
48
49
50
51
do
    case $source in
	*.po | *.pot)
	    echo "Ignoring PO file $source, as it has a date in it.";;
	*.md)
	    echo "Ignoring Markdown file $source, as it may be non-reproducibly generated by org-mode.";;
Vivien Kraus's avatar
Vivien Kraus committed
52
	*/.git/*);;
53
	*)
Vivien Kraus's avatar
Vivien Kraus committed
54
	    if diff $source $DIST_TOP/$source
Vivien Kraus's avatar
Vivien Kraus committed
55
	    then
Vivien Kraus's avatar
Vivien Kraus committed
56
57
		echo "$source: OK"
	    else
Vivien Kraus's avatar
Vivien Kraus committed
58
59
60
		echo "ERROR: $source has been modified since check-in, or ignored from the distribution.  Is it automatically generated?  Did you forget to indent it?  Did you forget to include it as distributed in Automake?"
		OK="no"
	    fi;;
61
62
	esac
done;
Vivien Kraus's avatar
Vivien Kraus committed
63
64
65
66
67
68
69
70
cd $DIST_TOP || exit 1
./configure && make maintainer-clean || exit 1
echo "Checking what files are maintainer-clean..."
for source in $(find . -type f)
do
    case $source in
	*.po | *.pot)
	    echo "Ignoring PO file $source, as it has a date in it.";;
Vivien Kraus's avatar
Vivien Kraus committed
71
72
	./po/en@quot.header | ./po/en@boldquot.header | ./po/Rules-quot | ./po/remove-potcdate.sin | ./po/boldquot.sed | ./po/quot.sed | ./po/insert-header.sin | ./po/Makefile.in.in)
	    echo "Ignoring Gettext garbage $source.";;
Vivien Kraus's avatar
Vivien Kraus committed
73
74
75
76
	./libopts/*)
	    echo "Ignoring embedded file $source, as it is not ours.";;
	./.tarball-version)
	    echo "Ignoring .tarball-version.";;
Vivien Kraus's avatar
Vivien Kraus committed
77
	./lib/* | ./snippet/*)
Vivien Kraus's avatar
Vivien Kraus committed
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
	    echo "Ignoring $source, some gnulib stuff.";;
	./m4/*)
	    echo "Ignoring autoconf macro $source.";;
	./git-version-gen | ./gitlog-to-changelog)
	    echo "Ignoring helper script $source.";;
	./compile | ./depcomp | ./config.rpath | ./config.sub | ./texinfo.tex | ./ar-lib | ./INSTALL | ./missing | ./test-driver | ./ltmain.sh | ./aclocal.m4 | ./ChangeLog | ./config.h.in | ./config.guess | ./Makefile.in | ./configure | ./install-sh | ./ABOUT-NLS)
	    echo "Ignoring required automake script $source.";;
	*)
	    if diff $source $CLEAN_TOP/$source
	    then
		echo "$source: OK"
	    else
		echo "ERROR: $source is not a maintainer-clean file, but it has been rebuilt or deleted since checkout.  If this file has been generated, add it to MAINTAINERCLEANFILES."
		OK="no"
	    fi;;
    esac
done;
Vivien Kraus's avatar
Vivien Kraus committed
95
96
97
98
99
if test "$OK" = "no"
then
    echo "Failure."
    exit 1
fi
100
101
102

## Nice!
cd $SOURCE_TOP || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
103
mkdir -p $SOURCE_TOP/dist || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
104
cp $SOURCE_TOP/.version \
Vivien Kraus's avatar
Vivien Kraus committed
105
106
   $SOURCE_TOP/dist/version || exit 1
cp tarot-*.tar.gz $SOURCE_TOP/dist/ || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
107
108
109
110
111

if test "x$CI_COMMIT_TAG" != "x"
then
    cd $SOURCE_TOP
    TARFILE=$(ls dist/tarot-*.tar.gz)
112
    SHASUM=$(sha256sum $TARFILE)
Vivien Kraus's avatar
Vivien Kraus committed
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
    UPLOAD_STATUS=$(curl \
	      --request POST \
	      --header "PRIVATE-TOKEN: $PRIVATE_TOKEN" \
	      --form \
	      "file=@$TARFILE" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/uploads")
    URL=$(echo "$UPLOAD_STATUS" | jq -r '.url')

    echo "Upload $TARFILE to $CI_API_V4_URL/projects/$CI_PROJECT_ID/uploads: $UPLOAD_STATUS"

    NAME="Tarot release"
    TAG_NAME="$CI_COMMIT_TAG"
    DESCRIPTION=$(git tag -l --format='%(contents)' "$CI_COMMIT_TAG")
    FULL_URL="${CI_PROJECT_URL}${URL}"
    LINK="{\"name\": \"$TARFILE\", \"url\": \"$FULL_URL\"}"
    ASSETS="{\"links\": [$LINK]}"
    DESCRIPTION_ESCAPED=$(echo "$DESCRIPTION" | jq -R --slurp '.')
    DATA="{\"name\": \"$NAME\", \"tag_name\": \"$TAG_NAME\", \"description\": $DESCRIPTION_ESCAPED, \"assets\": $ASSETS}"

    echo "POSTing $DATA to $CI_API_V4_URL/projects/$CI_PROJECT_ID/releases"

    curl --header 'Content-Type: application/json' \
	 --header "PRIVATE-TOKEN: $PRIVATE_TOKEN" \
	 --data "$DATA" \
	 --request POST \
137
138
	 "$CI_API_V4_URL/projects/$CI_PROJECT_ID/releases" || exit 1
    mkdir /root/.ssh || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
139
140
    echo "$SSH_KEY" > /root/.ssh/id_rsa || exit 1
    echo "$SSH_KEY_PUB" > /root/.ssh/id_rsa.pub || exit 1
141
142
143
144
145
146
    git clone git@framagit.org:play-tarot/tarot-flatpak.git || exit 1
    cd tarot-flatpak || exit 1
    ./update-tarot.sh "$FULL_URL" "$SHASUM" || exit 1
    git add . || exit 1
    git commit -m"New version" || exit 1
    git push || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
147
fi