-
Notifications
You must be signed in to change notification settings - Fork 115
/
push.sh
executable file
·56 lines (42 loc) · 1.16 KB
/
push.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
#!/bin/sh
set -e
cd "$(dirname "$0")"
SECRET_FILE=~/.secrets/asahilinux-storage
BASEPATH=https://storage.bunnycdn.com/asahilinux
SRC=releases
case "$1" in
prod) DIR=installer;;
dev) DIR=installer-dev;;
*) echo "Usage: $0 [prod|dev]" 1>&2; exit 1;;
esac
if [ ! -e "$SECRET_FILE" ]; then
echo "Missing storage bucket secret. Please place the secret in $SECRET_FILE." 1>&2
exit 1
fi
SECRET="$(cat "$SECRET_FILE")"
put() {
curl -# --fail --request PUT \
--url "$1" \
--header "AccessKey: $SECRET" \
--header "Content-Type: $2" \
--header 'accept: application/json' \
--data-binary @$3 >/tmp/ret
ret=$?
cat /tmp/ret; echo; echo
return $ret
}
VERSION="$(cat $SRC/latest)"
FILE="installer-${VERSION}.tar.gz"
SRCFILE="$SRC/$FILE"
TARGETFILE="$BASEPATH/$DIR/$FILE"
if [ ! -e "$SRCFILE" ]; then
echo "$SRCFILE does not exist" 1>&2
exit 1
fi
echo "About to push version $VERSION from $SRCFILE to $TARGETFILE."
echo "Press enter to confirm."
read
put "$TARGETFILE" "application/octet-stream" "$SRCFILE"
echo "Updating latest flag..."
put "$BASEPATH/$DIR/latest" "text/plain" "$SRC/latest"
echo "Done!"