-
Notifications
You must be signed in to change notification settings - Fork 3
/
release.sh
42 lines (34 loc) · 1.38 KB
/
release.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
#!/bin/bash
if [ -z "$1" ] ; then
echo "Usage: $0 <ota zip>"
exit 1
fi
ROM="$1"
METADATA=$(unzip -p "$ROM" META-INF/com/android/metadata)
SDK_LEVEL=$(echo "$METADATA" | grep post-sdk-level | cut -f2 -d '=')
TIMESTAMP=$(echo "$METADATA" | grep post-timestamp | cut -f2 -d '=')
FILENAME=$(basename $ROM)
DEVICE=$(echo $FILENAME | cut -f5 -d '-' | cut -f1 -d".")
ROMTYPE=$(echo $FILENAME | cut -f4 -d '-')
DATE=$(echo $FILENAME | cut -f3 -d '-')
ID=$(echo ${TIMESTAMP}${DEVICE}${SDK_LEVEL} | sha256sum | cut -f 1 -d ' ')
SIZE=$(du -b $ROM | cut -f1 -d ' ')
TYPE=$(echo $FILENAME | cut -f4 -d '-')
VERSION=$(echo $FILENAME | cut -f2 -d '-')
RELASE_TAG=${DEVICE}_lineage-${VERSION}_${TIMESTAMP}
URL="https://github.com/ivanmeler/ota_provider/releases/download/${RELASE_TAG}/${FILENAME}"
response=$(jq -n --arg datetime $TIMESTAMP \
--arg filename $FILENAME \
--arg id $ID \
--arg romtype $ROMTYPE \
--arg size $SIZE \
--arg url $URL \
--arg version $VERSION \
'$ARGS.named'
)
wrapped_response=$(jq -n --argjson response "[$response]" '$ARGS.named')
echo "$wrapped_response" > $VERSION/$DEVICE.json
git add $VERSION/$DEVICE.json
git commit -m "Update autogenerated json for $DEVICE $VERSION ${DATE}/${TIMESTAMP}"
git push origin master -f
gh release create $RELASE_TAG $ROM --notes "Automated release for $DEVICE $VERSION ${DATE}/${TIMESTAMP}"