From 245cf7210466d2e905d016383a948b50533ea4b8 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sun, 11 May 2025 20:14:43 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E5=A2=9E=E5=8A=A0github=20action?= =?UTF-8?q?=E6=9D=A5=E8=87=AA=E5=8A=A8=E5=8F=91=E5=B8=83=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=88=B0maven=E4=B8=AD=E5=A4=AE=E4=BB=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows | 4 -- .github/workflows/maven-publish.yml | 57 +++++++++++++++++++++++++++++ pom.xml | 5 +-- 3 files changed, 59 insertions(+), 7 deletions(-) delete mode 100644 .github/workflows create mode 100644 .github/workflows/maven-publish.yml diff --git a/.github/workflows b/.github/workflows deleted file mode 100644 index e420c7d44..000000000 --- a/.github/workflows +++ /dev/null @@ -1,4 +0,0 @@ -- name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml new file mode 100644 index 000000000..9bcd3c747 --- /dev/null +++ b/.github/workflows/maven-publish.yml @@ -0,0 +1,57 @@ +name: Publish to Maven Central +on: + push: + branches: + - develop + +jobs: + build-and-publish: + runs-on: ubuntu-latest + + steps: + # 检出代码 + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # 设置所需的Java版本 + - name: Set up Java + uses: actions/setup-java@v4 + with: + java-version: '8' + distribution: 'temurin' + server-id: ossrh + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg-passphrase: MAVEN_GPG_PASSPHRASE + cache: maven + + - name: Verify GPG keys + run: | + echo "Available GPG Keys:" + gpg --list-secret-keys --keyid-format LONG + + - name: Generate version && Set version + id: set_version + run: | + git describe --tags 2>/dev/null || echo "no tag" + TIMESTAMP=$(date +'%Y%m%d.%H%M%S') + GIT_DESCRIBE=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.0.1") + VERSION="${GIT_DESCRIBE}-${TIMESTAMP}" + echo "Generated version: $VERSION" + mvn versions:set -DnewVersion=$VERSION --no-transfer-progress + env: + TZ: Asia/Shanghai + + - name: Publish to Maven Central + run: | + mvn clean deploy -P release \ + -Dmaven.test.skip=true \ + -Dgpg.args="--batch --yes --pinentry-mode loopback" \ + --no-transfer-progress + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} diff --git a/pom.xml b/pom.xml index 3c660ac65..861bbbf1e 100644 --- a/pom.xml +++ b/pom.xml @@ -136,10 +136,8 @@ UTF-8 4.5.13 - 9.4.56.v20240826 - + 9.4.56.v20240826 - @@ -339,6 +337,7 @@ ossrh + OSSRH Repository https://oss.sonatype.org/service/local/staging/deploy/maven2/