diff --git a/.github/workflows/maven-publish-modules.yml b/.github/workflows/maven-publish-modules.yml new file mode 100644 index 00000000000..596ede35560 --- /dev/null +++ b/.github/workflows/maven-publish-modules.yml @@ -0,0 +1,44 @@ +name: Publish unified query modules to maven + +on: + workflow_dispatch: + push: + branches: + - main + - 1.* + - 2.* + - feature/unified-ppl # Temporarily added for testing + +env: + SNAPSHOT_REPO_URL: https://aws.oss.sonatype.org/content/repositories/snapshots/ + +jobs: + publish-unified-query-modules: + strategy: + fail-fast: false + if: github.repository == 'opensearch-project/sql' + runs-on: ubuntu-latest + + permissions: + id-token: write + contents: write + + steps: + - uses: actions/setup-java@v3 + with: + distribution: temurin # Temurin is a distribution of adoptium + java-version: 21 + - uses: actions/checkout@v3 + - uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + role-to-assume: ${{ secrets.PUBLISH_SNAPSHOTS_ROLE }} + aws-region: us-east-1 + + - name: get credentials + run: | + # Get credentials for publishing + .github/get-sonatype-credentials.sh + + - name: publish unified query modules to maven + run: | + ./gradlew publishUnifiedQueryPublicationToSnapshotsRepository \ No newline at end of file diff --git a/build.gradle b/build.gradle index 68161e30c2a..e57e3522121 100644 --- a/build.gradle +++ b/build.gradle @@ -160,6 +160,52 @@ subprojects { maven { url "https://ci.opensearch.org/ci/dbc/snapshots/lucene/" } maven { url 'https://jitpack.io' } } + + // Publish internal modules as Maven artifacts for external use, such as by opensearch-spark and opensearch-cli. + def publishedModules = ['sql', 'ppl', 'core', 'opensearch', 'common', 'protocol'] + if (publishedModules.contains(name)) { + apply plugin: 'java-library' + apply plugin: 'maven-publish' + + def fullArtifactId = "unified-query-${project.name}" + publishing { + publications { + unifiedQuery(MavenPublication) { + from components.java + groupId = "org.opensearch.query" + artifactId = fullArtifactId + + pom { + name = fullArtifactId + description = "OpenSearch unified query ${project.name} module" + licenses { + license { + name = 'The Apache License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + developers { + developer { + name = 'OpenSearch' + url = 'https://github.com/opensearch-project/sql' + } + } + } + } + } + + repositories { + maven { + name = "Snapshots" + url = "https://aws.oss.sonatype.org/content/repositories/snapshots" + credentials { + username = "$System.env.SONATYPE_USERNAME" + password = "$System.env.SONATYPE_PASSWORD" + } + } + } + } + } } // TODO: fix compiler warnings