4242# 4. Open a focused PR.
4343#
4444# Environment overrides:
45- # UC_DIR directory to clone into (default: /tmp/unitycatalog)
46- # UC_REPO git remote URL (default: upstream unitycatalog)
47- # UC_REF must be `main` or UC_PIN_SHA (default: UC_PIN_SHA below)
48- # UC_FORCE set to "1" to rebuild even when the Ivy artifact exists
45+ # UC_DIR directory to clone into (default: /tmp/unitycatalog)
46+ # UC_REPO git remote URL (default: upstream unitycatalog)
47+ # UC_REF must be `main` or UC_PIN_SHA (default: UC_PIN_SHA below)
48+ # UC_FORCE set to "1" to rebuild even when the Ivy artifact exists
49+ # SPARK_VERSION Spark major.minor UC should build for (default: 4.1)
50+ # Forwarded as -DsparkVersion to UC's sbt; also determines the published artifact
51+ # name (unitycatalog-spark_${X.Y}_2.13). Delta's build.sbt sets this from
52+ # CrossSparkVersions when invoking the script; matrix CI workflows set it from
53+ # `matrix.spark_version`. Default matches UC's own default in
54+ # project/spark-versions.json - workflows that don't care which Spark variant UC
55+ # builds (kernel/flink/etc.) inherit it.
4956#
5057# UC_REF is restricted to exactly two values by design: the pinned SHA (the normal case) or
5158# `main` (for the floating-main canary flow). Any other value is rejected. CI should never set
@@ -65,6 +72,7 @@ UC_DIR="${UC_DIR:-/tmp/unitycatalog}"
6572UC_REPO=" ${UC_REPO:- https:// github.com/ unitycatalog/ unitycatalog.git} "
6673UC_REF=" ${UC_REF:- $UC_PIN_SHA } "
6774UC_FORCE=" ${UC_FORCE:- 0} "
75+ SPARK_VERSION=" ${SPARK_VERSION:- 4.1} "
6876
6977# Enforce the two-value contract. Anything else is either a typo or a misuse and would bypass the
7078# safety check below.
92100# Canonical Ivy + Maven artifact paths. Delta depends on all three UC modules; sbt resolves from
93101# ~/.ivy2/local, mvn (kernel-examples integration tests) resolves from ~/.m2/repository. If any
94102# is missing in either layout we must re-publish.
103+ # UC publishes its Spark connector under a per-Spark-version coordinate
104+ # (e.g. unitycatalog-spark_4.1_2.13). The suffix tracks SPARK_VERSION so the
105+ # canary check matches whatever variant we tell UC to build below.
95106IVY_LOCAL=" $HOME /.ivy2/local/io.unitycatalog"
96107IVY_CANARY_CLIENT=" $IVY_LOCAL /unitycatalog-client/$UC_VERSION /ivys/ivy.xml"
97108IVY_CANARY_SERVER=" $IVY_LOCAL /unitycatalog-server/$UC_VERSION /ivys/ivy.xml"
98- SPARK_MAJOR_MINOR=" ${SPARK_MAJOR_MINOR:- $(echo " ${SPARK_VERSION:- 4.1} " | cut -d. -f1,2)} "
99- UC_SPARK_ARTIFACT=" unitycatalog-spark_${SPARK_MAJOR_MINOR} _2.13"
109+ UC_SPARK_ARTIFACT=" unitycatalog-spark_${SPARK_VERSION} _2.13"
100110IVY_CANARY_SPARK=" $IVY_LOCAL /$UC_SPARK_ARTIFACT /$UC_VERSION /ivys/ivy.xml"
101111IVY_CANARY_HADOOP=" $IVY_LOCAL /unitycatalog-hadoop/$UC_VERSION /ivys/ivy.xml"
102112M2_LOCAL=" $HOME /.m2/repository/io/unitycatalog"
162172# coordinate. Applied as a persistent setting so it sticks across the two sbt invocations below.
163173SET_VERSION_CMD=" set ThisBuild / version := \" $UC_VERSION \" "
164174
175+ # Force publishLocal / publishM2 to overwrite existing artifacts. UC artifacts at the same
176+ # coordinate can be left behind from a prior run (e.g. cross-Spark publish re-invokes this
177+ # script for a different sparkVersion while client/server/hadoop are already in ~/.ivy2/local
178+ # and ~/.m2 from the first invocation). publishLocalConfiguration / publishM2Configuration are
179+ # task settings scoped per-project (ThisBuild / Global don't propagate), so we set them on each
180+ # project we publish. Both configs need overriding: publishLocal uses the former, publishM2
181+ # uses the latter.
182+ SET_OVERWRITE_CMDS=()
183+ for p in client server hadoop spark; do
184+ SET_OVERWRITE_CMDS+=(
185+ " set $p / publishLocalConfiguration := ($p / publishLocalConfiguration).value.withOverwrite(true)"
186+ " set $p / publishM2Configuration := ($p / publishM2Configuration).value.withOverwrite(true)"
187+ )
188+ done
189+
165190echo " >>> Building and publishing UC client + server to local Maven repo"
166191# Clear stale UC artifacts — GHA cache may restore jars from a prior run at the same coordinate,
167192# and SBT's publishM2 refuses to overwrite (ThisBuild / publishM2Configuration is ignored).
168193rm -rf " $HOME /.ivy2/local/io.unitycatalog" " $HOME /.m2/repository/io/unitycatalog"
169194./build/sbt \
170195 " $SET_VERSION_CMD " \
196+ " ${SET_OVERWRITE_CMDS[@]} " \
171197 " set client / Compile / packageDoc / publishArtifact := false" \
172198 clean \
173199 client/generate \
@@ -179,23 +205,24 @@ rm -rf "$HOME/.ivy2/local/io.unitycatalog" "$HOME/.m2/repository/io/unitycatalog
179205 hadoop/publishM2
180206
181207# Publish the Spark connector for the caller's Spark version. Each CI matrix cell passes its own
182- # SPARK_MAJOR_MINOR ; when auto-triggered by ensurePinnedUnityCatalog (no env), defaults above.
183- echo " >>> Publishing UC spark connector for Spark $SPARK_MAJOR_MINOR "
208+ # SPARK_VERSION ; when auto-triggered by ensurePinnedUnityCatalog (no env), defaults above.
209+ echo " >>> Publishing UC spark connector for Spark $SPARK_VERSION "
184210for attempt in 1 2 3; do
185211 if ./build/sbt \
186- -DsparkVersion=" $SPARK_MAJOR_MINOR " \
212+ -DsparkVersion=" $SPARK_VERSION " \
187213 -DskipDeltaSpark=true \
188214 " $SET_VERSION_CMD " \
215+ " ${SET_OVERWRITE_CMDS[@]} " \
189216 " set client / Compile / packageDoc / publishArtifact := false" \
190217 spark/publishLocal \
191218 spark/publishM2; then
192219 break
193220 fi
194221 if [[ " $attempt " -eq 3 ]]; then
195- echo " >>> spark/publishM2 (Spark $SPARK_MAJOR_MINOR ) failed after 3 attempts"
222+ echo " >>> spark/publishM2 (Spark $SPARK_VERSION ) failed after 3 attempts"
196223 exit 1
197224 fi
198- echo " >>> spark/publishM2 (Spark $SPARK_MAJOR_MINOR ) failed on attempt $attempt ; retrying..."
225+ echo " >>> spark/publishM2 (Spark $SPARK_VERSION ) failed on attempt $attempt ; retrying..."
199226 sleep 5
200227done
201228
0 commit comments