1- name : IABGPP-Java Release
1+ # Release to Maven Central via Central Publisher Portal
2+ # https://central.sonatype.org/publish/publish-portal-guide/
3+ #
4+ # Required GitHub secrets (Settings → Secrets and variables → Actions):
5+ # CENTRAL_TOKEN_USERNAME - Portal token username (from https://central.sonatype.com/usertoken)
6+ # CENTRAL_TOKEN_PASSWORD - Portal token password (from same page; save on first view, cannot be retrieved later)
7+ # GPG_SECRET_KEY - Armored GPG private key for signing
8+ # GPG_PASSPHRASE - Passphrase for the GPG key
9+ # PAT - Personal access token with repo scope (for pushing commits/tags)
10+ #
11+ name : IABGPP-Java 4.X Release
212
313on :
414 workflow_dispatch :
515 inputs :
616 version :
7- description : ' The release version (e.g., 3 .x.x)'
17+ description : ' The release version (e.g., 4 .x.x)'
818 required : true
919 default : ' '
1020
@@ -14,15 +24,15 @@ jobs:
1424 steps :
1525 # Checkout the repository with full history for tagging
1626 - name : Checkout repository
17- uses : actions/checkout@v2
27+ uses : actions/checkout@v4
1828 with :
1929 fetch-depth : 0
2030
21- # Set up Java (assuming Java 11, adjust if different)
31+ # Set up Java
2232 - name : Set up Java
23- uses : actions/setup-java@v2
33+ uses : actions/setup-java@v4
2434 with :
25- distribution : ' adopt '
35+ distribution : ' temurin '
2636 java-version : ' 21'
2737
2838 # Import GPG secret key for signing
@@ -31,35 +41,44 @@ jobs:
3141 echo "${{ secrets.GPG_SECRET_KEY }}" > secret_key.asc
3242 gpg --import --no-tty --batch secret_key.asc || { echo "GPG import failed"; cat secret_key.asc; exit 1; }
3343 rm -f secret_key.asc
34- # gpg --list-secret-keys
3544
36-
37- # Generate settings.xml with Maven repository credentials
45+ # Generate settings.xml with Central Publisher Portal token credentials
46+ # Token from: https://central.sonatype.com/usertoken
3847 - name : Create settings.xml
48+ env :
49+ CENTRAL_TOKEN_USERNAME : ${{ secrets.CENTRAL_TOKEN_USERNAME }}
50+ CENTRAL_TOKEN_PASSWORD : ${{ secrets.CENTRAL_TOKEN_PASSWORD }}
3951 run : |
4052 mkdir -p ~/.m2
4153 cat > ~/.m2/settings.xml << EOF
42- <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
43- <localRepository>~/.m2</localRepository> <interactiveMode>false</interactiveMode> <offline>false</offline><pluginGroups> <pluginGroup>org.sonatype.plugins</pluginGroup> </pluginGroups> <servers> <server> <id>sonatype-nexus-snapshots</id> <username>TiW/t45q</username> <password>${{ secrets.SONATYPE_PWD }}</password> </server> <server> <id>sonatype-nexus-staging</id> <username>TiW/t45q</username> <password>${{ secrets.SONATYPE_PWD_STAGING }}</password> </server> </servers>
54+ <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
55+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
56+ xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
57+ <servers>
58+ <server>
59+ <id>central</id>
60+ <username>${CENTRAL_TOKEN_USERNAME}</username>
61+ <password>${CENTRAL_TOKEN_PASSWORD}</password>
62+ </server>
63+ </servers>
4464 </settings>
4565 EOF
4666
4767 # Pull latest changes from master
4868 - name : Pull latest changes
49- run : git pull origin master
69+ run : git pull origin 4.X
5070
5171 # Set the release version in pom.xml
5272 - name : Set release version
5373 run : mvn versions:set -DnewVersion=${{ github.event.inputs.version }} -DgenerateBackupPoms=false
5474
55- # Build and deploy the release
75+ # Build and deploy to Central Publisher Portal (mvn deploy uploads bundle and publishes)
5676 - name : Deploy release
5777 run : |
5878 echo "pinentry-mode loopback" > ~/.gnupg/gpg.conf
5979 echo "use-agent" >> ~/.gnupg/gpg.conf
6080 export GPG_TTY=$(tty || echo /dev/tty)
6181 mvn clean deploy --settings ~/.m2/settings.xml -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" -Prelease
62- # mvn clean deploy --settings ~/.m2/settings.xml -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" -Prelease -Dmaven.javadoc.skip=true
6382
6483 # Commit the release version and create a tag
6584 - name : Commit and tag release
@@ -80,12 +99,11 @@ jobs:
8099 NEW_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
81100 git add .
82101 git commit -m "$NEW_VERSION"
83- # git commit -m "${{ github.event.inputs.version }}-SNAPSHOT"
84102
85103 # Push commits and tags to GitHub
86104 - name : Push changes
87105 run : |
88106 git status
89107 git push; git push --tags
90108 env :
91- GITHUB_TOKEN : ${{secrets.PAT}}
109+ GITHUB_TOKEN : ${{ secrets.PAT }}
0 commit comments