Skip to content

Commit 7758d67

Browse files
committed
Cronjob to release on new tags
The last addition to the make_release is not needed anymore as deployment is now done via the server. - Setup extra environment variables - Trigger tests on gitlab - GPG tag is checked against local keyring on the server - Script can be used also in GitLab to do a trial run - When there is an unknown signer for a tag (or not signed) SLACK will be alerted. This should only run once. In the future the docs can also be updated.
1 parent 51f4842 commit 7758d67

File tree

2 files changed

+77
-9
lines changed

2 files changed

+77
-9
lines changed

cron_tag_release.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
main=master
6+
7+
RELEASE_DIR="/srv/http/domjudge/releases"
8+
DOWNLOAD_RELEASE_SCRIPT=""
9+
10+
notify_channel () {
11+
# Local debug
12+
echo "$1"
13+
# When cron is run often one should have time to
14+
# fix the issue.
15+
if [ ! -f /tmp/$2 ]; then
16+
# Write to syslog on server
17+
logger "$1"
18+
DATA='{"text":"'"$1"'"}'
19+
# Notify DOMjudge Slack channel (github-notifications)
20+
# SLACK_URL should be exported in the .bashrc (it should be secret)
21+
curl -X POST -H 'Content-type: application/json' --data "$DATA" "$SLACK_URL"
22+
touch /tmp/$2
23+
fi
24+
}
25+
26+
process_tag () {
27+
TAG="$1"
28+
NUMB="[0-9]+"
29+
DOT="\."
30+
RELEASE="$NUMB$DOT$NUMB$DOT$NUMB"
31+
OPTRC="((RC|rc)[0-9])?"
32+
if [[ $TAG =~ ^$RELEASE$OPTRC$ ]]; then
33+
# TODO: check if the file already exists
34+
if [ -f "$RELEASE_DIR/domjudge-$TAG.tar.gz" ]; then
35+
# Tag is already handled
36+
return 0
37+
fi
38+
# To find the signer key of a earlier tag:
39+
# gpg --search 780355B5EA6BFC8235A99C4B56F61A79401DAC04
40+
# And if one trusts the internet to be correct
41+
# gpg --recv-keys 780355B5EA6BFC8235A99C4B56F61A79401DAC04
42+
set +e # Some tags are not signed
43+
if git verify-tag $TAG; then
44+
set -e
45+
# At this point the tarball should already be locally tested
46+
~/domjudge-scripts/make_release.sh "$TAG"
47+
mv domjudge-$TAG.* $RELEASE_DIR/
48+
notify_channel "Tarball finished ($TAG)." "$TAG"
49+
else
50+
notify_channel "Untrusted tag ($TAG)" "$TAG"
51+
fi
52+
fi
53+
}
54+
55+
# Reset to main branch
56+
cd ~domjudge/domjudge
57+
git checkout $main
58+
59+
while read -r tag; do
60+
#echo "Handling tag: $tag"
61+
process_tag "$tag"
62+
done <<< "$(git tag)"
63+

make_release.sh

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
# Script to create a DOMjudge release package. Release file is
44
# generated in the current directory.
55

6-
if [ -z "${CI+x}" ]; then
6+
CI_USAGE=${CI+x}
7+
if [ -z "$CI_USAGE" ]; then
78
set -e
89
else
910
set -eux
1011
export PS4='(${0}:): - [$?] $ '
11-
fi
12+
fi
1213

1314
GITURL="https://github.com/DOMjudge/domjudge.git"
1415

@@ -19,11 +20,11 @@ if [ -z "$1" ]; then
1920
exit 1
2021
fi
2122

22-
if [ -n "${CI+x}" ]; then
23+
if [ -n "$CI_USAGE" ]; then
2324
set +x
2425
fi
2526
TAG="$1" ; shift
26-
if [ -n "${CI+x}" ]; then
27+
if [ -n "$CI_USAGE" ]; then
2728
set -x
2829
fi
2930

@@ -53,6 +54,10 @@ CHLOG_VERSION="$(echo "$CHLOG" | sed -r 's/^Version ([0-9\.]+) .*$/\1/')"
5354
if [ "$VERSION" != "$CHLOG_VERSION" ]; then
5455
echo "WARNING: version strings in README* and ChangeLog differ:"
5556
echo "'$VERSION' != '$CHLOG_VERSION'"
57+
if [ ! -t 1 && -z ${CI+x} ] ; then
58+
# In the cronjob this would be reason to not release
59+
exit 1
60+
fi
5661
fi
5762

5863
# Add released tag for revision information:
@@ -64,17 +69,17 @@ cd ..
6469

6570
mv domjudge "domjudge-$VERSION"
6671

67-
tar -cf "domjudge-$VERSION.tar" "domjudge-$VERSION"
68-
gzip -9 "domjudge-$VERSION.tar"
72+
tar -cf "domjudge-$TAG.tar" "domjudge-$VERSION"
73+
gzip -9 "domjudge-$TAG.tar"
6974

7075
cd "$OWD"
7176

72-
mv "$TEMPDIR/domjudge-$VERSION.tar.gz" .
77+
mv "$TEMPDIR/domjudge-$TAG.tar.gz" .
7378
rm -rf "$TEMPDIR"
7479

75-
sha256sum "domjudge-$VERSION.tar.gz" > "domjudge-$VERSION.tar.gz.sha256sum"
80+
sha256sum "domjudge-$TAG.tar.gz" > "domjudge-$TAG.tar.gz.sha256sum"
7681

77-
GPG_ARGS="-a --detach-sign --digest-algo SHA256 domjudge-$VERSION.tar.gz"
82+
GPG_ARGS="-a --detach-sign --digest-algo SHA256 domjudge-$TAG.tar.gz"
7883
if [ -t 1 ] ; then
7984
# Explicit not quoted!
8085
gpg $GPG_ARGS

0 commit comments

Comments
 (0)