forked from ponces/treble_aosp
-
Notifications
You must be signed in to change notification settings - Fork 3
/
upload.sh
70 lines (59 loc) · 1.8 KB
/
upload.sh
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
62
63
64
65
66
67
68
69
70
#!/bin/bash
echo
echo "--------------------------------------"
echo " AOSP 14.0 Uploadbot "
echo " by "
echo " ponces "
echo "--------------------------------------"
echo
set -e
BL=$PWD/imbroglios_gsi
BD=$HOME/builds
TAG="$(date +v%Y.%m.%d)"
GUSER="imbroglius"
GREPO="imbroglios_gsi"
SKIPOTA=false
if [ "$1" == "--skip-ota" ]; then
SKIPOTA=true
fi
createRelease() {
echo "--> Creating release $TAG"
res=$(curl -s -L -X POST \
"https://api.github.com/repos/$GUSER/$GREPO/releases" \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $IMBROGLIOTOKEN" \
-d "{\"tag_name\":\"$TAG\",\"name\":\"ImbrogliOS 14.0 $TAG\",\"body\":\"## Changelog\n- ...\n\n## Notes\n- ...\",\"draft\":true}")
id=$(echo "$res" | jq -rc ".id")
echo
}
uploadAssets() {
buildDate="$(date +%Y%m%d)"
find $BD/ -name "ImbrogliOS-*-14.0-$buildDate.img.xz" | while read file; do
echo "--> Uploading $(basename $file)"
curl -o /dev/null -s -L -X POST \
"https://api.github.com/repos/$GUSER/$GREPO/releases/$id/assets?name=$(basename $file)" \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $IMBROGLIOTOKEN" \
-H "Content-Type: application/octet-stream" \
-T "$file"
echo
done
}
updateOta() {
echo "--> Updating OTA file"
pushd "$BL"
git add config/ota.json
git commit -m "build: Bump OTA to $TAG"
git push
popd
echo
}
START=$(date +%s)
createRelease
uploadAssets
[ "$SKIPOTA" = false ] && updateOta
END=$(date +%s)
ELAPSEDM=$(($(($END-$START))/60))
ELAPSEDS=$(($(($END-$START))-$ELAPSEDM*60))
echo "--> Uploadbot completed in $ELAPSEDM minutes and $ELAPSEDS seconds"
echo