From 88333ed93066ce043b14caf6e40f2d8b9dc11214 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 18:59:35 +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 | 86 +++++++++-------------------------- pom.xml | 6 +++ 2 files changed, 28 insertions(+), 64 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1d90cb3..8eb0552 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,33 +1,21 @@ -name: 发布到 Maven Central - +name: Maven Central Repo Deployment on: release: - types: [created] - # 可选:也可以手动触发 - workflow_dispatch: - + types: [released] jobs: publish: runs-on: ubuntu-latest steps: - - name: 检出代码 - uses: actions/checkout@v3 - - - name: 设置 JDK 1.8 - uses: actions/setup-java@v3 - with: - java-version: '8' - distribution: 'temurin' - cache: 'maven' - - - name: 配置 GPG 密钥 + - name: Checkout Git Repo + uses: actions/checkout@v2 + - name: Configure GPG Key run: | - # 导入 GPG 密钥 + # Setup GPG echo "${{ secrets.GPG_SECRET }}" | base64 --decode > private.key gpg --batch --import private.key rm private.key - # 配置 GPG 为非交互模式 + # Configure GPG for non-interactive use mkdir -p ~/.gnupg/ echo "use-agent" > ~/.gnupg/gpg.conf echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf @@ -35,48 +23,18 @@ jobs: chmod 700 ~/.gnupg chmod 600 ~/.gnupg/* gpg-connect-agent reloadagent /bye - - - name: 创建 Maven 设置文件 - run: | - cat > settings.xml << EOF - - - - ossrh - ${{ secrets.OSSRH_USER }} - ${{ secrets.OSSRH_PASSWORD }} - - - - central - ${{ secrets.OSSRH_USER }} - ${{ secrets.OSSRH_PASSWORD }} - - - sonatype-nexus-staging - ${{ secrets.OSSRH_USER }} - ${{ secrets.OSSRH_PASSWORD }} - - - - - ossrh - - true - - - gpg - ${{ secrets.GPG_PASSWORD }} - - - - - EOF - - - name: 构建并发布到 Maven Central - run: | - mvn clean deploy \ - --batch-mode \ - --settings settings.xml \ - -Dgpg.passphrase="${{ secrets.GPG_PASSWORD }}" \ - -DskipTests=true + - name: Set up Maven Central Repo + 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 + 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 diff --git a/pom.xml b/pom.xml index 6cbf455..fb264f2 100644 --- a/pom.xml +++ b/pom.xml @@ -73,6 +73,12 @@ sign + + + --pinentry-mode + loopback + +