diqiu50 commented on code in PR #10233:
URL: https://github.com/apache/gravitino/pull/10233#discussion_r2944237650


##########
dev/release/publish-docker.sh:
##########
@@ -0,0 +1,159 @@
+#!/bin/bash
+#
+# Build and publish Gravitino Docker images via GitHub Actions
+#
+# Usage: ./publish_docker.sh <tag|branch> [--dry-run]
+# Example:
+#   ./publish_docker.sh v1.2.0-rc5
+#   ./publish_docker.sh branch-1.2.0-rc5
+#   ./publish_docker.sh v1.2.0-rc5 --dry-run
+#
+# Environment variables required (set in env file or shell profile):
+#   DOCKER_USERNAME        - Docker Hub username
+#   PUBLISH_DOCKER_TOKEN  - Docker Hub access token
+#   GH_TOKEN              - GitHub token with repo/workflow permissions
+#
+# This script triggers the docker-image.yml workflow for the following images:
+#   - apache/gravitino:v${VERSION}
+#   - apache/gravitino-iceberg-rest:${VERSION}
+#   - apache/gravitino-lance-rest:${VERSION}
+#   - apache/gravitino-mcp-server:${VERSION}
+#   - apache/gravitino-playground:trino-478-gravitino-${VERSION}
+#
+
+set -e
+
+# Parse arguments
+DRY_RUN=false
+INPUT_TAG=""
+
+while [[ $# -gt 0 ]]; do
+  case "$1" in
+    --dry-run)
+      DRY_RUN=true
+      shift
+      ;;
+    -h|--help)
+      cat << EOF
+Usage: $0 <tag|branch> [--dry-run]
+
+Arguments:
+  <tag|branch>   Git tag or branch name to build (e.g., v1.2.0-rc5, 
branch-1.2.0-rc5)
+  --dry-run      Preview mode, print commands without triggering workflows
+
+Environment variables:
+  DOCKER_USERNAME        Docker Hub username (required for actual run)
+  PUBLISH_DOCKER_TOKEN   Docker Hub access token (required for actual run)
+  GH_TOKEN               GitHub token with repo/workflow permissions
+
+Examples:
+  $0 v1.2.0-rc5                  # Build version 1.2.0-rc5
+  $0 branch-1.2.0-rc5            # Build from branch
+  $0 v1.2.0-rc5 --dry-run        # Preview commands only
+
+Images built:
+  apache/gravitino:v${VERSION}
+  apache/gravitino-iceberg-rest:${VERSION}
+  apache/gravitino-lance-rest:${VERSION}
+  apache/gravitino-mcp-server:${VERSION}
+  apache/gravitino-playground:trino-478-gravitino-${VERSION}
+
+EOF
+      exit 0
+      ;;
+    *)
+      if [[ -z "$INPUT_TAG" ]]; then
+        INPUT_TAG="$1"
+      else
+        echo "ERROR: Unknown argument: $1"
+        exit 1
+      fi
+      shift
+      ;;
+  esac
+done
+
+# Check tag argument
+if [[ -z "$INPUT_TAG" ]]; then
+  echo "ERROR: Missing tag/branch argument"
+  echo "Usage: $0 <tag|branch> [--dry-run]"
+  exit 1
+fi
+
+# Verify tag or branch exists
+if ! git rev-parse "$INPUT_TAG" >/dev/null 2>&1; then
+  echo "ERROR: Tag or branch '$INPUT_TAG' does not exist"
+  exit 1
+fi
+
+echo "Verified: $INPUT_TAG exists"
+
+# Trino special version
+TRINO_VERSION="trino-478-gravitino-${INPUT_TAG}"
+
+if [[ "$DRY_RUN" == "true" ]]; then
+  echo "=== [DRY RUN] Preview Gravitino Docker Image Build ==="
+else
+  echo "=== Building Gravitino Docker Images ==="
+fi
+echo "Input: ${INPUT_TAG}"
+echo "Trino Version: ${TRINO_VERSION}"
+
+if [[ "$DRY_RUN" == "false" ]]; then
+  if [[ -z "$DOCKER_USERNAME" ]]; then
+    echo "ERROR: DOCKER_USERNAME environment variable not set"
+    exit 1
+  fi
+  if [[ -z "$PUBLISH_DOCKER_TOKEN" ]]; then
+    echo "ERROR: PUBLISH_DOCKER_TOKEN environment variable not set"
+    exit 1
+  fi
+  echo "Username: ${DOCKER_USERNAME}"
+fi
+echo ""
+
+# Image list
+declare -a images=(
+  "gravitino"
+  "gravitino-iceberg-rest-server"
+  "gravitino-lance-rest-server"
+  "gravitino-mcp-server"
+)
+
+echo "=== Triggering Workflows ==="
+
+# Build main images
+for img in "${images[@]}"; do
+  if [[ "$DRY_RUN" == "true" ]]; then
+    echo ">>> [DRY RUN] gh workflow run docker-image.yml -R apache/gravitino 
-f image=${img} -f version=${INPUT_TAG}"
+  else
+    echo ">>> Triggering ${img}:${INPUT_TAG}"
+    gh workflow run docker-image.yml -R apache/gravitino \
+      -f image="${img}" \
+      -f docker_repo_name=apache \
+      -f version="${INPUT_TAG}" \
+      -f username="${DOCKER_USERNAME}" \
+      -f token="${PUBLISH_DOCKER_TOKEN}"
+  fi

Review Comment:
   It's correct



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to