github.com/prysmaticlabs/prysm@v1.4.4/scripts/tag-versioned-docker-images.sh (about)

     1  #!/bin/bash
     2  
     3  # This script is used to tag docker images with a specific commit or tag the
     4  # docker images as ":stable" with the --stable flag.
     5  
     6  # List of docker tags to update with git versioned tag.
     7  DOCKER_IMAGES=(
     8    # Beacon chain images
     9    "gcr.io/prysmaticlabs/prysm/beacon-chain"
    10    "index.docker.io/prysmaticlabs/prysm-beacon-chain"
    11    # Validator images
    12    "gcr.io/prysmaticlabs/prysm/validator"
    13    "index.docker.io/prysmaticlabs/prysm-validator"
    14    # Slasher images
    15    "gcr.io/prysmaticlabs/prysm/slasher"
    16    "index.docker.io/prysmaticlabs/prysm-slasher"
    17  )
    18  
    19  
    20  # Check that the current commit has an associated git tag.
    21  TAG=$(git describe --tags HEAD)
    22  TAG_COMMIT=$(git rev-list -n 1 "$TAG")
    23  CURRENT_COMMIT=$(git rev-parse HEAD)
    24  
    25  if [ "$TAG_COMMIT" != "$CURRENT_COMMIT" ]
    26  then
    27    echo "Current commit does not have an associated tag."
    28    exit 1
    29  fi
    30  
    31  TAG_AS_STABLE=0
    32  
    33  for arg in "$@"
    34  do
    35      case $arg in
    36          -s|--stable)
    37          TAG_AS_STABLE=1
    38          shift # Remove --stable from processing
    39          ;;
    40          *)
    41          OTHER_ARGUMENTS+=("$1")
    42          shift # Remove generic argument from processing
    43          ;;
    44      esac
    45  done
    46  
    47  if [ "$TAG_AS_STABLE" = "1" ]
    48  then
    49    TAG="stable"
    50  fi
    51  
    52  HEAD=HEAD-$(git rev-parse --short=6 HEAD)
    53  
    54  for image in "${DOCKER_IMAGES[@]}"
    55  do
    56    SRC="$image:$HEAD"
    57    DST="$image:$TAG"
    58    echo "Pulling $SRC"
    59    docker pull "$SRC"
    60    echo "Tagging $SRC as $DST"
    61    docker tag "$SRC" "$DST"
    62    echo "Pushing $DST"
    63    docker push "$DST"
    64  done
    65  
    66  exit 0