diff --git a/.github/workflows/Java.yml b/.github/workflows/Java.yml index 7db850fae..bb40aa719 100644 --- a/.github/workflows/Java.yml +++ b/.github/workflows/Java.yml @@ -107,7 +107,7 @@ jobs: # ./scripts/upload-assets-to-staging.sh github_release duckdb_jdbc-linux-aarch64.jar - uses: actions/upload-artifact@v3 - with: + with: name: java-linux-aarch64 path: | build/release/duckdb_jdbc.jar @@ -196,6 +196,58 @@ jobs: path: | build/release/duckdb_jdbc.jar + java-linux-amd64-musl: + name: Java Musllinux (amd64) + runs-on: ubuntu-latest + container: + image: alpine:latest + env: + GEN: ninja + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true + DUCKDB_PLATFORM: linux_amd64_musl + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ inputs.git_ref }} + + - name: Prepare Alpine Container + shell: sh + + run: | + # Update package lists and install essential build tools + apk update + apk add --no-cache bash boost-dev build-base cmake gcc g++ git libstdc++ make ninja openjdk17 openjdk17-jdk pkgconfig + + rm -rf /var/cache/apk/* + + # Set Java environment variables + echo "JAVA_HOME=/usr/lib/jvm/java-17-openjdk" >> $GITHUB_ENV + echo "/usr/lib/jvm/java-17-openjdk/bin:${PATH}" >> $GITHUB_PATH + + - name: Build + shell: bash + run: make release + + - name: Java Tests + shell: bash + if: ${{ inputs.skip_tests != 'true' }} + run: make test + + - name: Deploy + shell: bash + env: + AWS_ACCESS_KEY_ID: ${{ secrets.S3_DUCKDB_STAGING_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_DUCKDB_STAGING_KEY }} + run: | + cp build/release/duckdb_jdbc.jar duckdb_jdbc-linux-amd64-musl.jar + ./scripts/upload-assets-to-staging.sh github_release duckdb_jdbc-linux-amd64-musl.jar + + - uses: actions/upload-artifact@v3 + with: + name: java-linux-amd64-musl + path: | + build/release/duckdb_jdbc.jar java-combine: if: ${{ inputs.override_git_describe == '' }} @@ -206,6 +258,7 @@ jobs: - java-linux-amd64 - java-windows-amd64 - java-osx-universal + - java-linux-amd64-musl steps: - uses: actions/checkout@v3 @@ -236,6 +289,11 @@ jobs: name: java-osx-universal path: jdbc-artifacts/java-osx-universal + - uses: actions/download-artifact@v3 + with: + name: java-linux-amd64-musl + path: jdbc-artifacts/java-linux-amd64-musl + - name: Combine JARs shell: bash run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index a6cacc0fd..48d619eca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,6 @@ else() set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") endif() - set(OS_NAME "unknown") set(OS_ARCH "amd64") @@ -65,12 +64,31 @@ if(OVERRIDE_JDBC_OS_ARCH) set(OS_ARCH ${OVERRIDE_JDBC_OS_ARCH}) endif() +# Check if the current system is Alpine Linux +function(is_alpine_linux RESULT) + if(UNIX AND NOT APPLE) + if(EXISTS "/etc/os-release") + file(READ "/etc/os-release" OS_RELEASE_CONTENTS) + string(FIND "${OS_RELEASE_CONTENTS}" "Alpine Linux" ALPINE_FOUND) + + if(ALPINE_FOUND GREATER -1) + set(${RESULT} TRUE PARENT_SCOPE) + else() + set(${RESULT} FALSE PARENT_SCOPE) + endif() + else() + set(${RESULT} FALSE PARENT_SCOPE) + endif() + else() + set(${RESULT} FALSE PARENT_SCOPE) + endif() +endfunction() + add_jar(duckdb_jdbc ${JAVA_SRC_FILES} META-INF/services/java.sql.Driver GENERATE_NATIVE_HEADERS duckdb-native) add_jar(duckdb_jdbc_tests ${JAVA_TEST_FILES} INCLUDE_JARS duckdb_jdbc) - set(DUCKDB_SYSTEM_LIBS ${CMAKE_DL_LIBS}) if(MSVC) @@ -82,6 +100,7 @@ target_compile_options(duckdb_java PRIVATE -fexceptions) target_link_libraries(duckdb_java duckdb-native ) target_link_libraries(duckdb_java ${DUCKDB_SYSTEM_LIBS}) + string(JOIN "_" LIB_SUFFIX ".so" ${OS_NAME} ${OS_ARCH}) set_target_properties(duckdb_java PROPERTIES SUFFIX ${LIB_SUFFIX}) set_target_properties(duckdb_java PROPERTIES PREFIX "lib") diff --git a/scripts/jdbc_maven_deploy.py b/scripts/jdbc_maven_deploy.py index 9f40fe469..b4c53c8b7 100644 --- a/scripts/jdbc_maven_deploy.py +++ b/scripts/jdbc_maven_deploy.py @@ -58,7 +58,7 @@ def exec(cmd): jdbc_artifact_dir = sys.argv[2] jdbc_root_path = sys.argv[3] -combine_builds = ['linux-amd64', 'osx-universal', 'windows-amd64', 'linux-aarch64'] +combine_builds = ['linux-amd64', 'osx-universal', 'windows-amd64', 'linux-aarch64', 'linux-amd64-musl'] staging_dir = tempfile.mkdtemp()