Skip to content

Commit

Permalink
maven配置自动化
Browse files Browse the repository at this point in the history
  • Loading branch information
Lambdua committed May 9, 2024
1 parent db0cdeb commit 492d32f
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 73 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
name: Publish package to the Maven Central Repository

on:
release:
types: [created]

push:
tags:
- 'v*'
# release:
# types: [created]
jobs:
publish:
runs-on: ubuntu-latest
Expand All @@ -17,13 +19,17 @@ jobs:
with:
java-version: '8'
distribution: 'temurin'
server-id: central
server-id: Lambdua
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Set version
run: mvn versions:set -DnewVersion=${{ github.event.release.tag_name }}
- name: set publish version
run: |
VERSION=${{ github.event.release.tag_name }}
VERSION=${VERSION:1}
echo "Tag detected: $VERSION , performing build and publish..."
mvn versions:set -DnewVersion=$VERSION
- name: Publish package
run: mvn -P release --batch-mode deploy -DskipTests
env:
Expand Down
211 changes: 144 additions & 67 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@
<module>service</module>
</modules>

<dependencyManagement>
<dependencies>
<!-- 在这里添加你项目的依赖 -->
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
Expand All @@ -71,6 +67,147 @@
</dependencies>


<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.4.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>Lambdua</publishingServerId>
<tokenAuth>true</tokenAuth>
<autoPublish>false</autoPublish>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<executions>
<execution>
<id>attach-javadoc</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<stylesheet>java</stylesheet>
<doclint>none</doclint>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>local</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<configuration>
<executable>C:\Program Files\Git\usr\bin\gpg.exe</executable>
<keyname>lambdua</keyname>
</configuration>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- central发布插件 -->
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.4.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>Lambdua</publishingServerId>
<tokenAuth>true</tokenAuth>
<autoPublish>false</autoPublish>
</configuration>
</plugin>
<!-- source源码插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- javadoc插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam> <!-- 关闭所有 Javadoc lint 警告 -->
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>


<build>
<plugins>
<plugin>
Expand All @@ -88,8 +225,6 @@
<skipTests>true</skipTests>
</configuration>
</plugin>


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
Expand All @@ -106,6 +241,7 @@
</filesets>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -115,66 +251,7 @@
<target>1.8</target>
</configuration>
</plugin>
<!-- central发布插件 -->
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.4.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>Lambdua</publishingServerId>
<tokenAuth>true</tokenAuth>
</configuration>
</plugin>
<!-- source源码插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- javadoc插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam> <!-- 关闭所有 Javadoc lint 警告 -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<configuration>
<executable>C:\Program Files\Git\usr\bin\gpg.exe</executable>
<keyname>lambdua</keyname>
</configuration>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>

</build>
Expand Down

0 comments on commit 492d32f

Please sign in to comment.