forked from RediSearch/RediSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload-artifacts
executable file
·147 lines (115 loc) · 3.7 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
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
PROGNAME="${BASH_SOURCE[0]}"
HERE="$(cd "$(dirname "$PROGNAME")" &>/dev/null && pwd)"
ROOT=$(cd $HERE/.. && pwd)
READIES=$ROOT/deps/readies
. $READIES/shibumi/defs
set -e
#----------------------------------------------------------------------------------------------
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
NOP=1 No operation
VERBOSE=1 Show artifacts details
HELP=1 Show help
END
exit 0
fi
#----------------------------------------------------------------------------------------------
ARCH=$(uname -m)
[[ $ARCH == arm64 ]] && ARCH="aarch64"
[[ $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 == noble ]] && OSNICK=ubuntu24.04
[[ $OSNICK == centos7 ]] && OSNICK=rhel7
[[ $OSNICK == centos8 ]] && OSNICK=rhel8
[[ $OSNICK == centos9 ]] && OSNICK=rhel9
[[ $OSNICK == ol8 ]] && OSNICK=rhel8
[[ $OSNICK == rocky8 ]] && OSNICK=rhel8
[[ $OSNICK == rocky9 ]] && OSNICK=rhel9
if [[ $OS == macos ]]; then
# as we don't build on macOS for every platform, we converge to a least common denominator
if [[ $ARCH == x86_64 ]]; then
OSNICK=catalina # to be aligned with the rest of the modules in redis stack
else
[[ $OSNICK == ventura ]] && OSNICK=monterey
fi
fi
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
# TODO: remove circle
if [[ -z $GITHUB_ACTIONS && -z $CIRCLECI ]]; then
eprint "Cannot upload outside of GitHub Actions. 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}/"
[[ -n $GITHUB_ACTIONS ]] && echo "::group::S3 ls $s3_dir"
$OP aws s3 ls $s3_dir
[[ -n $GITHUB_ACTIONS ]] && echo "::endgroup::"
}
s3_upload() {
local prod_subdir="$PROD"
local prefix="$PREFIX"
local upload_dir="${S3_URL}/${prod_subdir}${MAYBE_SNAP}"
local file
if [[ $SNAPSHOT == 1 ]]; then
files=$(ls ${prefix}.*${PLATFORM}*.zip)
for file in $files; do
s3_upload_file $file $upload_dir
done
else
files=$(ls ${prefix}.*.zip)
for file in $files; do
s3_upload_file $file $upload_dir
done
fi
[[ $VERBOSE == 1 ]] && s3_ls $upload_dir
return 0
}
#----------------------------------------------------------------------------------------------
PROD=redisearch PREFIX=redisearch s3_upload
PROD=redisearch PREFIX=redisearch-light s3_upload
PROD=redisearch-oss PREFIX=redisearch-oss s3_upload