Skip to content

Commit 35483df

Browse files
committed
Tidyup and move script
1 parent d9d549e commit 35483df

1 file changed

Lines changed: 111 additions & 0 deletions

File tree

‎dev/confluent-hub-package.sh‎

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
# Builds and repackages the connector for Confluent Hub submission.
21+
# Usage: dev/confluent-hub-package.sh [TAG]
22+
# TAG: git tag to build (default: latest tag)
23+
24+
set -euo pipefail
25+
26+
ORIGINAL_DIR="$(pwd)"
27+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
28+
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
29+
CONNECT_RUNTIME_DIR="${PROJECT_ROOT}/kafka-connect/kafka-connect-runtime"
30+
31+
# Return to original directory on exit
32+
trap "cd '${ORIGINAL_DIR}'" EXIT
33+
34+
# Determine tag
35+
if [[ -n "${1:-}" ]]; then
36+
TAG="$1"
37+
else
38+
git fetch --tags 2>/dev/null || true
39+
TAG=$(git describe --tags "$(git rev-list --tags --max-count=1)")
40+
echo "Using latest tag: $TAG"
41+
fi
42+
43+
git checkout "$TAG"
44+
45+
# Extract version from tag (apache-iceberg-X.Y.Z -> X.Y.Z)
46+
VERSION="${TAG#apache-iceberg-}"
47+
48+
# Create version.txt to override gradle's SNAPSHOT versioning
49+
echo "$VERSION" > "${PROJECT_ROOT}/version.txt"
50+
trap "rm -f '${PROJECT_ROOT}/version.txt'; cd '${ORIGINAL_DIR}'" EXIT
51+
52+
# Build (clean first to remove old artifacts)
53+
"${PROJECT_ROOT}/gradlew" clean :iceberg-kafka-connect:iceberg-kafka-connect-runtime:distZip \
54+
-x test -x integrationTest --quiet
55+
56+
# Extract
57+
DIST_DIR="${CONNECT_RUNTIME_DIR}/build/distributions"
58+
MAIN_ZIP="${DIST_DIR}/iceberg-kafka-connect-runtime-${VERSION}.zip"
59+
[[ -f "${MAIN_ZIP}" ]] || { echo "Distribution not found: ${MAIN_ZIP}"; exit 1; }
60+
PACKAGE_NAME="apache-iceberg-kafka-connect-${VERSION}"
61+
WORK_DIR="${CONNECT_RUNTIME_DIR}/build/confluent-hub-work"
62+
63+
rm -rf "${WORK_DIR}"
64+
mkdir -p "${WORK_DIR}"
65+
unzip -q "${MAIN_ZIP}" -d "${WORK_DIR}"
66+
mv "${WORK_DIR}/iceberg-kafka-connect-runtime-${VERSION}" "${WORK_DIR}/${PACKAGE_NAME}"
67+
PKG="${WORK_DIR}/${PACKAGE_NAME}"
68+
69+
# Update manifest owner
70+
sed -i.bak 's/"username": "iceberg"/"username": "apache"/' "${PKG}/manifest.json"
71+
rm -f "${PKG}/manifest.json.bak"
72+
73+
# Add README
74+
cat > "${PKG}/doc/README.md" << EOF
75+
# Apache Iceberg Sink Connector
76+
77+
A Kafka Connect sink connector for writing data from Apache Kafka into Apache Iceberg tables.
78+
79+
Documentation: https://iceberg.apache.org/docs/${VERSION}/kafka-connect/
80+
81+
License: Apache License 2.0
82+
EOF
83+
84+
# Add example config
85+
mkdir -p "${PKG}/etc"
86+
cat > "${PKG}/etc/iceberg-sink.properties.example" << 'EOF'
87+
# Iceberg Sink Connector - Example Configuration
88+
# https://iceberg.apache.org/docs/latest/kafka-connect/
89+
name=iceberg-sink
90+
connector.class=org.apache.iceberg.connect.IcebergSinkConnector
91+
tasks.max=1
92+
topics=events
93+
iceberg.tables=db.table_name
94+
iceberg.catalog.type=rest
95+
iceberg.catalog.uri=https://your-catalog-uri
96+
iceberg.catalog.warehouse=your-warehouse
97+
EOF
98+
99+
# Add logo
100+
mkdir -p "${PKG}/assets"
101+
cp "${CONNECT_RUNTIME_DIR}/src/main/resources/iceberg.png" "${PKG}/assets/"
102+
103+
# Security scan
104+
docker run --rm -v "${PKG}:/scan:ro" aquasec/trivy rootfs --severity HIGH,CRITICAL /scan
105+
106+
# Create archive
107+
OUTPUT="${DIST_DIR}/${PACKAGE_NAME}.zip"
108+
(cd "${WORK_DIR}" && zip -rq "${OUTPUT}" "${PACKAGE_NAME}")
109+
rm -rf "${WORK_DIR}"
110+
111+
echo "Created: ${OUTPUT}"

0 commit comments

Comments
 (0)