Skip to content

Commit

Permalink
23: Implement automated build and deploy to Sonatype Nexus
Browse files Browse the repository at this point in the history
- key is still propagating it may take 24 hours before it works
  • Loading branch information
John Cairns committed Sep 7, 2020
1 parent d37c238 commit 304a158
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 14 deletions.
Binary file added .github/distribution/distribution.key.gpg
Binary file not shown.
Binary file added .github/distribution/distribution_secret.key.gpg
Binary file not shown.
19 changes: 19 additions & 0 deletions .github/scripts/decrypt_secret.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
mkdir -m 700 -p ${HOME}/distribution


for keyfile in distribution.key distribution_secret.key
do

echo "Decrypt ${keyfile}"

gpg --quiet --batch --yes --decrypt --passphrase="${GPG_KEYRING}" --output ${HOME}/distribution/${keyfile} .github/distribution/${keyfile}.gpg
sha256sum ${HOME}/distribution/${keyfile}
done


echo 'Import keys'
gpg --import ${HOME}/distribution/distribution.key

gpg --allow-secret-key-import --import ${HOME}/distribution/distribution_secret.key


15 changes: 8 additions & 7 deletions .github/workflows/oss-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# This workflow will build a package using Maven and then publish it to oss.sonatype.org (Nexus Repository Manager)
# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path

name: Publish package to Maven Central Repository
Expand All @@ -9,7 +9,6 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
Expand All @@ -21,11 +20,13 @@ jobs:
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD

- name: Build with Maven
run: mvn -B clean package javadoc:jar source:jar --file pom.xml
- name: Deploy with Maven
run: mvn -B gpg:sign deploy --file pom.xml

- name: Setup GPG KeyRing
run: ./.github/scripts/decrypt_secret.sh
env:
GPG_KEYRING: ${{ secrets.GPG_KEYRING }}
- name: Build and Deploy with Maven
run: mvn --file pom.xml -D gpg.keyname=71F57B8AFAE29A33097ABFEC333223C0CA0C8429 -B clean package javadoc:jar source:jar gpg:sign deploy
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
11 changes: 4 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
</prerequisites>

<properties>
<jdk.version>9</jdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<snapshots.repo.id>ossrh</snapshots.repo.id>
Expand Down Expand Up @@ -88,10 +87,9 @@
<version>3.8.1</version>
<inherited>true</inherited>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<source>11</source>
<target>11</target>
<encoding>${project.build.sourceEncoding}</encoding>
<!-- <executable>/usr/lib/jvm/jdk-9/bin/javac</executable> -->
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -145,7 +143,7 @@
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down Expand Up @@ -204,7 +202,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.3</version>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
Expand All @@ -230,7 +228,6 @@
</pluginManagement>
</build>


<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
10 changes: 10 additions & 0 deletions settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<settings>
<servers>
<server>
<id>ossrh</id>
<username>KwiIRYwB</username>
<password>KcLTBRYUrFmgwwjJj0fZMZUpg9Fn2mCZ8oASR4KUkY03</password>
</server>
</servers>
</settings>

0 comments on commit 304a158

Please sign in to comment.