From 5e77b478dd0ff78a24479eace31671b9842556c4 Mon Sep 17 00:00:00 2001 From: Josako Date: Thu, 17 Oct 2024 11:22:18 +0200 Subject: [PATCH] - Release script added to tag in both git and docker --- docker/release_and_tag_eveai.sh | 60 +++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 docker/release_and_tag_eveai.sh diff --git a/docker/release_and_tag_eveai.sh b/docker/release_and_tag_eveai.sh new file mode 100644 index 0000000..743458e --- /dev/null +++ b/docker/release_and_tag_eveai.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# Initialize variables +RELEASE_VERSION="" +RELEASE_MESSAGE="" +DOCKER_ACCOUNT="josakola" # Your Docker account name + +# Parse input arguments +while getopts r:m: flag +do + case "${flag}" in + r) RELEASE_VERSION=${OPTARG};; + m) RELEASE_MESSAGE=${OPTARG};; + *) + echo "Usage: $0 -r -m " + exit 1 ;; + esac +done + +# Ensure both version and message are provided +if [ -z "$RELEASE_VERSION" ]; then + echo "Error: Release version not provided. Use -r " + exit 1 +fi + +if [ -z "$RELEASE_MESSAGE" ]; then + echo "Error: Release message not provided. Use -m " + exit 1 +fi + +# Path to your docker-compose file +DOCKER_COMPOSE_FILE="compose_dev.yaml" + +# Get all the services defined in the docker-compose file +SERVICES=$(docker-compose -f $DOCKER_COMPOSE_FILE config --services) + +# Tag and push images for all services that belong to your Docker account +for SERVICE in $SERVICES; do + DOCKER_IMAGE="your-docker-repo/$SERVICE" + + # Check if the image starts with your Docker account name + if [[ $DOCKER_IMAGE == $DOCKER_ACCOUNT* ]]; then + echo "Tagging Docker image for service: $SERVICE with version: $RELEASE_VERSION" + + # Tag the 'latest' image with the new release version + docker tag $DOCKER_IMAGE:latest $DOCKER_IMAGE:$RELEASE_VERSION + + # Push the newly tagged image to Docker Hub + docker push $DOCKER_IMAGE:$RELEASE_VERSION + else + echo "Skipping service: $SERVICE (not part of Docker account $DOCKER_ACCOUNT)" + fi +done + +# Step 3: Tag the Git repository with the release version +echo "Tagging Git repository with version: $RELEASE_VERSION" +git tag -a v$RELEASE_VERSION -m "Release $RELEASE_VERSION: $RELEASE_MESSAGE" +git push origin v$RELEASE_VERSION + +echo "Release process completed for version: $RELEASE_VERSION"