From a125e7c4933dc436510c00f9268195f138a1babf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=87=95=E9=99=87=E7=90=AA?= Date: Wed, 2 Apr 2025 20:00:08 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B5=81=E6=B0=B4=E7=BA=BF):=20github?= =?UTF-8?q?=E7=9A=84=E6=B5=81=E6=B0=B4=E7=BA=BF=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 58 ++++++++++++++++++++++++++--------- pom.xml | 15 +++++---- 2 files changed, 50 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 08d48b8..c2266ea 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,25 +1,53 @@ -name: Maven Central Repo Deployment +name: deploy + on: + # 支持手动触发构建 + workflow_dispatch: release: types: [released] jobs: - publish: + deploy: runs-on: ubuntu-latest + steps: - - name: Checkout Git Repo - uses: actions/checkout@v2 - - name: Set up Maven Central Repo + # 拉取源码 + - uses: actions/checkout@v2 + # 安装JDK环境 + - name: Set up JDK 1.8 uses: actions/setup-java@v1 with: java-version: 1.8 - server-id: sonatype-nexus-staging - server-username: ${{ secrets.OSSRH_USER }} - server-password: ${{ secrets.OSSRH_PASSWORD }} - gpg-passphrase: ${{ secrets.GPG_PASSWORD }} - - name: Publish to Maven Central Repo - uses: samuelmeuli/action-maven-publish@v1 + # 设置Maven中央仓库配置 + - name: Set up Apache Maven Central + uses: actions/setup-java@v1 with: - gpg_private_key: ${{ secrets.GPG_SECRET }} - gpg_passphrase: ${{ secrets.GPG_PASSWORD }} - nexus_username: ${{ secrets.OSSRH_USER }} - nexus_password: ${{ secrets.OSSRH_PASSWORD }} \ No newline at end of file + java-version: 1.8 + server-id: releases + # Nexus用户名环境变量 + server-username: MAVEN_USERNAME + # Nexus密码环境变量 + server-password: MAVEN_CENTRAL_TOKEN + # gpg短密码环境变量 + gpg-passphrase: MAVEN_GPG_PASSPHRASE + # gpg私钥 + gpg-private-key: ${{ secrets.GPG_SECRET }} + # 推送jar包至maven中央仓库 + - name: Publish to Apache Maven Central + # 执行maven deploy命令 + run: mvn clean deploy + # 环境变量设置 + env: + # Nexus用户名,如果觉得不想暴露也可以配置到secrets中 + MAVEN_USERNAME: ${{ secrets.OSSRH_USER }} + # Nexus密码 + MAVEN_CENTRAL_TOKEN: ${{ secrets.OSSRH_PASSWORD }} + # gpg短密码 + MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSWORD }} + # Nexus自动部署 + - name: Release on nexus + uses: monkeyWie/maven-nexus-release@v1 + with: + # Nexus用户名 + maven-repo-server-username: ${{ secrets.OSSRH_USER }} + # Nexus密码 + maven-repo-server-password: ${{ secrets.OSSRH_PASSWORD }} \ No newline at end of file diff --git a/pom.xml b/pom.xml index b503310..2aebad2 100644 --- a/pom.xml +++ b/pom.xml @@ -101,22 +101,21 @@ - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.8 + org.sonatype.central + central-publishing-maven-plugin + 0.7.0 true - ossrh - https://oss.sonatype.org/ - false + central + true - org.sonatype.plugins - nexus-staging-maven-plugin + org.sonatype.central + central-publishing-maven-plugin org.apache.maven.plugins