Skip to content

Commit c3e8d6d

Browse files
author
yanruhao
committed
v1.0.23——添加自动部署发布
1 parent 7cd9b62 commit c3e8d6d

File tree

3 files changed

+100
-90
lines changed

3 files changed

+100
-90
lines changed

.github/workflows/release.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
tags:
66
- 'v*' # 例如 v1.0.20 触发
77

8+
permissions:
9+
contents: write
10+
811
jobs:
912
build:
1013
runs-on: ubuntu-latest
@@ -20,6 +23,11 @@ jobs:
2023
with:
2124
distribution: 'temurin'
2225
java-version: '8'
26+
server-id: central
27+
server-username: SERVER_USERNAME
28+
server-password: SERVER_PASSWORD
29+
gpg-private-key: ${{ secrets.GPG_SECRET }}
30+
gpg-passphrase: GPG_PASSPHRASE
2331

2432
# 获取 Maven 项目版本号
2533
- name: Extract project version
@@ -30,6 +38,14 @@ jobs:
3038
- name: Build with Maven
3139
run: mvn clean package -DskipTests
3240

41+
# 发布到 Apache Maven Central
42+
- name: Publish to Apache Maven Central
43+
run: mvn deploy -Dmaven.test.skip=true
44+
env:
45+
SERVER_USERNAME: ${{ secrets.SERVER_USERNAME }}
46+
SERVER_PASSWORD: ${{ secrets.SERVER_PASSWORD }}
47+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSWORD }}
48+
3349
# 创建 Release(自动附带 Source code (zip/tar.gz))
3450
- name: Create Release
3551
id: create_release

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ java-demo使用和测试可参考[java-demo-test](https://github.com/kuaidi100-a
2828

2929
```css
3030
dependencies {
31-
implementation 'com.github.kuaidi100-api:sdk:1.0.22'
31+
implementation 'com.github.kuaidi100-api:sdk:1.0.23'
3232
}
3333
```
3434

@@ -38,7 +38,7 @@ dependencies {
3838
<dependency>
3939
<groupId>com.github.kuaidi100-api</groupId>
4040
<artifactId>sdk</artifactId>
41-
<version>1.0.22</version>
41+
<version>1.0.23</version>
4242
</dependency>
4343
```
4444

pom.xml

Lines changed: 82 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.github.kuaidi100-api</groupId>
88
<artifactId>sdk</artifactId>
9-
<version>1.0.22.6</version>
9+
<version>1.0.23</version>
1010

1111
<name>api</name>
1212
<url>https://github.com/kuaidi100-api/java-demo</url>
@@ -116,94 +116,88 @@
116116

117117
</dependencies>
118118

119-
<!-- 使用个人资料:由于生成javadoc和源jar以及使用GPG签署组件是一个相当耗时的过程,因此这些执行通常与正常的构建配置隔离并移动到配置文件中。然后,在通过激活配置文件执行部署时,将使用此配置文件。 -->
120-
<profiles>
121-
<profile>
122-
<id>snapshots</id>
123-
<activation>
124-
<activeByDefault>true</activeByDefault>
125-
</activation>
126-
<build>
127-
<plugins>
128-
<!--生成源码jar包-->
129-
<plugin>
130-
<groupId>org.apache.maven.plugins</groupId>
131-
<artifactId>maven-source-plugin</artifactId>
132-
<version>3.2.1</version>
133-
<executions>
134-
<execution>
135-
<id>attach-sources</id>
136-
<goals>
137-
<goal>jar</goal>
138-
</goals>
139-
</execution>
140-
</executions>
141-
</plugin>
142-
<plugin>
143-
<groupId>org.apache.maven.plugins</groupId>
144-
<artifactId>maven-javadoc-plugin</artifactId>
145-
<version>2.10.4</version>
119+
<build>
120+
<plugins>
121+
<plugin>
122+
<groupId>org.apache.maven.plugins</groupId>
123+
<artifactId>maven-compiler-plugin</artifactId>
124+
<version>3.11.0</version>
125+
<configuration>
126+
<source>1.8</source>
127+
<target>1.8</target>
128+
<encoding>UTF-8</encoding>
129+
</configuration>
130+
</plugin>
131+
132+
<plugin>
133+
<groupId>org.apache.maven.plugins</groupId>
134+
<artifactId>maven-source-plugin</artifactId>
135+
<version>3.2.1</version>
136+
<inherited>false</inherited>
137+
<executions>
138+
<execution>
139+
<phase>package</phase>
140+
<goals>
141+
<goal>jar-no-fork</goal>
142+
</goals>
143+
</execution>
144+
</executions>
145+
</plugin>
146+
147+
<plugin>
148+
<groupId>org.apache.maven.plugins</groupId>
149+
<artifactId>maven-javadoc-plugin</artifactId>
150+
<version>3.3.0</version>
151+
<inherited>false</inherited>
152+
<configuration>
153+
<nohelp>true</nohelp>
154+
<charset>UTF-8</charset>
155+
<encoding>UTF-8</encoding>
156+
<docencoding>UTF-8</docencoding>
157+
</configuration>
158+
<executions>
159+
<execution>
160+
<phase>compile</phase>
161+
<goals>
162+
<goal>jar</goal>
163+
</goals>
164+
</execution>
165+
</executions>
166+
</plugin>
167+
168+
<plugin>
169+
<groupId>org.apache.maven.plugins</groupId>
170+
<artifactId>maven-gpg-plugin</artifactId>
171+
<version>1.6</version>
172+
<inherited>false</inherited>
173+
<executions>
174+
<execution>
175+
<id>sign-artifacts</id>
176+
<phase>verify</phase>
177+
<goals>
178+
<goal>sign</goal>
179+
</goals>
146180
<configuration>
147-
<encoding>UTF8</encoding>
148-
<aggregate>true</aggregate>
149-
<charset>UTF8</charset>
150-
<docencoding>UTF8</docencoding>
181+
<gpgArguments>
182+
<arg>--pinentry-mode</arg>
183+
<arg>loopback</arg>
184+
</gpgArguments>
151185
</configuration>
152-
<executions>
153-
<execution>
154-
<id>attach-javadocs</id>
155-
<phase>package</phase>
156-
<goals>
157-
<goal>jar</goal>
158-
</goals>
159-
<configuration>
160-
<additionalparam>-Xdoclint:none</additionalparam>
161-
</configuration>
162-
</execution>
163-
</executions>
164-
</plugin>
165-
<plugin>
166-
<groupId>org.apache.maven.plugins</groupId>
167-
<artifactId>maven-gpg-plugin</artifactId>
168-
<version>1.1</version>
169-
<configuration>
170-
<passphrase></passphrase>
171-
</configuration>
172-
<executions>
173-
<execution>
174-
<id>sign-artifacts</id>
175-
<phase>verify</phase>
176-
<goals>
177-
<goal>sign</goal>
178-
</goals>
179-
</execution>
180-
</executions>
181-
</plugin>
182-
<plugin>
183-
<groupId>org.sonatype.central</groupId>
184-
<artifactId>central-publishing-maven-plugin</artifactId>
185-
<version>0.8.0</version>
186-
<extensions>true</extensions>
187-
<configuration>
188-
<publishingServerId>snapshots</publishingServerId>
189-
</configuration>
190-
</plugin>
191-
<plugin>
192-
<groupId>org.apache.maven.plugins</groupId>
193-
<artifactId>maven-compiler-plugin</artifactId>
194-
<version>3.3</version>
195-
<configuration>
196-
<source>1.8</source>
197-
<target>1.8</target>
198-
<encoding>UTF-8</encoding>
199-
</configuration>
200-
</plugin>
201-
</plugins>
202-
203-
</build>
204-
205-
206-
</profile>
207-
</profiles>
186+
</execution>
187+
</executions>
188+
</plugin>
189+
190+
<plugin>
191+
<groupId>org.sonatype.central</groupId>
192+
<artifactId>central-publishing-maven-plugin</artifactId>
193+
<version>0.8.0</version>
194+
<extensions>true</extensions>
195+
<configuration>
196+
<publishingServerId>central</publishingServerId>
197+
<autoPublish>true</autoPublish>
198+
</configuration>
199+
</plugin>
200+
</plugins>
201+
</build>
208202

209203
</project>

0 commit comments

Comments
 (0)