-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_upload_nightly
executable file
·61 lines (60 loc) · 1.65 KB
/
build_upload_nightly
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
#!/bin/sh
name=$1
. "$HOME/$name.params"
echo Starting $CONTAINER_NAME
lxc-start -n "$CONTAINER_NAME"
if [ $? -ne 0 ]; then
exit $?
fi
sleep 10
echo Starting build by $BUILD_USER in $CONTAINER_NAME
lxc-attach -n "$CONTAINER_NAME" -- /home/$BUILD_USER/blastem/build_nightly $BUILD_USER needsu 2>&1 > /tmp/build_${name}_out.log
result=$?
if [ $result -ne 0 ]; then
echo Build falied with return code $result stopping $CONTAINER_NAME
lxc-stop -n "$CONTAINER_NAME"
curdate=`date -Iseconds`
curl -d'@-' -H 'Content-Type: application/json' "$WEBHOOKURL" <<WEBHOOKEOF
{
"embeds": [
{
"title": "Build $name failed!",
"type": "rich",
"description": "Build falied with return code $result stopping $CONTAINER_NAME",
"timestamp": "$curdate",
"color": 16711680
}
]
}
WEBHOOKEOF
exit $result
fi
echo "Build succeeded, stopping $CONTAINER_NAME"
lxc-stop -n "$CONTAINER_NAME"
. $HOME/remote.params
artifact=$(tail -n 1 /tmp/build_${name}_out.log)
echo "Uploaing $artifact to $REMOTE_HOST"
scp -i "$REMOTE_IDENT" "$HOME/.local/share/lxc/$CONTAINER_NAME/rootfs/home/$BUILD_USER/blastem/$artifact" $REMOTE_USER@$REMOTE_HOST:/home/$REMOTE_USER/nightlies
echo "Done"
curdate=`date -Iseconds`
version=`echo "$artifact" | sed -E 's/[^-]+-([0-9]+\.[0-9]+\.[0-9]+[^.]*)\..*$/\1/'`
curl -d'@-' -H 'Content-Type: application/json' "$WEBHOOKURL" <<WEBHOOKEOF
{
"embeds": [
{
"title": "$artifact",
"type": "rich",
"url": "https://www.retrodev.com/blastem/nightlies/$artifact",
"description": "New build of $name succeeded!",
"timestamp": "$curdate",
"color": 65280,
"fields": [
{
"name": "Version",
"value": "$version"
}
]
}
]
}
WEBHOOKEOF