Skip to content

Commit 03415a6

Browse files
author
zhanq
committed
update publish
1 parent 1bbe8b3 commit 03415a6

File tree

2 files changed

+32
-136
lines changed

2 files changed

+32
-136
lines changed

.github/workflows/maven.yml

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,27 @@
11
name: Publish package to the Maven Central Repository
22
on:
33
release:
4-
types: [published]
5-
4+
types: [released]
65
jobs:
76
publish:
87
runs-on: ubuntu-latest
9-
108
steps:
119
- uses: actions/checkout@v2
12-
- name: Set up JDK 1.8
13-
uses: actions/setup-java@v1
10+
- name: Set up Maven Central Repository
11+
uses: actions/setup-java@v2
1412
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 -X deploy -Dmaven.test.skip
13+
java-version: '8'
14+
distribution: 'adopt'
15+
server-id: ossrh
16+
server-username: MAVEN_USERNAME
17+
server-password: MAVEN_PASSWORD
18+
- id: install-secret-key
19+
name: Install gpg secret key
20+
run: |
21+
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
22+
gpg --list-secret-keys --keyid-format LONG
23+
- name: Publish package
3224
env:
3325
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
34-
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
35-
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
26+
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
27+
run: mvn --batch-mode -Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} clean deploy

pom.xml

Lines changed: 16 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -107,73 +107,17 @@
107107

108108
<build>
109109
<plugins>
110-
111-
<plugin>
112-
<groupId>org.apache.maven.plugins</groupId>
113-
<artifactId>maven-release-plugin</artifactId>
114-
<version>2.5.1</version>
115-
</plugin>
116-
117-
<plugin>
118-
<artifactId>maven-compiler-plugin</artifactId>
119-
<version>3.5.1</version>
120-
<configuration>
121-
<source>${jdkVersion}</source>
122-
<target>${jdkVersion}</target>
123-
<compilerVersion>1.5</compilerVersion>
124-
<showDeprecation>true</showDeprecation>
125-
<showWarnings>true</showWarnings>
126-
<debug>true</debug>
127-
<fork>true</fork>
128-
<compilerArgs>
129-
<arg>-Xlint:unchecked</arg>
130-
</compilerArgs>
131-
</configuration>
132-
</plugin>
133-
134110
<plugin>
135-
<groupId>com.github.github</groupId>
136-
<artifactId>site-maven-plugin</artifactId>
137-
<version>0.12</version>
138-
<configuration>
139-
<message>Creating site for ${project.version}</message>
140-
<server>github</server>
141-
</configuration>
142-
<executions>
143-
<execution>
144-
<goals>
145-
<goal>site</goal>
146-
</goals>
147-
<phase>site</phase>
148-
</execution>
149-
</executions>
150-
</plugin>
151-
152-
<plugin>
153-
<groupId>org.apache.maven.plugins</groupId>
154-
<artifactId>maven-surefire-plugin</artifactId>
155-
<version>2.17</version>
111+
<groupId>org.sonatype.plugins</groupId>
112+
<artifactId>nexus-staging-maven-plugin</artifactId>
113+
<version>1.6.7</version>
114+
<extensions>true</extensions>
156115
<configuration>
157-
<groups>cn.jpush.api.FastTests</groups>
158-
<argLine>-Dfile.encoding=UTF-8</argLine>
159-
<excludes>
160-
<exclude>**/mock/*Test.java</exclude>
161-
</excludes>
116+
<serverId>ossrh</serverId>
117+
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
118+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
162119
</configuration>
163-
<dependencies>
164-
<dependency>
165-
<groupId>org.apache.maven.surefire</groupId>
166-
<artifactId>surefire-junit47</artifactId>
167-
<version>2.17</version>
168-
</dependency>
169-
</dependencies>
170120
</plugin>
171-
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和源代码附件 -->
177121
<plugin>
178122
<groupId>org.apache.maven.plugins</groupId>
179123
<artifactId>maven-source-plugin</artifactId>
@@ -200,8 +144,6 @@
200144
</execution>
201145
</executions>
202146
</plugin>
203-
204-
<!-- GPG签名组件 -->
205147
<plugin>
206148
<groupId>org.apache.maven.plugins</groupId>
207149
<artifactId>maven-gpg-plugin</artifactId>
@@ -213,66 +155,28 @@
213155
<goals>
214156
<goal>sign</goal>
215157
</goals>
158+
<configuration>
159+
<!-- Prevent gpg from using pinentry programs -->
160+
<gpgArguments>
161+
<arg>--pinentry-mode</arg>
162+
<arg>loopback</arg>
163+
</gpgArguments>
164+
</configuration>
216165
</execution>
217166
</executions>
218167
</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-
234168
</plugins>
235169
</build>
236170

237171
<distributionManagement>
238172
<snapshotRepository>
239173
<id>ossrh</id>
240-
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
174+
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
241175
</snapshotRepository>
242176
<repository>
243177
<id>ossrh</id>
244-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
178+
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
245179
</repository>
246180
</distributionManagement>
247181

248-
<reporting>
249-
<plugins>
250-
251-
<plugin>
252-
<groupId>org.apache.maven.plugins</groupId>
253-
<artifactId>maven-project-info-reports-plugin</artifactId>
254-
<version>2.8.1</version>
255-
<reportSets>
256-
<reportSet>
257-
<reports>
258-
<report>dependencies</report>
259-
<report>license</report>
260-
<report>scm</report>
261-
</reports>
262-
</reportSet>
263-
</reportSets>
264-
</plugin>
265-
266-
<plugin>
267-
<groupId>org.apache.maven.plugins</groupId>
268-
<artifactId>maven-javadoc-plugin</artifactId>
269-
<version>2.10.3</version>
270-
<configuration>
271-
<overview>resources/javadoc-overview.html</overview>
272-
</configuration>
273-
</plugin>
274-
275-
</plugins>
276-
</reporting>
277-
278182
</project>

0 commit comments

Comments
 (0)