Skip to content

Commit

Permalink
[UPDATE] 更新持续集成,自动将 central-studio-lib 发布到 Maven Central 和 GitHub Pac…
Browse files Browse the repository at this point in the history
…kages 中

Signed-off-by: Alan Yeh <[email protected]>
  • Loading branch information
alan-yeh committed Nov 26, 2023
1 parent d80e5bc commit ca89852
Show file tree
Hide file tree
Showing 16 changed files with 1,482 additions and 145 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Publish packages
on:
push:
branches:
- master
- '*.x'
jobs:
publish-to-github-packages:
name: Publish to GitHub Packages
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: 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: 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 sonatype --batch-mode clean deploy
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
193 changes: 176 additions & 17 deletions central-dashboard/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@
<skip>true</skip>
</configuration>
</plugin>
<!-- 运行单元测试时需要依赖其它服务,因此手工执行单元测试 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>

<!-- 处理占位符 -->
<plugin>
Expand Down Expand Up @@ -125,21 +133,172 @@
</plugins>
</build>

<!-- 镜像仓库 -->
<repositories>
<repository>
<id>mirror</id>
<name>Mirror Repository</name>
<url>https://mirror.central-x.com/repository/maven-public/</url>
</repository>
</repositories>

<!-- 插件仓库 -->
<pluginRepositories>
<pluginRepository>
<id>mirror</id>
<name>Mirror Repository</name>
<url>https://mirror.central-x.com/repository/maven-public/</url>
</pluginRepository>
</pluginRepositories>
<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>
<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-studio</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</distributionManagement>
</profile>
</profiles>
</project>
Loading

0 comments on commit ca89852

Please sign in to comment.