Skip to content

Commit

Permalink
[UPDATE] 更新持续集成,支持发布到 Maven Central 和 GitHub Packages
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Yeh <[email protected]>
  • Loading branch information
alan-yeh committed Nov 25, 2023
1 parent 5cb272f commit 1f19ceb
Show file tree
Hide file tree
Showing 3 changed files with 218 additions and 92 deletions.
50 changes: 42 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: Publish package to Maven Central Repository
name: Publish packages
on:
push:
branches:
- master
- '*.x'
jobs:
publish:
publish-to-github-packages:
name: Publish to GitHub Packages
runs-on: ubuntu-latest
steps:
- name: Checkout sources
Expand All @@ -15,11 +16,44 @@ jobs:
- name: Set up java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
java-version: 17
distribution: zulu
server-id: github
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Echo settings.xml
run: cat /home/runner/.m2/settings.xml
- name: Publish packages
run: mvn -P github --batch-mode clean deploy
env:
MAVEN_USERNAME: ${{ secrets.GHPKG_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.GHPKG_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
publish-to-maven-central:
name: Publish to Maven Central
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up java
uses: actions/setup-java@v3
with:
java-version: 17
distribution: zulu
server-id: sonatype
server-username: ${{ secrets.MAVEN_USERNAME }}
server-password: ${{secrets.MAVEN_PASSWORD }}
gpg-private-key: ${{ secrets.GPG_SECRET_KEY }}
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Echo settings.xml
run: cat /home/runner/.m2/settings.xml
- name: Publish packages
run: mvn --batch-mode clean deploy
run: mvn -P sonatype --batch-mode clean deploy
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
250 changes: 168 additions & 82 deletions central-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -378,19 +378,6 @@
<artifactId>versions-maven-plugin</artifactId>
</plugin>

<!-- Sonatype 发布 -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>sonatype</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>

<!-- 发布时附带源代码 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -453,7 +440,6 @@
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<keyname>0x839CD986</keyname>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
Expand All @@ -473,73 +459,173 @@
</plugins>
</build>

<!-- 镜像仓库 -->
<repositories>
<repository>
<id>mirror</id>
<name>Mirror Repository</name>
<url>https://mirror.central-x.com/repository/maven-public/</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<profiles>
<profile>
<id>centralx</id>
<!-- 镜像仓库 -->
<repositories>
<repository>
<id>centralx</id>
<name>CentralX Repository</name>
<url>https://mirror.central-x.com/repository/maven-public/</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<!-- 插件仓库 -->
<pluginRepositories>
<pluginRepository>
<id>centralx</id>
<name>CentralX Repository</name>
<url>https://mirror.central-x.com/repository/maven-public/</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
<!-- 发布仓库 -->
<distributionManagement>
<repository>
<id>centralx</id>
<name>CentralX Release Repository</name>
<url>https://mirror.central-x.com/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>centralx</id>
<name>CentralX Snapshot Repository</name>
<url>https://mirror.central-x.com/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</profile>

<profile>
<id>sonatype</id>
<name>Sonatype Repository</name>
<url>https://s01.oss.sonatype.org/content/groups/public/</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>central</id>
<name>Maven Central Repository</name>
<url>https://repo1.maven.org/maven2/</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>

<!-- 插件仓库 -->
<pluginRepositories>
<pluginRepository>
<id>mirror</id>
<name>Mirror Repository</name>
<url>https://mirror.central-x.com/repository/maven-public/</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>sonatype</id>
<name>Sonatype Repository</name>
<url>https://s01.oss.sonatype.org/content/groups/public/</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>central</id>
<name>Maven Central Repository</name>
<url>https://repo1.maven.org/maven2/</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>

<!-- 发布仓库 -->
<distributionManagement>
<repository>
<id>sonatype</id>
<name>Sonatype Release Repository</name>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
<snapshotRepository>
<id>sonatype</id>
<name>Sonatype Snapshot Repository</name>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<!-- Sonatype 发布 -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>sonatype</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
<!-- 镜像仓库 -->
<repositories>
<repository>
<id>sonatype</id>
<name>Sonatype Repository</name>
<url>https://s01.oss.sonatype.org/content/groups/public/</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>central</id>
<name>Maven Central Repository</name>
<url>https://repo1.maven.org/maven2/</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<!-- 插件仓库 -->
<pluginRepositories>
<pluginRepository>
<id>sonatype</id>
<name>Sonatype Repository</name>
<url>https://s01.oss.sonatype.org/content/groups/public/</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>central</id>
<name>Maven Central Repository</name>
<url>https://repo1.maven.org/maven2/</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
<!-- 发布仓库 -->
<distributionManagement>
<repository>
<id>sonatype</id>
<name>Sonatype Release Repository</name>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
<snapshotRepository>
<id>sonatype</id>
<name>Sonatype Snapshot Repository</name>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
</profile>

<profile>
<id>github</id>
<!-- 镜像仓库 -->
<repositories>
<repository>
<id>github</id>
<name>GitHub Repository</name>
<url>https://maven.pkg.github.com/central-x/*</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>central</id>
<name>Maven Central Repository</name>
<url>https://repo1.maven.org/maven2/</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<!-- 插件仓库 -->
<pluginRepositories>
<pluginRepository>
<id>github</id>
<name>GitHub Repository</name>
<url>https://maven.pkg.github.com/central-x/*</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>central</id>
<name>Maven Central Repository</name>
<url>https://repo1.maven.org/maven2/</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
<!-- 发布仓库 -->
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Repository</name>
<url>https://maven.pkg.github.com/central-x/central-framework</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</distributionManagement>
</profile>
</profiles>

</project>
10 changes: 8 additions & 2 deletions central-stdlib/src/main/java/central/bean/BeanException.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
package central.bean;

import central.lang.PublicApi;
import lombok.experimental.StandardException;

import java.io.Serial;

Expand All @@ -36,8 +35,15 @@
* @since 2022/08/08
*/
@PublicApi
@StandardException
public class BeanException extends RuntimeException {
@Serial
private static final long serialVersionUID = 6604630928904931910L;

public BeanException(String message) {
super(message);
}

public BeanException(String message, Throwable cause) {
super(message, cause);
}
}

0 comments on commit 1f19ceb

Please sign in to comment.