blob: 857fb3012f4300e5dd97e5a786051a3beb934db4 (
plain)
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
|
#! /bin/bash
set -eu -o pipefail
export DOCKER_CLI_EXPERIMENTAL=enabled
channel="${EXPEDITOR_CHANNEL:-unstable}"
version="${EXPEDITOR_VERSION:?You must manually set the EXPEDITOR_VERSION environment variable to an existing semantic version.}"
docker_login_user="expeditor"
docker_login_password="$(vault read -field=expeditor-full-access secret/docker/expeditor)"
# login to docker
echo "--- Docker login so we can push to chef org"
docker login -u "$docker_login_user" -p "$docker_login_password"
function create_and_push_manifest() {
local manifest_tag
manifest_tag="$1"
echo "--- Creating manifest for ${manifest_tag}"
docker manifest create "chef/chef:${manifest_tag}" \
--amend "chef/chef:${version}-arm64" \
--amend "chef/chef:${version}-amd64"
echo "--- Pushing manifest for ${manifest_tag}"
docker manifest push "chef/chef:${manifest_tag}"
}
# split the version components into integer variables
declare -i major_version minor_version _patch_version
IFS="."; read -r major_version minor_version _patch_version <<< "$version"
# mixlib-install uses package router's API which makes requests directly to Artifactory thereby providing up-to-date results
if mixlib-install download chef --url --channel stable --version "$major_version" &> /dev/null; then
major_version_is_in_omnibus_stable="true"
else
major_version_is_in_omnibus_stable="false"
fi
latest_major_version_in_omnibus_current="$(mixlib-install download chef --version latest --channel current --attributes --url | tail -n +2 | jq -r '.version | split(".")[0]')"
latest_major_version_in_omnibus_stable="$(mixlib-install download chef --version latest --channel stable --attributes --url | tail -n +2 | jq -r '.version | split(".")[0]')"
if [[ "$channel" == "current" ]]; then
# Add major and major.minor version tags unless this major version has been promoted to the omnibus STABLE channel
if [[ "$major_version_is_in_omnibus_stable" = "false" ]] ; then
create_and_push_manifest "$major_version"
create_and_push_manifest "${major_version}.${minor_version}"
fi
# Add "current" tag unless a newer major version has been promoted to the omnibus CURRENT channel
if [[ $major_version -ge $latest_major_version_in_omnibus_current ]]; then
create_and_push_manifest "current"
fi
elif [[ "$channel" == "stable" ]]; then
# Add major and major.minor version tags
create_and_push_manifest "$major_version"
create_and_push_manifest "${major_version}.${minor_version}"
# Add "stable" tag unless a newer major version has been promoted to the omnibus STABLE channel
if [[ $major_version -ge $latest_major_version_in_omnibus_stable ]]; then
create_and_push_manifest "stable"
# The "latest" docker tag is equivalent to the latest stable release
create_and_push_manifest "latest"
fi
else
echo "ERROR: Channel $channel not recognized"
exit 1
fi
|