diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml
new file mode 100644
index 0000000..8922079
--- /dev/null
+++ b/.github/workflows/maven-publish.yml
@@ -0,0 +1,57 @@
+name: Publish to Maven Central
+on:
+ push:
+ branches:
+ - main
+
+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: central
+ 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/README.md b/README.md
index cb50553..af7786c 100644
--- a/README.md
+++ b/README.md
@@ -16,6 +16,15 @@ Maven 引用方式
com.github.binarywang
java-testdata-generator
- 1.1.2
+ 1.1.2
````
+
+
+```shell
+git add .
+git commit -m "updat deploymentName"
+
+git pull --rebase
+git push origin
+```
diff --git a/pom.xml b/pom.xml
index 6a8edf1..b2d3665 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,7 +47,7 @@
org.apache.commons
commons-lang3
- 3.10
+ 3.18.0
joda-time
@@ -80,17 +80,6 @@
-
-
- ossrh
- https://oss.sonatype.org/content/repositories/snapshots
-
-
- ossrh
- https://oss.sonatype.org/service/local/staging/deploy/maven2/
-
-
-
doclint-java8-disable
@@ -140,7 +129,7 @@
org.apache.maven.plugins
maven-gpg-plugin
- 1.5
+ 3.1.0
sign-artifacts
@@ -172,14 +161,14 @@
- org.sonatype.plugins
- nexus-staging-maven-plugin
- 1.6.3
+ org.sonatype.central
+ central-publishing-maven-plugin
+ 0.7.0
true
- ossrh
- https://oss.sonatype.org/
- true
+ Release ${project.artifactId}:${project.version}
+ central
+ true