Skip to content

Commit 092f59b

Browse files
committed
Use GitHub actions to deploy to OSS Sonatype/Maven Central
[#325]
1 parent cb6c2f4 commit 092f59b

12 files changed

+144
-332
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

CI.adoc

-23
This file was deleted.

Jenkinsfile

-102
This file was deleted.

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Reactive Relational Database Connectivity PostgreSQL Implementation [![Build Status](https://travis-ci.org/r2dbc/r2dbc-postgresql.svg?branch=0.8.x)](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+
# Reactive Relational Database Connectivity PostgreSQL Implementation [![Java CI with Maven](https://github.com/pgjdbc/r2dbc-postgresql/workflows/Java%20CI%20with%20Maven/badge.svg?branch=0.8.x)](https://github.com/pgjdbc/r2dbc-postgresql/actions?query=workflow%3A%22Java+CI+with+Maven%22+branch%3A0.8.x) [![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

@@ -152,9 +152,9 @@ If you'd rather like the latest snapshots of the upcoming major version, use our
152152
</dependency>
153153

154154
<repository>
155-
<id>spring-libs-snapshot</id>
156-
<name>Spring Snapshot Repository</name>
157-
<url>https://repo.spring.io/libs-snapshot</url>
155+
<id>sonatype-nexus-snapshots</id>
156+
<name>Sonatype OSS Snapshot Repository</name>
157+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
158158
</repository>
159159
```
160160

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.

0 commit comments

Comments
 (0)