Skip to content

Release Thin JAR

Release Thin JAR #19

Workflow file for this run

name: Release Thin JAR
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
publish-thin:
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Java for publishing to Maven Central Repository
uses: actions/setup-java@v4
with:
java-version: 11
distribution: "adopt"
server-id: central
server-username: MAVEN_CENTRAL_USERNAME
server-password: MAVEN_CENTRAL_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Configure GPG
run: |
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
gpg-connect-agent reloadagent /bye
- name: Build thin JAR
run: |
mvn -B -DskipTests package
- name: Sign thin JAR
run: |
VERSION=$(grep -m1 '<version>' pom.xml | sed 's/.*<version>\(.*\)<\/version>.*/\1/')
THIN_JAR="target/databricks-jdbc-${VERSION}-thin.jar"
echo "$GPG_PASSPHRASE" | gpg --batch --yes --passphrase-fd 0 --pinentry-mode loopback \
--armor --detach-sign "$THIN_JAR"
env:
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Verify thin jar exists
run: |
VERSION=$(grep -m1 '<version>' pom.xml | sed 's/.*<version>\(.*\)<\/version>.*/\1/')
test -f "target/databricks-jdbc-${VERSION}-thin.jar"
test -f "target/databricks-jdbc-${VERSION}-thin.jar.asc"
- name: Publish Thin JAR as Separate Artifact to Maven Central
run: |
VERSION=$(grep -m1 '<version>' pom.xml | sed 's/.*<version>\(.*\)<\/version>.*/\1/')
THIN_JAR="target/databricks-jdbc-${VERSION}-thin.jar"
echo "Creating deployment bundle for thin JAR..."
# Create staging directory
mkdir -p target/thin-staging/com/databricks/databricks-jdbc-thin/${VERSION}
# Copy thin JAR and its signature
cp "$THIN_JAR" target/thin-staging/com/databricks/databricks-jdbc-thin/${VERSION}/databricks-jdbc-thin-${VERSION}.jar
cp "${THIN_JAR}.asc" target/thin-staging/com/databricks/databricks-jdbc-thin/${VERSION}/databricks-jdbc-thin-${VERSION}.jar.asc
# Copy POM and sign it
cp thin_public_pom.xml target/thin-staging/com/databricks/databricks-jdbc-thin/${VERSION}/databricks-jdbc-thin-${VERSION}.pom
echo "$GPG_PASSPHRASE" | gpg --batch --yes --passphrase-fd 0 --pinentry-mode loopback \
--armor --detach-sign \
target/thin-staging/com/databricks/databricks-jdbc-thin/${VERSION}/databricks-jdbc-thin-${VERSION}.pom
# Generate checksums
cd target/thin-staging/com/databricks/databricks-jdbc-thin/${VERSION}
for file in databricks-jdbc-thin-*; do
md5sum "$file" | awk '{print $1}' > "${file}.md5"
sha1sum "$file" | awk '{print $1}' > "${file}.sha1"
done
cd $GITHUB_WORKSPACE
# Create bundle ZIP
cd target/thin-staging
zip -r ../central-thin-bundle.zip com/
cd $GITHUB_WORKSPACE
echo "Uploading bundle to Maven Central Portal..."
# Upload to new Maven Central Portal
curl -X POST \
-u "$MAVEN_CENTRAL_USERNAME:$MAVEN_CENTRAL_PASSWORD" \
-F "bundle=@target/central-thin-bundle.zip" \
-F "publishingType=AUTOMATIC" \
-w "\nHTTP_STATUS:%{http_code}\n" \
https://central.sonatype.com/api/v1/publisher/upload
echo "Thin JAR published successfully!"
env:
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
- name: Upload Thin JAR to GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
target/*-thin.jar