-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
add_version.sh
executable file
·50 lines (41 loc) · 1.01 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
#!/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"
echo "mypy==${version}
typing-extensions" > "requirements.in"
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.12-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"