-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathskopeo-promote.sh
executable file
·141 lines (120 loc) · 5.63 KB
/
skopeo-promote.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
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
#!/bin/sh
# This script will copy remote container images from one repository to another.
# It requires that auth.json already exists within $SKOPEO_CONFIG_DIR. See the
# skopeo-login.sh script if you have not yet logged into your Docker Hub account
# with Skopeo before.
usage() {
echo "usage:"
echo " skopeo-copy.sh ci-to-testing <major_version> <minor_version> <patch_version> <git_sha>"
echo " skopeo-copy.sh ci-to-stable <major_version> <minor_version> <patch_version> <git_sha>"
echo " skopeo-copy.sh testing-to-stable <major_version> <minor_version> <patch_version>"
exit 1
}
error() {
echo "error: ${1}"
echo
usage
}
# SKOPEO_CONFIG_DIR is the path to the local config directory for Skopeo
SKOPEO_CONFIG_DIR="${PWD}/.config/containers"
SENSU_CI_DOCKER_REPO="docker://docker.io/sensu/sensu-ci"
SENSU_DOCKER_REPO="docker://docker.io/sensu/sensu"
SENSU_RHEL_DOCKER_REPO="docker://docker.io/sensu/sensu-rhel"
SENSU_TESTING_DOCKER_REPO="docker://docker.io/sensu/sensu-testing"
COMMAND="$1"
if [ "${COMMAND}" = "" ]; then
error "missing command"
fi
MAJOR_VERSION="$2"
if [ "${MAJOR_VERSION}" = "" ]; then
error "missing major version"
fi
MINOR_VERSION="$3"
if [ "${MINOR_VERSION}" = "" ]; then
error "missing minor version"
fi
PATCH_VERSION="$4"
if [ "${PATCH_VERSION}" = "" ]; then
error "missing patch version"
fi
GIT_SHA="$5"
case $COMMAND in
ci-to-stable|ci-to-testing)
if [ "$GIT_SHA" = "" ]; then
error "missing git sha"
fi
;;
esac
VERSION="${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}"
SHORT_VERSION="${MAJOR_VERSION}.${MINOR_VERSION}"
ALPINE_TAG="alpine"
RHEL7_TAG="rhel7"
skopeo_copy() {
src="$1"
dst="$2"
echo "running: skopeo copy -a ${src} to ${dst}"
docker run \
-v "${SKOPEO_CONFIG_DIR}:/tmp/config" \
-e REGISTRY_AUTH_FILE="/tmp/config/auth.json" \
-it quay.io/skopeo/stable:latest \
copy -a "${src}" "${dst}"
}
ci_to_stable() {
# create alpine tags
skopeo_copy "${SENSU_CI_DOCKER_REPO}:${GIT_SHA}-${ALPINE_TAG}" "${SENSU_DOCKER_REPO}:${ALPINE_TAG}"
skopeo_copy "${SENSU_DOCKER_REPO}:${ALPINE_TAG}" "${SENSU_DOCKER_REPO}:${VERSION}"
skopeo_copy "${SENSU_DOCKER_REPO}:${ALPINE_TAG}" "${SENSU_DOCKER_REPO}:${SHORT_VERSION}"
skopeo_copy "${SENSU_DOCKER_REPO}:${ALPINE_TAG}" "${SENSU_DOCKER_REPO}:${MAJOR_VERSION}"
skopeo_copy "${SENSU_DOCKER_REPO}:${ALPINE_TAG}" "${SENSU_DOCKER_REPO}:latest"
# create rhel7 tags
skopeo_copy "${SENSU_CI_DOCKER_REPO}:${GIT_SHA}-${RHEL7_TAG}" "${SENSU_RHEL_DOCKER_REPO}:${RHEL7_TAG}"
skopeo_copy "${SENSU_RHEL_DOCKER_REPO}:${RHEL7_TAG}" "${SENSU_RHEL_DOCKER_REPO}:${VERSION}"
skopeo_copy "${SENSU_RHEL_DOCKER_REPO}:${RHEL7_TAG}" "${SENSU_RHEL_DOCKER_REPO}:${SHORT_VERSION}"
skopeo_copy "${SENSU_RHEL_DOCKER_REPO}:${RHEL7_TAG}" "${SENSU_RHEL_DOCKER_REPO}:${MAJOR_VERSION}"
skopeo_copy "${SENSU_RHEL_DOCKER_REPO}:${RHEL7_TAG}" "${SENSU_RHEL_DOCKER_REPO}:latest"
}
ci_to_testing() {
# create alpine tags
skopeo_copy "${SENSU_CI_DOCKER_REPO}:${GIT_SHA}-${ALPINE_TAG}" "${SENSU_TESTING_DOCKER_REPO}:${ALPINE_TAG}"
skopeo_copy "${SENSU_TESTING_DOCKER_REPO}:${ALPINE_TAG}" "${SENSU_TESTING_DOCKER_REPO}:${VERSION}-${ALPINE_TAG}"
skopeo_copy "${SENSU_TESTING_DOCKER_REPO}:${ALPINE_TAG}" "${SENSU_TESTING_DOCKER_REPO}:${SHORT_VERSION}-${ALPINE_TAG}"
skopeo_copy "${SENSU_TESTING_DOCKER_REPO}:${ALPINE_TAG}" "${SENSU_TESTING_DOCKER_REPO}:${MAJOR_VERSION}-${ALPINE_TAG}"
# create rhel7 tags
skopeo_copy "${SENSU_CI_DOCKER_REPO}:${GIT_SHA}-${RHEL7_TAG}" "${SENSU_TESTING_DOCKER_REPO}:${RHEL7_TAG}"
skopeo_copy "${SENSU_TESTING_DOCKER_REPO}:${RHEL7_TAG}" "${SENSU_TESTING_DOCKER_REPO}:${VERSION}-${RHEL7_TAG}"
skopeo_copy "${SENSU_TESTING_DOCKER_REPO}:${RHEL7_TAG}" "${SENSU_TESTING_DOCKER_REPO}:${SHORT_VERSION}-${RHEL7_TAG}"
skopeo_copy "${SENSU_TESTING_DOCKER_REPO}:${RHEL7_TAG}" "${SENSU_TESTING_DOCKER_REPO}:${MAJOR_VERSION}-${RHEL7_TAG}"
# default tags (uses alpine)
skopeo_copy "${SENSU_TESTING_DOCKER_REPO}:${ALPINE_TAG}" "${SENSU_TESTING_DOCKER_REPO}:${VERSION}"
skopeo_copy "${SENSU_TESTING_DOCKER_REPO}:${ALPINE_TAG}" "${SENSU_TESTING_DOCKER_REPO}:${SHORT_VERSION}"
skopeo_copy "${SENSU_TESTING_DOCKER_REPO}:${ALPINE_TAG}" "${SENSU_TESTING_DOCKER_REPO}:${MAJOR_VERSION}"
skopeo_copy "${SENSU_TESTING_DOCKER_REPO}:${ALPINE_TAG}" "${SENSU_TESTING_DOCKER_REPO}:latest"
}
testing_to_stable() {
# create alpine tags
skopeo_copy "${SENSU_TESTING_DOCKER_REPO}:${VERSION}-${ALPINE_TAG}" "${SENSU_DOCKER_REPO}:${ALPINE_TAG}"
skopeo_copy "${SENSU_DOCKER_REPO}:${ALPINE_TAG}" "${SENSU_DOCKER_REPO}:${VERSION}"
skopeo_copy "${SENSU_DOCKER_REPO}:${ALPINE_TAG}" "${SENSU_DOCKER_REPO}:${SHORT_VERSION}"
skopeo_copy "${SENSU_DOCKER_REPO}:${ALPINE_TAG}" "${SENSU_DOCKER_REPO}:${MAJOR_VERSION}"
skopeo_copy "${SENSU_DOCKER_REPO}:${ALPINE_TAG}" "${SENSU_DOCKER_REPO}:latest"
# create rhel7 tags
skopeo_copy "${SENSU_TESTING_DOCKER_REPO}:${VERSION}-${RHEL7_TAG}" "${SENSU_RHEL_DOCKER_REPO}:${RHEL7_TAG}"
skopeo_copy "${SENSU_RHEL_DOCKER_REPO}:${RHEL7_TAG}" "${SENSU_RHEL_DOCKER_REPO}:${VERSION}"
skopeo_copy "${SENSU_RHEL_DOCKER_REPO}:${RHEL7_TAG}" "${SENSU_RHEL_DOCKER_REPO}:${SHORT_VERSION}"
skopeo_copy "${SENSU_RHEL_DOCKER_REPO}:${RHEL7_TAG}" "${SENSU_RHEL_DOCKER_REPO}:${MAJOR_VERSION}"
skopeo_copy "${SENSU_RHEL_DOCKER_REPO}:${RHEL7_TAG}" "${SENSU_RHEL_DOCKER_REPO}:latest"
}
case $COMMAND in
ci-to-stable)
ci_to_stable
;;
ci-to-testing)
ci_to_testing
;;
testing-to-stable)
testing_to_stable
;;
*)
error "invalid command"
;;
esac