Skip to content

Commit f1394a9

Browse files
committed
JVMCBC-1650 Backport Maven Central Portal publishing changes
Motivation ---------- Align the `aurora` branch with changes in master to support publication via Maven Central Portal and GitHub Actions. Unfortunately, could not cherry-pick due to merge conflicts. Modifications ------------- Backport the following patchsets: https://review.couchbase.org/c/couchbase-jvm-clients/+/226920 https://review.couchbase.org/c/couchbase-jvm-clients/+/227011 https://review.couchbase.org/c/couchbase-jvm-clients/+/228347 https://review.couchbase.org/c/couchbase-jvm-clients/+/228435 https://review.couchbase.org/c/couchbase-jvm-clients/+/228480 The same changes are applied verbatim, with two exception: 1. In `aurora`, the parent POM's `scala-2.13` profile sets `scala.compat.library.version` to 2.13.15 to match the scala-client 1.8.1 release. This differs from the `master` branch, which upgrades that library to 2.13.16. 2. The "Deploy Snapshot" action in the `aurora` branch triggers on pushes to `aurora`, not `master`. Change-Id: I61e8d3519eec06c3e3de467ac4bffcb7b4dda71d Reviewed-on: https://review.couchbase.org/c/couchbase-jvm-clients/+/228481 Tested-by: Build Bot <[email protected]> Reviewed-by: Michael Reiche <[email protected]>
1 parent c63a30a commit f1394a9

File tree

18 files changed

+302
-96
lines changed

18 files changed

+302
-96
lines changed

.github/scripts/deploy.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
3+
# CI script for publishing to Maven Central.
4+
5+
if [ $# -ne 1 ]; then
6+
echo 1>&2 "$0: requires exactly one argument, the Maven profile (snapshot or release)"
7+
exit 2
8+
fi
9+
10+
MAVEN_PROFILE=$1
11+
12+
set -e
13+
set -x
14+
15+
./mvnw --batch-mode --file protostellar/pom.xml clean install
16+
./mvnw --batch-mode --file tracing-opentelemetry-deps/pom.xml clean install
17+
./mvnw --batch-mode --file core-io-deps/pom.xml clean install
18+
19+
# Improper shading should have been caught during PR verification, but let's double check.
20+
./mvnw --batch-mode --file core-io/pom.xml install -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
21+
cd core-io ; ./shade-check.sh ; cd ..
22+
./mvnw --batch-mode --file java-client/pom.xml install -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
23+
./mvnw --batch-mode --file tracing-opentelemetry/pom.xml install -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
24+
cd tracing-opentelemetry ; ./shade-check.sh ; cd ..
25+
26+
./mvnw --batch-mode --settings deploy-settings.xml deploy -Dgpg.signer=bc -Dsurefire.rerunFailingTestsCount=1 --activate-profiles ${MAVEN_PROFILE}
27+
./mvnw --batch-mode --settings deploy-settings.xml clean deploy -Dgpg.signer=bc -Dmaven.test.skip=true --activate-profiles ${MAVEN_PROFILE},scala-2.13 --projects scala-implicits,scala-client
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Maven Deploy Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
type: string
8+
description: Tag to release. Must already exist.
9+
required: true
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
ref: ${{ inputs.tag }}
21+
22+
- name: Verify the ref is actually a tag
23+
run: git tag --list | grep --line-regexp ${{ inputs.tag }}
24+
25+
- name: Set up JDK 21
26+
uses: actions/setup-java@v4
27+
with:
28+
java-version: '21'
29+
distribution: 'temurin'
30+
31+
- name: Build and deploy to Maven Central
32+
run: .github/scripts/deploy.sh release
33+
env:
34+
MAVEN_USERNAME: ${{ vars.MAVEN_USERNAME }}
35+
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
36+
MAVEN_GPG_KEY: ${{ secrets.SDK_ROBOT_GPG_PRIVATE_KEY }}
37+
MAVEN_GPG_PASSPHRASE: ''
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Maven Deploy Snapshot
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
6+
on:
7+
push:
8+
branches:
9+
- aurora
10+
paths-ignore:
11+
- '.gitignore'
12+
- '.editorconfig'
13+
- '.scalafmt.conf'
14+
- '*-fit-*/**'
15+
- '*-examples/**'
16+
- 'test-utils/**'
17+
- 'Jenkinsfile'
18+
- '*.md'
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Set up JDK 21
30+
uses: actions/setup-java@v4
31+
with:
32+
java-version: '21'
33+
distribution: 'temurin'
34+
35+
- name: Build and deploy to Maven Central
36+
run: .github/scripts/deploy.sh snapshot
37+
env:
38+
MAVEN_USERNAME: ${{ vars.MAVEN_USERNAME }}
39+
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
40+
MAVEN_GPG_KEY: ${{ secrets.SDK_ROBOT_GPG_PRIVATE_KEY }}
41+
MAVEN_GPG_PASSPHRASE: ''

.mvn/maven.config

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
-Dscala.compat.version=2.12
2-
-Dscala.compat.library.version=2.12.20

Jenkinsfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pipeline {
118118
expression { notTriggeredByGerrit() }
119119
}
120120
steps {
121-
buildScala(defaultBuildJvm(), "2.13", "2.13.7", REFSPEC)
121+
buildScala(defaultBuildJvm(), "2.13", REFSPEC)
122122
}
123123
}
124124

@@ -541,15 +541,14 @@ void test(Map args=[:],
541541

542542
void buildScala(Jvm buildJvm,
543543
String scalaCompatVersion,
544-
String scalaLibraryVersion,
545544
String refspec) {
546545
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
547546
cleanupWorkspace()
548547

549548
dir('couchbase-jvm-clients') {
550549
doCheckout(refspec)
551550
makeDeps(buildJvm)
552-
runMaven(buildJvm, null, "-Dmaven.test.skip -Dscala.compat.version=${scalaCompatVersion} -Dscala.compat.library.version=${scalaLibraryVersion} clean compile")
551+
runMaven(buildJvm, null, "-Dmaven.test.skip -Pscala-${scalaCompatVersion} clean compile")
553552
}
554553
}
555554
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ Yes, we need `make` because maven doesn't support the setup we need and neither
5050
want to build for different Scala versions, after the first `make` you can do this through:
5151

5252
```sh
53-
$ ./mvnw -D"scala.compat.version=2.13" -D"scala.compat.library.version=2.13.13" clean install
53+
$ ./mvnw -Pscala-2.13 clean install
5454
```
5555

5656
Notes:
5757
+ Couchbase provides, tests and supports builds for Scala 2.12 and 2.13.
58-
+ Default `scala.compat.`X properties are defined in file [.mvn/maven.config]
58+
+ Default `scala.compat.`X properties are defined as properties in file [pom.xml]
5959
+ You can always go into one of the sub-directories like `core-io` to only build or test an
6060
individual project:
6161
```shell script

columnar-java-client/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@
9090

9191
<build>
9292
<plugins>
93+
<plugin>
94+
<groupId>org.sonatype.central</groupId>
95+
<artifactId>central-publishing-maven-plugin</artifactId>
96+
</plugin>
9397
<plugin>
9498
<groupId>org.apache.maven.plugins</groupId>
9599
<artifactId>maven-source-plugin</artifactId>

core-io/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@
9090

9191
<build>
9292
<plugins>
93+
<plugin>
94+
<groupId>org.sonatype.central</groupId>
95+
<artifactId>central-publishing-maven-plugin</artifactId>
96+
</plugin>
9397
<plugin>
9498
<groupId>org.apache.maven.plugins</groupId>
9599
<artifactId>maven-source-plugin</artifactId>

deploy-settings.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- This is a Maven settings.xml file for publishing to Maven Central
2+
using credentials stored in environment variables. -->
3+
<settings>
4+
<servers>
5+
<server>
6+
<id>central</id>
7+
<username>${env.MAVEN_USERNAME}</username>
8+
<password>${env.MAVEN_PASSWORD}</password>
9+
</server>
10+
</servers>
11+
</settings>

java-client/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@
5454

5555
<build>
5656
<plugins>
57+
<plugin>
58+
<groupId>org.sonatype.central</groupId>
59+
<artifactId>central-publishing-maven-plugin</artifactId>
60+
</plugin>
5761
<plugin>
5862
<groupId>org.apache.maven.plugins</groupId>
5963
<artifactId>maven-source-plugin</artifactId>

0 commit comments

Comments
 (0)