Skip to content

Commit

Permalink
Use GitHub actions to deploy to OSS Sonatype/Maven Central
Browse files Browse the repository at this point in the history
  • Loading branch information
mp911de committed Oct 15, 2020
1 parent 630712f commit f507c14
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 116 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Java CI with Maven

on:
push:
branches: [ main, 0.8.x ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
env:
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: ./mvnw -B deploy -D skipITs -P snapshot -s settings.xml
25 changes: 25 additions & 0 deletions .github/workflows/pullrequests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Build Pull request with Maven

on: [pull_request]

jobs:
pr-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-pr-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-pr-
- name: Build with Maven
run: ./mvnw -B verify -D skipITs
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Stage release to Maven Central

on:
push:
branches: [ release-0.x ]

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Initialize Maven Version
run: ./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version
- name: GPG Check
run: gpg -k
- name: Release with Maven
env:
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_KEY_BASE64: ${{ secrets.GPG_KEY_BASE64 }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: ci/build-and-deploy-to-maven-central.sh
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 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)
# 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)

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.

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

<repositories>
<repository>
<id>sonatype-snapshots</id>
<name>Sonatype Snapshot Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype OSS Snapshot Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
```

## Listen/Notify
Expand Down
10 changes: 0 additions & 10 deletions ci/build-and-deploy-to-artifactory.sh

This file was deleted.

49 changes: 33 additions & 16 deletions ci/build-and-deploy-to-maven-central.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,39 @@
#!/bin/bash -x
#!/bin/bash

set -euo pipefail

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

GNUPGHOME=/tmp/gpghome
export GNUPGHOME
if [[ $VERSION =~ [^.*-SNAPSHOT$] ]] ; then

mkdir $GNUPGHOME
cp $KEYRING $GNUPGHOME
echo "Cannot deploy a snapshot: $VERSION"
exit 1
fi

if [[ $VERSION =~ [^(\d+\.)+(RC(\d+)|M(\d+)|RELEASE)$] ]] ; then

#
# Prepare GPG Key is expected to be in base64
# Exported with gpg -a --export-secret-keys "your@email" | base64 > gpg.base64
#
printf "$GPG_KEY_BASE64" | base64 --decode > gpg.asc
echo ${GPG_PASSPHRASE} | gpg --batch --yes --passphrase-fd 0 --import gpg.asc
gpg -k

#
# Stage on Maven Central
#
echo "Staging $VERSION to Maven Central"

./mvnw \
-s settings.xml \
-Pcentral \
-Dmaven.test.skip=true \
-Dgpg.passphrase=${GPG_PASSPHRASE} \
clean deploy -B -D skipITs
else

echo "Not a release: $VERSION"
exit 1
fi

MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw \
-s settings.xml \
-P${PROFILE} \
-Dmaven.test.skip=true \
-Dgpg.passphrase=${PASSPHRASE} \
-Dgpg.secretKeyring=${GNUPGHOME}/secring.gpg \
clean deploy -B
18 changes: 0 additions & 18 deletions ci/create-release.sh

This file was deleted.

5 changes: 0 additions & 5 deletions ci/test.sh

This file was deleted.

73 changes: 20 additions & 53 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -439,47 +439,6 @@

<profiles>

<profile>
<id>snapshot</id>

<build>
<plugins>
<plugin>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>artifactory-maven-plugin</artifactId>
<version>2.6.1</version>
<inherited>false</inherited>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>publish</goal>
</goals>
<configuration>
<buildInfo>
<buildUrl>{{BUILD_URL}}</buildUrl>
</buildInfo>
<deployProperties>
<zip.name>r2dbc-postgresql</zip.name>
<zip.displayname>r2dbc-postgresql</zip.displayname>
<zip.deployed>false</zip.deployed>
<archives>*:*:*:*@zip</archives>
</deployProperties>
<publisher>
<contextUrl>https://repo.spring.io</contextUrl>
<username>{{ARTIFACTORY_USR}}</username>
<password>{{ARTIFACTORY_PSW}}</password>
<repoKey>libs-snapshot-local</repoKey>
<snapshotRepoKey>libs-snapshot-local</snapshotRepoKey>
</publisher>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>jmh</id>
<dependencies>
Expand Down Expand Up @@ -572,15 +531,25 @@
</repositories>
</profile>

<profile>
<id>central</id>
<build>
<pluginManagement>
<plugins>
<profile>
<id>snapshot</id>
<distributionManagement>
<snapshotRepository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
</profile>

<profile>
<id>central</id>
<build>
<pluginManagement>
<plugins>

<!-- Sign JARs -->
<!-- Sign JARs -->

<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
Expand Down Expand Up @@ -649,11 +618,9 @@

<repositories>
<repository>
<id>spring-libs-snapshot</id>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype OSS Snapshot Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>

Expand Down
6 changes: 3 additions & 3 deletions settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<servers>
<server>
<id>sonatype</id>
<username>${env.SONATYPE_USR}</username>
<password>${env.SONATYPE_PSW}</password>
<username>${env.SONATYPE_USER}</username>
<password>${env.SONATYPE_PASSWORD}</password>
</server>
</servers>
</settings>
</settings>

0 comments on commit f507c14

Please sign in to comment.