1+ name : Publish to Maven Central
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ version :
7+ description : ' Version number for release'
8+ required : true
9+
10+ jobs :
11+ release :
12+ name : Release to Maven Central
13+ if : github.ref == 'refs/heads/master'
14+ runs-on : ubuntu-latest
15+ env :
16+ java-version : ' 8'
17+ user : codeleep
18+ email : codeleep@163.com
19+ gpg-keyname : ${{ secrets.MAVEN_GPG_KEY_NAME }}
20+ gpg-private-key : ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
21+ gpg-passphrase : ${{ secrets.MAVEN_GPG_PASSPHRASE }}
22+ server-username : ${{ secrets.CENTER_SERVER_USERNAME }}
23+ server-password : ${{ secrets.CENTER_SERVER_PASSWORD }}
24+ steps :
25+ - uses : actions/checkout@v4
26+ with :
27+ fetch-depth : 0
28+
29+ - name : Bump version
30+ run : |
31+ git pull
32+ VERSION=${{ github.event.inputs.version }}
33+ echo "INFO input tag: $VERSION"
34+ mvn versions:set -DnewVersion=$VERSION -DgenerateBackupPoms=false
35+ mvn versions:update-property -Dproperty=version.athena -DnewVersion=$VERSION -DgenerateBackupPoms=false
36+ shell : bash
37+ - name : Tag for release
38+ run : |
39+ git config --global user.name ${{ env.user }}
40+ git config --global user.email ${{ env.email }}
41+ git commit -am "Bump version to $VERSION"
42+ git push
43+
44+ echo "INFO Creating tag: ${{ github.event.inputs.version }}"
45+ git tag ${{ github.event.inputs.version }} -a -m "Autogenerated version bump tag"
46+ # Push the new tag
47+ echo "INFO Pushing tag: ${{ github.event.inputs.version }}"
48+ git push origin ${{ github.event.inputs.version }}
49+ shell : bash
50+
51+ - name : Set up Java
52+ uses : actions/setup-java@v3
53+ with :
54+ # https://stackoverflow.com/a/77710731/14312712
55+ java-version : ${{ env.java-version }}
56+ distribution : ' adopt'
57+ server-id : ${{ env.gpg-keyname }}
58+ settings-path : ${{ github.workspace }}
59+ gpg-private-key : ${{ env.gpg-private-key }}
60+ gpg-passphrase : ${{ env.gpg-passphrase }}
61+ server-username : ${{ env.server-username }}
62+ server-password : ${{ env.server-password }}
63+
64+ - name : Prepare GPG
65+ run : |
66+ mkdir -p ~/.gnupg/
67+ echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
68+ gpgconf --reload gpg-agent
69+ shell : bash
70+
71+ - name : Configure settings.xml for Maven Central release
72+ uses : whelk-io/maven-settings-xml-action@v20
73+ with :
74+ servers : >
75+ [
76+ {
77+ "id": "${{ env.gpg-keyname }}",
78+ "username": "${{ env.server-username }}",
79+ "password": "${{ env.server-password }}",
80+ "passphrase": "${{ env.gpg-passphrase }}"
81+ }
82+ ]
83+ profiles : >
84+ [
85+ {
86+ "id": "${{ env.gpg-keyname }}",
87+ "properties": {
88+ "gpg.keyname": "${{ env.gpg-keyname }}"
89+ },
90+ "activation": {
91+ "activeByDefault": "true"
92+ }
93+ }
94+ ]
95+
96+ - name : Release
97+ run : mvn clean deploy -P release -DskipTests
98+ shell : bash
0 commit comments