2020-05-16 14:55:46 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
2021-07-16 22:35:36 +00:00
|
|
|
# See if this version already exists on Docker Hub.
|
|
|
|
function version_exists() {
|
|
|
|
local output
|
|
|
|
output=$(curl --silent "https://index.docker.io/v1/repositories/codercom/code-server/tags/$VERSION")
|
|
|
|
if [[ $output == "Tag not found" ]]; then
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-07-16 23:25:54 +00:00
|
|
|
# Import and push the Docker image for the provided arch. We must have
|
|
|
|
# individual arch repositories pushed remotely in order to use `docker
|
|
|
|
# manifest` to create single a multi-arch image.
|
|
|
|
# TODO: Switch to buildx? Seems it can do this more simply.
|
2021-07-16 21:24:50 +00:00
|
|
|
push() {
|
|
|
|
local arch=$1
|
|
|
|
local tag="codercom/code-server-$arch:$VERSION"
|
|
|
|
docker import "./release-images/code-server-$arch-$VERSION.tar" "$tag"
|
|
|
|
docker push "$tag"
|
|
|
|
}
|
|
|
|
|
2020-05-16 14:55:46 +00:00
|
|
|
main() {
|
|
|
|
cd "$(dirname "$0")/../.."
|
|
|
|
source ./ci/lib.sh
|
|
|
|
|
2021-07-16 22:35:36 +00:00
|
|
|
if version_exists; then
|
|
|
|
echo "$VERSION is already pushed"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2020-05-16 14:55:46 +00:00
|
|
|
download_artifact release-images ./release-images
|
|
|
|
if [[ ${CI-} ]]; then
|
|
|
|
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
|
|
|
fi
|
|
|
|
|
2021-07-16 21:24:50 +00:00
|
|
|
push "amd64"
|
|
|
|
push "arm64"
|
2021-07-16 23:25:54 +00:00
|
|
|
|
|
|
|
export DOCKER_CLI_EXPERIMENTAL=enabled
|
|
|
|
|
|
|
|
docker manifest create "codercom/code-server:$VERSION" \
|
|
|
|
"codercom/code-server-amd64:$VERSION" \
|
|
|
|
"codercom/code-server-arm64:$VERSION"
|
|
|
|
docker manifest push --purge "codercom/code-server:$VERSION"
|
|
|
|
|
|
|
|
docker manifest create "codercom/code-server:latest" \
|
|
|
|
"codercom/code-server-amd64:$VERSION" \
|
|
|
|
"codercom/code-server-arm64:$VERSION"
|
|
|
|
docker manifest push --purge "codercom/code-server:latest"
|
2020-05-16 14:55:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|