-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use GitHub actions to deploy to OSS Sonatype/Maven Central
[#325]
- Loading branch information
Showing
10 changed files
with
146 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters