forked from RedisJSON/RedisJSON
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload-artifacts
executable file
·134 lines (102 loc) · 3.2 KB
/
upload-artifacts
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
PROGNAME="${BASH_SOURCE[0]}"
HERE="$(cd "$(dirname "$PROGNAME")" &>/dev/null && pwd)"
ROOT=$(cd $HERE/.. && pwd)
READIES=$ROOT/deps/readies
. $READIES/shibumi/defs
#----------------------------------------------------------------------------------------------
if [[ $1 == --help || $1 == help || $HELP == 1 ]]; then
cat <<-END
Upload packages to S3
upload-artifacts [--help|help] artifacts...
Argument variables:
SNAPSHOT=1 Upload snapshots (default)
OSNICK=nick Operate on packages for given OSNICK (default: host)
RELEASE=1 Upload release artifacts
STAGING=1 Upload into staging area
FORCE=1 Allow uploading outside of CI
NOP=1 No operation
VERBOSE=1 Show artifacts details
HELP=1 Show help
END
exit 0
fi
#----------------------------------------------------------------------------------------------
ARCH=$($READIES/bin/platform --arch)
[[ $ARCH == x64 ]] && ARCH="x86_64"
OS=$($READIES/bin/platform --os)
[[ $OS == linux ]] && OS="Linux"
[[ -z $OSNICK ]] && OSNICK=$($READIES/bin/platform --osnick)
[[ $OSNICK == trusty ]] && OSNICK=ubuntu14.04
[[ $OSNICK == xenial ]] && OSNICK=ubuntu16.04
[[ $OSNICK == bionic ]] && OSNICK=ubuntu18.04
[[ $OSNICK == focal ]] && OSNICK=ubuntu20.04
[[ $OSNICK == jammy ]] && OSNICK=ubuntu22.04
[[ $OSNICK == centos7 ]] && OSNICK=rhel7
[[ $OSNICK == centos8 ]] && OSNICK=rhel8
[[ $OSNICK == ol8 ]] && OSNICK=rhel8
[[ $OSNICK == rocky8 ]] && OSNICK=rhel8
[[ $OSNICK == bigsur ]] && OSNICK=catalina
PLATFORM="$OS-$OSNICK-$ARCH"
#----------------------------------------------------------------------------------------------
OP=""
[[ $NOP == 1 ]] && OP=echo
if [[ $STAGING == 1 ]]; then
S3_URL=s3://redismodules/lab/staging
else
S3_URL=s3://redismodules
fi
if [[ $FORCE != 1 ]]; then
if [[ -z $CIRCLECI ]]; then
eprint "Cannot upload outside of CircleCI. Override with FORCE=1."
exit 1
fi
if [[ -z $AWS_ACCESS_KEY_ID || -z $AWS_SECRET_ACCESS_KEY ]]; then
eprint "No credentials for S3 upload."
exit 1
fi
fi
cd $ROOT/bin
if [[ $SNAPSHOT == 1 ]]; then
MAYBE_SNAP=/snapshots
else
MAYBE_SNAP=
fi
cd artifacts${MAYBE_SNAP}
[[ $VERBOSE == 1 ]] && du -ah --apparent-size *
#----------------------------------------------------------------------------------------------
s3_upload_file() {
local file="$1"
local s3_dir="$2"
[[ $s3_dir != */ ]] && s3_dir="${s3_dir}/"
$OP aws s3 cp $file $s3_dir --acl public-read --no-progress
}
s3_ls() {
local s3_dir="$1"
[[ $s3_dir != */ ]] && s3_dir="${s3_dir}/"
$OP aws s3 ls $s3_dir
}
s3_upload() {
local prod_subdir="$PROD"
local prefix="$PREFIX"
local upload_dir="${S3_URL}/${prod_subdir}${MAYBE_SNAP}"
local file
if [[ $SNAPSHOT == 1 ]]; then
for file in `ls ${prefix}.*${PLATFORM}*.zip ${prefix}.*${PLATFORM}*.tgz 2> /dev/null`; do
s3_upload_file $file $upload_dir
done
else
for file in `ls ${prefix}.*.zip ${prefix}.*.tgz 2> /dev/null`; do
s3_upload_file $file $upload_dir
done
fi
[[ $VERBOSE == 1 ]] && s3_ls $upload_dir
return 0
}
#----------------------------------------------------------------------------------------------
if [[ $NOP != 1 ]]; then
if ! is_command aws; then
$READIES/bin/getaws
fi
fi
PROD=rejson-oss PREFIX=rejson-oss s3_upload