-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpush.sh
More file actions
executable file
·83 lines (70 loc) · 1.97 KB
/
push.sh
File metadata and controls
executable file
·83 lines (70 loc) · 1.97 KB
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
#!/bin/bash
if [[ -z $1 || "$1" == "-h" ]]
then
cat << EOF
$0 -v[ersion] -t[ag] -e[arly]
where
- Version: of Stata (17, 18, ...) (can be omitted if set in _version.sh)
- Tag: tag to give Docker image (typically date)
- Early: use template README for early version of Stata
- h: this helpfile
EOF
exit 2
fi
source ./_version.sh
while getopts v:t:c:r: flag
do
case "${flag}" in
v) VERSION=${OPTARG};;
t) TAG=${OPTARG};;
e) EARLY=1;;
esac
done
VERSION=${VERSION:-18}
[[ -z $TAG ]] && TAG=$(date +%F)
SHORTDESC="Docker image for Stata, to be used in automation and reproducibility."
TEMPLATE="README-containers.template.md"
[[ -n $EARLY ]] && TEMPLATE="README-containers.early.md"
EXTRAMD="README-containers.$VERSION.md"
OUTPUTMD="README-containers.md"
MYHUBID=dataeditors
MYIMG=stata${VERSION}
# Generate README-containers.md from template
if [[ -f "$TEMPLATE" ]]; then
# Extract base version (e.g., "19" from "19_5")
BASE_VERSION=$(echo "$VERSION" | cut -d'_' -f1)
# Replace template placeholders
sed -e "s/{{ base_version }}/$BASE_VERSION/g" \
-e "s/{{ full_version }}/$VERSION/g" \
"$TEMPLATE" > "$OUTPUTMD"
if [[ -f "$EXTRAMD" ]]; then
echo "" >> "$OUTPUTMD"
cat "$EXTRAMD" >> "$OUTPUTMD"
fi
fi
# build all the images
# Base:
list=$(docker images | grep $TAG | grep ${MYIMG}- | awk ' { print $1 } ')
if [[ -z $list ]]; then
echo "No images found for tag $TAG with prefix ${MYIMG}-"
exit 1
fi
echo "Ready to push? (y/N)"
echo " docker push $MYHUBID/${MYIMG}:$TAG"
echo " (will iterate across all images)"
docker images | grep $TAG | grep ${MYIMG}-
read answer
case $answer in
y|Y)
# iterate over all images in $list
for arg in $list
do
docker push ${arg}:$TAG
# also push the README - requires installation of docker-pushrm https://github.com/christian-korneck/docker-pushrm
docker pushrm ${arg} --short "$SHORTDESC"
done
;;
*)
exit 0
;;
esac