File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed
Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Publish to Maven Central
2+ on :
3+ push :
4+ branches :
5+ - main
6+
7+ jobs :
8+ build-and-publish :
9+ runs-on : ubuntu-latest
10+
11+ steps :
12+ # 检出代码
13+ - name : Checkout Code
14+ uses : actions/checkout@v4
15+ with :
16+ fetch-depth : 0
17+
18+ # 设置所需的Java版本
19+ - name : Set up Java
20+ uses : actions/setup-java@v4
21+ with :
22+ java-version : ' 8'
23+ distribution : ' temurin'
24+ server-id : central
25+ server-username : MAVEN_USERNAME
26+ server-password : MAVEN_PASSWORD
27+ gpg-private-key : ${{ secrets.GPG_PRIVATE_KEY }}
28+ gpg-passphrase : MAVEN_GPG_PASSPHRASE
29+ cache : maven
30+
31+ - name : Verify GPG keys
32+ run : |
33+ echo "Available GPG Keys:"
34+ gpg --list-secret-keys --keyid-format LONG
35+
36+ - name : Generate version && Set version
37+ id : set_version
38+ run : |
39+ git describe --tags 2>/dev/null || echo "no tag"
40+ TIMESTAMP=$(date +'%Y%m%d.%H%M%S')
41+ GIT_DESCRIBE=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.0.1")
42+ VERSION="${GIT_DESCRIBE}-${TIMESTAMP}"
43+ echo "Generated version: $VERSION"
44+ mvn versions:set -DnewVersion=$VERSION --no-transfer-progress
45+ env :
46+ TZ : Asia/Shanghai
47+
48+ - name : Publish to Maven Central
49+ run : |
50+ mvn clean deploy -P release \
51+ -Dmaven.test.skip=true \
52+ -Dgpg.args="--batch --yes --pinentry-mode loopback" \
53+ --no-transfer-progress
54+ env :
55+ MAVEN_USERNAME : ${{ secrets.OSSRH_USERNAME }}
56+ MAVEN_PASSWORD : ${{ secrets.OSSRH_TOKEN }}
57+ MAVEN_GPG_PASSPHRASE : ${{ secrets.GPG_PASSPHRASE }}
You can’t perform that action at this time.
0 commit comments