Skip to content

Commit 356d50a

Browse files
Setup maven release (#2)
* Add maven deploy step * fix YAML * Fix maven shade and optimize CI * fix yaml * Fix javadoc plugin
1 parent a7ccff0 commit 356d50a

File tree

3 files changed

+171
-54
lines changed

3 files changed

+171
-54
lines changed

.github/workflows/maven.yml renamed to .github/workflows/pullrequest.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
22
# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path
33

4-
name: maven
4+
name: maven-build
55

66
on:
7-
push:
8-
branches:
9-
- master
10-
- 'releases/*'
11-
- 'refs/tags/*'
127
pull_request:
138
branches:
149
- master
@@ -27,9 +22,11 @@ jobs:
2722
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
2823
settings-path: ${{ github.workspace }} # location for the settings.xml file
2924

30-
- name: Build with Maven
25+
- name: Build
3126
env:
3227
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
33-
run: |
34-
mvn clean verify -Pcoverage -Ppack --file pom.xml --batch-mode -Dsytle.colors=always --errors
35-
bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN -F unittests -f ./target/site/jacoco/jacoco.xml -n codecov-umbrella
28+
run: mvn -B package --file pom.xml -Pcoverage -Dsytle.colors=always --errors
29+
- name: Upload coverage to Codecov
30+
uses: codecov/codecov-action@v1
31+
with:
32+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/release.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
2+
# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path
3+
4+
name: maven-release
5+
6+
on:
7+
push:
8+
branches:
9+
- master
10+
- 'releases/*'
11+
- 'refs/tags/*'
12+
13+
jobs:
14+
build:
15+
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Set up JDK 1.11
21+
uses: actions/setup-java@v1
22+
with:
23+
java-version: 1.11
24+
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
25+
settings-path: ${{ github.workspace }} # location for the settings.xml file
26+
27+
- name: Build
28+
env:
29+
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
30+
run: mvn -B package --file pom.xml -Pcoverage -Dsytle.colors=always --errors
31+
- name: Upload coverage to Codecov
32+
uses: codecov/codecov-action@v1
33+
with:
34+
token: ${{ secrets.CODECOV_TOKEN }}
35+
- name: Release
36+
# if: github.event_name == 'push' && github.ref == 'refs/heads/master'
37+
uses: samuelmeuli/action-maven-publish@v1
38+
with:
39+
gpg_private_key: ${{ secrets.gpg_private_key }}
40+
gpg_passphrase: ${{ secrets.gpg_passphrase }}
41+
nexus_username: ${{ secrets.nexus_username }}
42+
nexus_password: ${{ secrets.nexus_password }}

pom.xml

Lines changed: 122 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@
247247
</dependencies>
248248

249249
<profiles>
250-
<profile>
250+
<profile>
251251
<id>coverage</id>
252252
<build>
253253
<plugins>
@@ -302,8 +302,88 @@
302302
</plugin>
303303
</plugins>
304304
</build>
305-
</profile>
306-
</profiles>
305+
</profile>
306+
307+
<profile>
308+
<id>deploy</id>
309+
<!-- Based on: https://central.sonatype.org/pages/apache-maven.html-->
310+
<build>
311+
<plugins>
312+
<plugin>
313+
<groupId>org.apache.maven.plugins</groupId>
314+
<artifactId>maven-gpg-plugin</artifactId>
315+
<version>1.6</version>
316+
<executions>
317+
<execution>
318+
<id>sign-artifacts</id>
319+
<phase>verify</phase>
320+
<goals>
321+
<goal>sign</goal>
322+
</goals>
323+
<configuration>
324+
<gpgArguments>
325+
<arg>--batch</arg>
326+
<arg>--pinentry-mode</arg>
327+
<arg>loopback</arg>
328+
</gpgArguments>
329+
</configuration>
330+
</execution>
331+
</executions>
332+
</plugin>
333+
<plugin>
334+
<groupId>org.apache.maven.plugins</groupId>
335+
<artifactId>maven-source-plugin</artifactId>
336+
<version>3.2.1</version>
337+
<executions>
338+
<execution>
339+
<id>attach-sources</id>
340+
<goals>
341+
<goal>jar-no-fork</goal>
342+
</goals>
343+
</execution>
344+
</executions>
345+
</plugin>
346+
<plugin>
347+
<groupId>org.apache.maven.plugins</groupId>
348+
<artifactId>maven-javadoc-plugin</artifactId>
349+
<version>3.2.0</version>
350+
<executions>
351+
<execution>
352+
<id>attach-javadocs</id>
353+
<goals>
354+
<goal>jar</goal>
355+
</goals>
356+
</execution>
357+
</executions>
358+
<configuration>
359+
<sourcepath>${project.build.sourceDirectory}:${project.build.directory}/generated-sources/annotations</sourcepath>
360+
<additionalDependencies>
361+
<additionalDependency>
362+
<groupId>javax.annotation</groupId>
363+
<artifactId>javax.annotation-api</artifactId>
364+
<version>1.3.2</version>
365+
</additionalDependency>
366+
367+
</additionalDependencies>
368+
<doclint>none</doclint>
369+
</configuration>
370+
371+
</plugin>
372+
<plugin>
373+
<groupId>org.sonatype.plugins</groupId>
374+
<artifactId>nexus-staging-maven-plugin</artifactId>
375+
<version>1.6.8</version>
376+
<extensions>true</extensions>
377+
<configuration>
378+
<serverId>ossrh</serverId>
379+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
380+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
381+
</configuration>
382+
</plugin>
383+
</plugins>
384+
</build>
385+
</profile>
386+
</profiles>
307387

308388
<build>
309389
<plugins>
@@ -328,50 +408,16 @@
328408
<version>2.19.1</version>
329409
</plugin>
330410
<plugin>
331-
<groupId>org.apache.maven.plugins</groupId>
332-
<artifactId>maven-source-plugin</artifactId>
333-
<version>3.0.1</version>
334-
<executions>
335-
<execution>
336-
<id>attach-sources</id>
337-
<goals>
338-
<goal>jar</goal>
339-
</goals>
340-
</execution>
341-
</executions>
342-
</plugin>
343-
<plugin>
344-
<artifactId>maven-javadoc-plugin</artifactId>
345-
<version>3.0.1</version>
346-
411+
<groupId>org.sonatype.plugins</groupId>
412+
<artifactId>nexus-staging-maven-plugin</artifactId>
413+
<version>1.6.7</version>
414+
<extensions>true</extensions>
347415
<configuration>
348-
<sourcepath>${project.build.sourceDirectory}:${project.build.directory}/generated-sources/annotations</sourcepath>
349-
<additionalDependencies>
350-
<additionalDependency>
351-
<groupId>javax.annotation</groupId>
352-
<artifactId>javax.annotation-api</artifactId>
353-
<version>1.3.2</version>
354-
</additionalDependency>
355-
356-
</additionalDependencies>
357-
<doclint>none</doclint>
416+
<serverId>ossrh</serverId>
417+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
418+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
358419
</configuration>
359420
</plugin>
360-
<plugin>
361-
<artifactId>maven-release-plugin</artifactId>
362-
<version>2.5.3</version>
363-
<configuration>
364-
<tagNameFormat>v@{project.version}</tagNameFormat>
365-
<allowTimestampedSnapshots>true</allowTimestampedSnapshots>
366-
</configuration>
367-
<dependencies>
368-
<dependency>
369-
<groupId>org.apache.maven.scm</groupId>
370-
<artifactId>maven-scm-provider-gitexe</artifactId>
371-
<version>1.9</version>
372-
</dependency>
373-
</dependencies>
374-
</plugin>
375421
<plugin>
376422
<artifactId>maven-jar-plugin</artifactId>
377423
<version>3.0.2</version>
@@ -433,6 +479,38 @@
433479
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
434480
</configuration>
435481
</plugin>
482+
<plugin>
483+
<groupId>org.apache.maven.plugins</groupId>
484+
<artifactId>maven-shade-plugin</artifactId>
485+
<version>3.2.3</version>
486+
<executions>
487+
<execution>
488+
<phase>package</phase>
489+
<goals>
490+
<goal>shade</goal>
491+
</goals>
492+
<configuration>
493+
<artifactSet>
494+
<includes>
495+
<include>${project.groupId}:${project.artifactId}</include>
496+
<include>com.squareup.okhttp3</include>
497+
<include>com.squareup.okio</include>
498+
</includes>
499+
</artifactSet>
500+
<relocations>
501+
<relocation>
502+
<pattern>okhttp3</pattern>
503+
<shadedPattern>${shade.id}.okhttp3</shadedPattern>
504+
</relocation>
505+
<relocation>
506+
<pattern>okio</pattern>
507+
<shadedPattern>${shade.id}.okio</shadedPattern>
508+
</relocation>
509+
</relocations>
510+
</configuration>
511+
</execution>
512+
</executions>
513+
</plugin>
436514
</plugins>
437515
</build>
438516
</project>

0 commit comments

Comments
 (0)