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
[resolves #173]
  • Loading branch information
mp911de committed Oct 15, 2020
1 parent 875d39e commit 02cd2cf
Show file tree
Hide file tree
Showing 13 changed files with 214 additions and 405 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
23 changes: 0 additions & 23 deletions CI.adoc

This file was deleted.

102 changes: 0 additions & 102 deletions Jenkinsfile

This file was deleted.

13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Reactive Relational Database Connectivity Microsoft SQL Server Implementation [![Build Status](https://travis-ci.org/r2dbc/r2dbc-mssql.svg?branch=0.8.x)](https://travis-ci.org/r2dbc/r2dbc-mssql) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.r2dbc/r2dbc-mssql/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.r2dbc/r2dbc-mssql)
# Reactive Relational Database Connectivity Microsoft SQL Server Implementation [![Java CI with Maven](https://github.com/r2dbc/r2dbc-mssql/workflows/Java%20CI%20with%20Maven/badge.svg?branch=0.8.x)](https://github.com/r2dbc/r2dbc-mssql/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-mssql/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.r2dbc/r2dbc-mssql)


This project contains the [Microsoft SQL Server][m] 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 @@ -137,9 +138,9 @@ If you'd rather like the latest snapshots of the upcoming major version, use our
</dependency>

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

Expand Down Expand Up @@ -293,6 +294,10 @@ Running the JMH benchmarks builds and runs the benchmarks without running tests.
$ ./mvnw clean install -Pjmh
```

## Staging to Maven Central

To stage a release to Maven Central, you need to create a release tag (release version) that contains the desired state and version numbers (`mvn versions:set versions:commit -q -o -DgenerateBackupPoms=false -DnewVersion=x.y.z.(RELEASE|Mnnn|RCnnn`) and force-push it to the `release-0.x` branch. This push will trigger a Maven staging build (see `build-and-deploy-to-maven-central.sh`).

## License

R2DBC MSSQL is Open Source software released under the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0.html).
9 changes: 0 additions & 9 deletions ci/Dockerfile

This file was deleted.

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.

Loading

0 comments on commit 02cd2cf

Please sign in to comment.