Skip to content

Commit f507c14

Browse files
committed
Use GitHub actions to deploy to OSS Sonatype/Maven Central
[pgjdbc#325]
1 parent 630712f commit f507c14

10 files changed

+146
-116
lines changed

.github/workflows/ci.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This workflow will build a Java project with Maven
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3+
4+
name: Java CI with Maven
5+
6+
on:
7+
push:
8+
branches: [ main, 0.8.x ]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up JDK 1.8
16+
uses: actions/setup-java@v1
17+
with:
18+
java-version: 1.8
19+
- name: Cache local Maven repository
20+
uses: actions/cache@v2
21+
with:
22+
path: ~/.m2/repository
23+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
24+
restore-keys: |
25+
${{ runner.os }}-maven-
26+
- name: Build with Maven
27+
env:
28+
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
29+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
30+
run: ./mvnw -B deploy -D skipITs -P snapshot -s settings.xml

.github/workflows/pullrequests.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This workflow will build a Java project with Maven
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3+
4+
name: Build Pull request with Maven
5+
6+
on: [pull_request]
7+
8+
jobs:
9+
pr-build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Set up JDK 1.8
14+
uses: actions/setup-java@v1
15+
with:
16+
java-version: 1.8
17+
- name: Cache local Maven repository
18+
uses: actions/cache@v2
19+
with:
20+
path: ~/.m2/repository
21+
key: ${{ runner.os }}-maven-pr-${{ hashFiles('**/pom.xml') }}
22+
restore-keys: |
23+
${{ runner.os }}-maven-pr-
24+
- name: Build with Maven
25+
run: ./mvnw -B verify -D skipITs

.github/workflows/release.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This workflow will build a Java project with Maven
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3+
4+
name: Stage release to Maven Central
5+
6+
on:
7+
push:
8+
branches: [ release-0.x ]
9+
10+
jobs:
11+
release:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up JDK 1.8
16+
uses: actions/setup-java@v1
17+
with:
18+
java-version: 1.8
19+
- name: Initialize Maven Version
20+
run: ./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version
21+
- name: GPG Check
22+
run: gpg -k
23+
- name: Release with Maven
24+
env:
25+
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
26+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
27+
GPG_KEY_BASE64: ${{ secrets.GPG_KEY_BASE64 }}
28+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
29+
run: ci/build-and-deploy-to-maven-central.sh

README.md

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PostgreSQL R2DBC Driver [![Build Status](https://travis-ci.org/r2dbc/r2dbc-postgresql.svg?branch=main)](https://travis-ci.org/r2dbc/r2dbc-postgresql) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.r2dbc/r2dbc-postgresql/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.r2dbc/r2dbc-postgresql)
1+
# PostgreSQL R2DBC Driver [![Java CI with Maven](https://github.com/pgjdbc/r2dbc-postgresql/workflows/Java%20CI%20with%20Maven/badge.svg?branch=main)](https://github.com/pgjdbc/r2dbc-postgresql/actions?query=workflow%3A%22Java+CI+with+Maven%22+branch%3Amain) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.r2dbc/r2dbc-postgresql/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.r2dbc/r2dbc-postgresql)
22

33
This project contains the [PostgreSQL][p] implementation of the [R2DBC SPI][r]. This implementation is not intended to be used directly, but rather to be used as the backing implementation for a humane client library to delegate to.
44

@@ -154,16 +154,11 @@ If you'd rather like the latest snapshots of the upcoming major version, use our
154154
<version>${version}.BUILD-SNAPSHOT</version>
155155
</dependency>
156156

157-
<repositories>
158-
<repository>
159-
<id>sonatype-snapshots</id>
160-
<name>Sonatype Snapshot Repository</name>
161-
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
162-
<snapshots>
163-
<enabled>true</enabled>
164-
</snapshots>
165-
</repository>
166-
</repositories>
157+
<repository>
158+
<id>sonatype-nexus-snapshots</id>
159+
<name>Sonatype OSS Snapshot Repository</name>
160+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
161+
</repository>
167162
```
168163

169164
## Listen/Notify

ci/build-and-deploy-to-artifactory.sh

-10
This file was deleted.

ci/build-and-deploy-to-maven-central.sh

+33-16
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,39 @@
1-
#!/bin/bash -x
1+
#!/bin/bash
22

33
set -euo pipefail
44

5-
#
6-
# Stage on Maven Central
7-
#
8-
echo 'Staging on Maven Central...'
5+
VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -o | grep -v INFO)
96

10-
GNUPGHOME=/tmp/gpghome
11-
export GNUPGHOME
7+
if [[ $VERSION =~ [^.*-SNAPSHOT$] ]] ; then
128

13-
mkdir $GNUPGHOME
14-
cp $KEYRING $GNUPGHOME
9+
echo "Cannot deploy a snapshot: $VERSION"
10+
exit 1
11+
fi
12+
13+
if [[ $VERSION =~ [^(\d+\.)+(RC(\d+)|M(\d+)|RELEASE)$] ]] ; then
14+
15+
#
16+
# Prepare GPG Key is expected to be in base64
17+
# Exported with gpg -a --export-secret-keys "your@email" | base64 > gpg.base64
18+
#
19+
printf "$GPG_KEY_BASE64" | base64 --decode > gpg.asc
20+
echo ${GPG_PASSPHRASE} | gpg --batch --yes --passphrase-fd 0 --import gpg.asc
21+
gpg -k
22+
23+
#
24+
# Stage on Maven Central
25+
#
26+
echo "Staging $VERSION to Maven Central"
27+
28+
./mvnw \
29+
-s settings.xml \
30+
-Pcentral \
31+
-Dmaven.test.skip=true \
32+
-Dgpg.passphrase=${GPG_PASSPHRASE} \
33+
clean deploy -B -D skipITs
34+
else
35+
36+
echo "Not a release: $VERSION"
37+
exit 1
38+
fi
1539

16-
MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw \
17-
-s settings.xml \
18-
-P${PROFILE} \
19-
-Dmaven.test.skip=true \
20-
-Dgpg.passphrase=${PASSPHRASE} \
21-
-Dgpg.secretKeyring=${GNUPGHOME}/secring.gpg \
22-
clean deploy -B

ci/create-release.sh

-18
This file was deleted.

ci/test.sh

-5
This file was deleted.

pom.xml

+20-53
Original file line numberDiff line numberDiff line change
@@ -439,47 +439,6 @@
439439

440440
<profiles>
441441

442-
<profile>
443-
<id>snapshot</id>
444-
445-
<build>
446-
<plugins>
447-
<plugin>
448-
<groupId>org.jfrog.buildinfo</groupId>
449-
<artifactId>artifactory-maven-plugin</artifactId>
450-
<version>2.6.1</version>
451-
<inherited>false</inherited>
452-
<executions>
453-
<execution>
454-
<id>build-info</id>
455-
<goals>
456-
<goal>publish</goal>
457-
</goals>
458-
<configuration>
459-
<buildInfo>
460-
<buildUrl>{{BUILD_URL}}</buildUrl>
461-
</buildInfo>
462-
<deployProperties>
463-
<zip.name>r2dbc-postgresql</zip.name>
464-
<zip.displayname>r2dbc-postgresql</zip.displayname>
465-
<zip.deployed>false</zip.deployed>
466-
<archives>*:*:*:*@zip</archives>
467-
</deployProperties>
468-
<publisher>
469-
<contextUrl>https://repo.spring.io</contextUrl>
470-
<username>{{ARTIFACTORY_USR}}</username>
471-
<password>{{ARTIFACTORY_PSW}}</password>
472-
<repoKey>libs-snapshot-local</repoKey>
473-
<snapshotRepoKey>libs-snapshot-local</snapshotRepoKey>
474-
</publisher>
475-
</configuration>
476-
</execution>
477-
</executions>
478-
</plugin>
479-
</plugins>
480-
</build>
481-
</profile>
482-
483442
<profile>
484443
<id>jmh</id>
485444
<dependencies>
@@ -572,15 +531,25 @@
572531
</repositories>
573532
</profile>
574533

575-
<profile>
576-
<id>central</id>
577-
<build>
578-
<pluginManagement>
579-
<plugins>
534+
<profile>
535+
<id>snapshot</id>
536+
<distributionManagement>
537+
<snapshotRepository>
538+
<id>sonatype</id>
539+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
540+
</snapshotRepository>
541+
</distributionManagement>
542+
</profile>
543+
544+
<profile>
545+
<id>central</id>
546+
<build>
547+
<pluginManagement>
548+
<plugins>
580549

581-
<!-- Sign JARs -->
550+
<!-- Sign JARs -->
582551

583-
<plugin>
552+
<plugin>
584553
<groupId>org.apache.maven.plugins</groupId>
585554
<artifactId>maven-gpg-plugin</artifactId>
586555
<version>1.6</version>
@@ -649,11 +618,9 @@
649618

650619
<repositories>
651620
<repository>
652-
<id>spring-libs-snapshot</id>
653-
<url>https://repo.spring.io/libs-snapshot</url>
654-
<snapshots>
655-
<enabled>true</enabled>
656-
</snapshots>
621+
<id>sonatype-nexus-snapshots</id>
622+
<name>Sonatype OSS Snapshot Repository</name>
623+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
657624
</repository>
658625
</repositories>
659626

settings.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<servers>
66
<server>
77
<id>sonatype</id>
8-
<username>${env.SONATYPE_USR}</username>
9-
<password>${env.SONATYPE_PSW}</password>
8+
<username>${env.SONATYPE_USER}</username>
9+
<password>${env.SONATYPE_PASSWORD}</password>
1010
</server>
1111
</servers>
12-
</settings>
12+
</settings>

0 commit comments

Comments
 (0)