forked from SWE-agent/SWE-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release_dockerhub.sh
executable file
·93 lines (78 loc) · 3.13 KB
/
release_dockerhub.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env bash
# This script builds the official docker images and pushes them to dockerhub
# after checking with the user.
# bash strict mode
set -euo pipefail
# Check if exactly one argument is supplied
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <version>" >&2
exit 1
fi
VERSION_STR=${1}
# The argument should be in the form of x.x.x where each x can be one or more digits
if [[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Validated version number"
else
echo "Argument must be in the form x.x.x, where x is one or more numbers." >&2
exit 2
fi
echo "------------------------------------------"
echo "Building swe-agent"
echo "------------------------------------------"
docker build -t sweagent/swe-agent:${VERSION_STR} --build-arg MINICONDA_URL=https://repo.anaconda.com/miniconda/Miniconda3-py39_23.11.0-1-Linux-aarch64.sh -f docker/swe.Dockerfile .
docker build -t sweagent/swe-agent:latest --build-arg MINICONDA_URL=https://repo.anaconda.com/miniconda/Miniconda3-py39_23.11.0-1-Linux-aarch64.sh -f docker/swe.Dockerfile .
echo "------------------------------------------"
echo "Building swe-eval"
echo "------------------------------------------"
docker build -t sweagent/swe-eval:${VERSION_STR} -f docker/eval.Dockerfile .
docker build -t sweagent/swe-eval:latest -f docker/eval.Dockerfile .
echo "------------------------------------------"
echo "Building swe-agent-run"
echo "------------------------------------------"
docker build -t sweagent/swe-agent-run:${VERSION_STR} .
docker build -t sweagent/swe-agent-run:latest .
echo "------------------------------------------"
echo "Building of all images done"
echo "------------------------------------------"
read -p "Do you want to push to dockerhub and add the tag to github? (yes to proceed) " answer
if [ "$answer" != "yes" ]; then
echo "Abort; Bye" >&2
exit 3
fi
# Check if the tags already exist on Docker Hub
IMAGES=("sweagent/swe-agent:${VERSION_STR}" "sweagent/swe-agent:latest" "sweagent/swe-eval:${VERSION_STR}" "sweagent/swe-eval:latest" "sweagent/swe-agent-run:${VERSION_STR}" "sweagent/swe-agent-run:latest")
for image in "${IMAGES[@]}"; do
IMAGE_NAME="${image%:*}"
TAG="${image##*:}"
URL="https://hub.docker.com/v2/repositories/${IMAGE_NAME}/tags/${TAG}/"
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "${URL}")
if [ "$HTTP_STATUS" -eq 200 ]; then
echo "The tag '${TAG}' exists for '${IMAGE_NAME}' on Docker Hub." >&2
echo "Abort" >&2
exit 4
fi
done
docker login || {
echo "Failed to login to dockerhub" >&2
exit 8
}
# Let's get serious
# Function to execute upon exit
on_error() {
echo "====> ERROR!!! IMPORTANT: Make sure if you've already pushed something to dockerhub or pushed the tag to github!" >&2
}
trap on_error ERR
git tag v${VERSION_STR} || {
echo "Failed to create a tag in git" >&2
exit 5
}
echo "🔥 Tag v${VERSION_STR} created in git!"
git push origin v${VERSION_STR} || {
echo "Failed to push the tag to github" >&2
exit 6
}
echo "🔥 Tag v${VERSION_STR} pushed to github"
for image in "${IMAGES[@]}"; do
docker push ${image}
echo "🔥 Pushed ${image} to dockerhub"
done