Skip to content

Commit e077bdf

Browse files
author
yutaipu
committed
加上github work flows
1 parent 5f8fec8 commit e077bdf

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

.github/workflows/maven.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish package to the Maven Central Repository
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Set up JDK 1.8
13+
uses: actions/setup-java@v1
14+
with:
15+
java-version: 1.8
16+
17+
- name: Build with Maven
18+
run: mvn -B clean package -Dmaven.test.skip
19+
20+
- name: Set up Apache Maven Central
21+
uses: actions/setup-java@v1
22+
with: # running setup-java again overwrites the settings.xml
23+
java-version: 1.8
24+
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
25+
server-username: MAVEN_USERNAME # env variable for username in deploy
26+
server-password: MAVEN_PASSWORD # env variable for token in deploy
27+
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
28+
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
29+
30+
- name: Publish to Apache Maven Central
31+
run: mvn deploy -Dmaven.test.skip
32+
env:
33+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
34+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
35+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

pom.xml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,82 @@
169169
</dependencies>
170170
</plugin>
171171

172+
<!-- 参考 https://docs.github.com/cn/actions/language-and-framework-guides/publishing-java-packages-with-maven#about-package-configuration -->
173+
<!-- 参考 https://github.com/actions/setup-java -->
174+
<!-- 参考 https://central.sonatype.org/pages/apache-maven.html -->
175+
176+
<!-- Javadoc和源代码附件 -->
177+
<plugin>
178+
<groupId>org.apache.maven.plugins</groupId>
179+
<artifactId>maven-source-plugin</artifactId>
180+
<version>2.2.1</version>
181+
<executions>
182+
<execution>
183+
<id>attach-sources</id>
184+
<goals>
185+
<goal>jar-no-fork</goal>
186+
</goals>
187+
</execution>
188+
</executions>
189+
</plugin>
190+
<plugin>
191+
<groupId>org.apache.maven.plugins</groupId>
192+
<artifactId>maven-javadoc-plugin</artifactId>
193+
<version>2.9.1</version>
194+
<executions>
195+
<execution>
196+
<id>attach-javadocs</id>
197+
<goals>
198+
<goal>jar</goal>
199+
</goals>
200+
</execution>
201+
</executions>
202+
</plugin>
203+
204+
<!-- GPG签名组件 -->
205+
<plugin>
206+
<groupId>org.apache.maven.plugins</groupId>
207+
<artifactId>maven-gpg-plugin</artifactId>
208+
<version>1.5</version>
209+
<executions>
210+
<execution>
211+
<id>sign-artifacts</id>
212+
<phase>verify</phase>
213+
<goals>
214+
<goal>sign</goal>
215+
</goals>
216+
</execution>
217+
</executions>
218+
</plugin>
219+
220+
<!-- Nexus Staging Maven插件,用于部署和发布 -->
221+
<plugin>
222+
<groupId>org.sonatype.plugins</groupId>
223+
<artifactId>nexus-staging-maven-plugin</artifactId>
224+
<version>1.6.7</version>
225+
<extensions>true</extensions>
226+
<configuration>
227+
<serverId>ossrh</serverId>
228+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
229+
<!-- 手动release -->
230+
<autoReleaseAfterClose>false</autoReleaseAfterClose>
231+
</configuration>
232+
</plugin>
233+
172234
</plugins>
173235
</build>
174236

237+
<distributionManagement>
238+
<snapshotRepository>
239+
<id>ossrh</id>
240+
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
241+
</snapshotRepository>
242+
<repository>
243+
<id>ossrh</id>
244+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
245+
</repository>
246+
</distributionManagement>
247+
175248
<reporting>
176249
<plugins>
177250

0 commit comments

Comments
 (0)