dist.sh 5.54 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-silent-rules=yes \
27
28
    || (cat config.log ; exit 1) \
    || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
29
(cd lib && make -j 16 CFLAGS="-Wno-error -g $CFLAGS") || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
30
make -j 16 src/tarot-app/tarot || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
31
make -j 16 distcheck || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
32
make -j 8 check || exit 1
33
make -j 16 install install-html || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
34
make indent || exit 1
35
36
37
rm -rf ../../tarot-*.tar.gz ../../tarot-*/
cp tarot-*.tar.gz ../../ || exit 1
cd ../../ || exit 1
38
39
tar xf tarot-*.tar.gz || exit 1
cd tarot-* || exit 1
40
DIST_TOP=$(pwd)
Vivien Kraus's avatar
Vivien Kraus committed
41
cd $CLEAN_TOP || exit 1
42
OK="yes"
Vivien Kraus's avatar
Vivien Kraus committed
43
for source in $(find . -type f)
44
45
46
47
48
49
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
50
	*/.git/*);;
51
	*)
Vivien Kraus's avatar
Vivien Kraus committed
52
	    if diff $source $DIST_TOP/$source
Vivien Kraus's avatar
Vivien Kraus committed
53
	    then
Vivien Kraus's avatar
Vivien Kraus committed
54
55
		echo "$source: OK"
	    else
Vivien Kraus's avatar
Vivien Kraus committed
56
57
58
		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;;
59
60
	esac
done;
Vivien Kraus's avatar
Vivien Kraus committed
61
62
63
64
65
66
67
68
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
69
70
	./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
71
72
73
74
	./libopts/*)
	    echo "Ignoring embedded file $source, as it is not ours.";;
	./.tarball-version)
	    echo "Ignoring .tarball-version.";;
Vivien Kraus's avatar
Vivien Kraus committed
75
	./lib/* | ./snippet/*)
Vivien Kraus's avatar
Vivien Kraus committed
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
	    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
93
94
95
96
97
if test "$OK" = "no"
then
    echo "Failure."
    exit 1
fi
98
99
100

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

if test "x$CI_COMMIT_TAG" != "x"
then
    cd $SOURCE_TOP
    TARFILE=$(ls dist/tarot-*.tar.gz)
Vivien Kraus's avatar
Vivien Kraus committed
110
    SHASUM=$(sha256sum $TARFILE | head -c 64)
Vivien Kraus's avatar
Vivien Kraus committed
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
    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 \
135
136
	 "$CI_API_V4_URL/projects/$CI_PROJECT_ID/releases" || exit 1
    mkdir /root/.ssh || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
137
138
    echo "$SSH_KEY" > /root/.ssh/id_rsa || exit 1
    echo "$SSH_KEY_PUB" > /root/.ssh/id_rsa.pub || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
139
140
    echo "$SSH_KNOWN_HOSTS" > /root/.ssh/known_hosts || exit 1
    chmod go-rwx /root/.ssh/id_rsa || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
141
142
    git config --global user.email "vivien@planete-kraus.eu" || exit 1
    git config --global user.name "Gitlab CI for the tarot package" || exit 1
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
Vivien Kraus's avatar
Vivien Kraus committed
147
148
    git commit -m"New version"
    git push
Vivien Kraus's avatar
Vivien Kraus committed
149
150
151
152
153
    cd .. || exit 1
    git clone git@framagit.org:play-tarot/tarot-deb.git || exit 1
    cd tarot-deb || exit 1
    ./update-tarot.sh "$FULL_URL" "$(cat $SOURCE_TOP/.version)" || exit 1
    git add . || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
154
155
    git commit -m"New version"
    git push
156
157
158
159
    cd .. || exit 1
    git clone git@framagit.org:play-tarot/tarot-mingw.git || exit 1
    cd tarot-mingw || exit 1
    ./update-tarot.sh "$FULL_URL" || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
160
    git add .
161
162
    git commit -m"New version"
    git push
Vivien Kraus's avatar
Vivien Kraus committed
163
fi