From 4e29e145ee7a4c82eb9666245edbd5635cf2b8e9 Mon Sep 17 00:00:00 2001 From: ShahanaFarooqui Date: Fri, 21 Nov 2025 15:58:51 -0800 Subject: [PATCH] tools: Add script to update `stable` tag on Dockerhub Changelog-None: Script for Docker tag only. --- tools/promote-stable.sh | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tools/promote-stable.sh diff --git a/tools/promote-stable.sh b/tools/promote-stable.sh new file mode 100644 index 000000000000..607234d1770f --- /dev/null +++ b/tools/promote-stable.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# DOCKER_USERNAME= DOCKER_PASSWORD= source ./tools/promote-stable.sh + +IMAGE_NAME="elementsproject/lightningd" +MINIMUM_DAYS_BEFORE_STABLE=15 + +if [ -z "$DOCKER_USERNAME" ] || [ -z "$DOCKER_PASSWORD" ]; then + echo "❌ Oops! Looks like someone forgot their Docker Hub credentials at home!" + echo "🔑 Please set DOCKER_USERNAME and DOCKER_PASSWORD as environment variables." + echo "💡 Hint: We can't log in with 'your-username' and 'your-password' (nice try though!)" + return 1 2>/dev/null || exit 1 +fi + +# Get Docker image information +DOCKER_TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"$DOCKER_USERNAME\", \"password\": \"$DOCKER_PASSWORD\"}" \ + https://hub.docker.com/v2/users/login/ | jq -r .token) +LATEST_INFO=$(curl -s -H "Authorization: JWT $DOCKER_TOKEN" https://hub.docker.com/v2/repositories/${IMAGE_NAME}/tags/latest/) +LAST_UPDATED=$(echo "$LATEST_INFO" | jq -r .last_updated) || 0 +DAYS_OLD=$(( ($(date +%s) - $(date -d "$LAST_UPDATED" +%s)) / 86400 )) + +if [ $DAYS_OLD -ge $MINIMUM_DAYS_BEFORE_STABLE ]; then + echo "🎂 Ah, the latest tag has aged beautifully for $DAYS_OLD days, like a perfectly fermented sourdough!" + echo "📦 Time for its grand debut as 'stable'..." + echo "" + docker pull $IMAGE_NAME:latest + docker tag $IMAGE_NAME:latest $IMAGE_NAME:stable + docker push $IMAGE_NAME:stable + echo "" + echo "✅ 🎉 Congratulations! Your image has officially graduated to stable status!" +else + DAYS_REMAINING=$((MINIMUM_DAYS_BEFORE_STABLE - DAYS_OLD)) + echo "⏰ Whoa there! This latest tag is only $DAYS_OLD days old." + echo "🧀 It's like cheese - it needs time to mature! Wait for $DAYS_REMAINING more day(s)..." + read -p "❓ But hey, it's your rodeo. Still want to promote it to stable? (y/n): " -n 1 -r + echo "" + + if [[ $REPLY =~ ^[Yy]$ ]]; then + echo "🤠 Living dangerously, I see! Alright, throwing caution to the wind..." + echo "🚀 Strapping rockets to this latest image and sending it to stable anyway!" + echo "" + docker pull $IMAGE_NAME:latest + docker tag $IMAGE_NAME:latest $IMAGE_NAME:stable + docker push $IMAGE_NAME:stable + echo "" + echo "✅ 💥 Done! Let's hope this doesn't come back to haunt us..." + else + echo "🎯 Smart move! Your reputation as the cautious one remains intact." + echo "☕ Grab a coffee, touch some grass, and revisit this in $DAYS_REMAINING day(s)." + fi +fi