Skip to content

Commit d2ea95f

Browse files
authored
feat: automatically publish to Maven repository (#5)
* feat: automatically publish to Maven repository * fix: add Codecov in CI
1 parent 9ceb57e commit d2ea95f

File tree

3 files changed

+239
-1
lines changed

3 files changed

+239
-1
lines changed

.github/workflows/maven-ci.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This workflow will build a Java project with Maven
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3+
4+
name: Java CI with Maven
5+
6+
on: [push, pull_request]
7+
8+
jobs:
9+
build:
10+
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
with:
17+
fetch-depth: '0'
18+
19+
- name: Set up JDK 1.8
20+
uses: actions/setup-java@v1
21+
with:
22+
java-version: 1.8
23+
server-id: ossrh
24+
server-username: OSSRH_JIRA_USERNAME
25+
server-password: OSSRH_JIRA_PASSWORD
26+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
27+
gpg-passphrase: GPG_PASSPHRASE
28+
29+
- name: Codecov
30+
uses: codecov/codecov-action@v1
31+
with:
32+
token: ${{ secrets.CODECOV_TOKEN }}
33+
34+
- name: Build with Maven
35+
run: mvn clean test
36+
37+
- name: Set up Node.js
38+
uses: actions/setup-node@v2
39+
with:
40+
node-version: 20
41+
42+
- name: Semantic Release
43+
run: |
44+
npm install -g @conveyal/maven-semantic-release semantic-release
45+
semantic-release --prepare @conveyal/maven-semantic-release --publish @semantic-release/github,@conveyal/maven-semantic-release --verify-conditions @semantic-release/github,@conveyal/maven-semantic-release --verify-release @conveyal/maven-semantic-release
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
49+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
50+
OSSRH_JIRA_USERNAME: ${{ secrets.OSSRH_JIRA_USERNAME }}
51+
OSSRH_JIRA_PASSWORD: ${{ secrets.OSSRH_JIRA_PASSWORD }}

maven-settings.xml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<settings>
2+
<servers>
3+
<server>
4+
<id>ossrh</id>
5+
<username>${OSSRH_JIRA_USERNAME}</username>
6+
<password>${OSSRH_JIRA_PASSWORD}</password>
7+
</server>
8+
</servers>
9+
<profiles>
10+
<profile>
11+
<id>ossrh</id>
12+
<activation>
13+
<activeByDefault>true</activeByDefault>
14+
</activation>
15+
<properties>
16+
<gpg.executable>gpg</gpg.executable>
17+
<gpg.keyname>${GPG_KEY_NAME}</gpg.keyname>
18+
<gpg.passphrase>${GPG_PASSPHRASE}</gpg.passphrase>
19+
</properties>
20+
</profile>
21+
</profiles>
22+
</settings>

pom.xml

+166-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,49 @@
66

77
<groupId>org.casbin</groupId>
88
<artifactId>kafka-casbin</artifactId>
9-
<version>1.0-SNAPSHOT</version>
9+
<version>1.0</version>
10+
11+
<name>kafka-casbin</name>
12+
<description>Kafka authorization plugin based on Casbin</description>
13+
<url>https://github.com/jcasbin/kafka-casbin</url>
14+
<inceptionYear>2021</inceptionYear>
15+
16+
<issueManagement>
17+
<system>Github</system>
18+
<url>https://github.com/jcasbin/kafka-casbin/issues</url>
19+
</issueManagement>
20+
21+
<parent>
22+
<groupId>org.sonatype.oss</groupId>
23+
<artifactId>oss-parent</artifactId>
24+
<version>7</version>
25+
</parent>
26+
<licenses>
27+
<license>
28+
<name>The Apache Software License, Version 2.0</name>
29+
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
30+
<distribution>repo</distribution>
31+
</license>
32+
</licenses>
33+
<scm>
34+
<url>https://github.com/jcasbin/kafka-casbin</url>
35+
<connection>[email protected]:jcasbin/kafka-casbin.git</connection>
36+
<developerConnection>https://github.com/hsluoyz</developerConnection>
37+
</scm>
38+
<developers>
39+
<developer>
40+
<name>Yang Luo</name>
41+
<email>[email protected]</email>
42+
<url>https://github.com/hsluoyz</url>
43+
</developer>
44+
</developers>
45+
46+
<distributionManagement>
47+
<snapshotRepository>
48+
<id>ossrh</id>
49+
<url>https://central.sonatype.com</url>
50+
</snapshotRepository>
51+
</distributionManagement>
1052

1153
<properties>
1254
<maven.compiler.source>8</maven.compiler.source>
@@ -63,4 +105,127 @@
63105

64106
</dependencies>
65107

108+
<build>
109+
<plugins>
110+
<plugin>
111+
<groupId>org.apache.maven.plugins</groupId>
112+
<artifactId>maven-gpg-plugin</artifactId>
113+
<version>1.5</version>
114+
<executions>
115+
<execution>
116+
<id>sign-artifacts</id>
117+
<phase>verify</phase>
118+
<goals>
119+
<goal>sign</goal>
120+
</goals>
121+
</execution>
122+
</executions>
123+
<configuration>
124+
<!-- Prevent gpg from using pinentry programs -->
125+
<gpgArguments>
126+
<arg>--pinentry-mode</arg>
127+
<arg>loopback</arg>
128+
</gpgArguments>
129+
</configuration>
130+
</plugin>
131+
<plugin>
132+
<!-- Allow attaching Javadoc during releases -->
133+
<groupId>org.apache.maven.plugins</groupId>
134+
<artifactId>maven-javadoc-plugin</artifactId>
135+
<version>2.10.4</version>
136+
<configuration>
137+
<source>11</source>
138+
<detectJavaApiLink>false</detectJavaApiLink>
139+
<!-- Turn off Java 8 strict Javadoc checking -->
140+
<additionalparam>-Xdoclint:none</additionalparam>
141+
<tags>
142+
<tag>
143+
<name>notnull</name>
144+
<placement>a</placement>
145+
<head>Not null</head>
146+
</tag>
147+
<tag>
148+
<name>default</name>
149+
<placement>a</placement>
150+
<head>Default:</head>
151+
</tag>
152+
</tags>
153+
</configuration>
154+
<executions>
155+
<!-- Compress Javadoc into JAR and include that JAR when deploying. -->
156+
<execution>
157+
<id>attach-javadocs</id>
158+
<goals>
159+
<goal>jar</goal>
160+
</goals>
161+
</execution>
162+
</executions>
163+
</plugin>
164+
<plugin>
165+
<!-- Include zipped source code in releases -->
166+
<groupId>org.apache.maven.plugins</groupId>
167+
<artifactId>maven-source-plugin</artifactId>
168+
<executions>
169+
<execution>
170+
<id>attach-sources</id>
171+
<goals>
172+
<goal>jar-no-fork</goal>
173+
</goals>
174+
</execution>
175+
</executions>
176+
</plugin>
177+
<plugin>
178+
<!-- Automatically close and deploy from OSSRH -->
179+
<groupId>org.sonatype.central</groupId>
180+
<artifactId>central-publishing-maven-plugin</artifactId>
181+
<version>0.5.0</version>
182+
<extensions>true</extensions>
183+
<configuration>
184+
<publishingServerId>ossrh</publishingServerId>
185+
<tokenAuth>true</tokenAuth>
186+
<!-- Release versions will be synced to Maven Central automatically. -->
187+
<autoPublish>true</autoPublish>
188+
</configuration>
189+
</plugin>
190+
<plugin>
191+
<groupId>org.codehaus.mojo</groupId>
192+
<artifactId>cobertura-maven-plugin</artifactId>
193+
<version>2.7</version>
194+
<configuration>
195+
<formats>
196+
<format>html</format>
197+
<format>xml</format>
198+
</formats>
199+
<check />
200+
</configuration>
201+
</plugin>
202+
<plugin>
203+
<groupId>org.eluder.coveralls</groupId>
204+
<artifactId>coveralls-maven-plugin</artifactId>
205+
<version>4.3.0</version>
206+
</plugin>
207+
<plugin>
208+
<groupId>org.jacoco</groupId>
209+
<artifactId>jacoco-maven-plugin</artifactId>
210+
<version>0.7.6.201602180812</version>
211+
<executions>
212+
<execution>
213+
<id>prepare-agent</id>
214+
<goals>
215+
<goal>prepare-agent</goal>
216+
</goals>
217+
</execution>
218+
</executions>
219+
</plugin>
220+
<plugin>
221+
<groupId>org.apache.maven.plugins</groupId>
222+
<artifactId>maven-compiler-plugin</artifactId>
223+
<configuration>
224+
<source>8</source>
225+
<target>8</target>
226+
</configuration>
227+
</plugin>
228+
</plugins>
229+
</build>
230+
66231
</project>

0 commit comments

Comments
 (0)