-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathadd_version.sh
executable file
·57 lines (48 loc) · 1.14 KB
/
add_version.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
#!/bin/bash
set -e
cd "$(dirname "$0")"
readonly sandbox_dir="$(pwd)"
if [ -z "$1" ]; then
echo "usage: $0 <version>" 1>&2
exit 1
fi
set -u
readonly version="$1"
readonly cloud_functions_dir="${sandbox_dir}/cloud_functions/${version}"
readonly docker_dir="${sandbox_dir}/docker/${version}"
if [ -d "$cloud_functions_dir" ]; then
echo "${cloud_functions_dir} already exists" 1>&2
exit 1
fi
if [ -d "$docker_dir" ]; then
echo "${docker_dir} already exists" 1>&2
exit 1
fi
set -x
mkdir "$cloud_functions_dir"
cd "$cloud_functions_dir"
case $version in
"basedmypy-"*)
echo "basedmypy==${version#basedmypy-}" > "requirements.in"
;;
*)
echo "mypy==${version}
typing-extensions" > "requirements.in"
;;
esac
pip-compile
ln -s ../main.py ./
cd "$sandbox_dir"
mkdir "$docker_dir"
cd "$docker_dir"
cp "${cloud_functions_dir}/requirements.in" ./
cp "${cloud_functions_dir}/requirements.txt" ./
echo 'FROM python:3.13-slim
WORKDIR /tmp
COPY ./requirements.txt /tmp/
RUN pip install -r requirements.txt \
&& rm -rf /tmp/requirements.txt \
&& rm -rf /root/.cache
USER nobody
CMD ["mypy"]' > "Dockerfile"
cd "$sandbox_dir"