1
- name : Maven Release
1
+
2
+ name : Maven Release
2
3
3
4
on :
4
5
workflow_dispatch :
6
+ inputs :
7
+ releaseVersion :
8
+ description : " Define the release version"
9
+ required : true
10
+ default : " "
11
+ developmentVersion :
12
+ description : " Define the snapshot version"
13
+ required : true
14
+ default : " "
5
15
6
16
jobs :
7
- publish :
17
+ build :
8
18
runs-on : ubuntu-latest
9
-
10
19
steps :
11
- - uses : actions/checkout@v4
12
-
13
- - name : ' Cache Maven packages'
14
- uses : actions/cache@v4
15
- with :
16
- path : ~/.m2
17
- key : ' cache'
18
- restore-keys : ' cache'
19
-
20
- - name : Setup Java JDK
21
- uses : actions/setup-java@v4
22
- with :
23
- distribution : ' zulu'
24
- java-version : 11
25
-
26
- - name : ' Build with Maven'
27
- run : mvn -B install --file pom.xml
28
-
29
- - name : Release
30
- uses : qcastel/github-actions-maven-release@master
31
- env :
32
- JAVA_HOME : /usr/lib/jvm/java-11-openjdk/
33
- with :
34
- git-release-bot-name : " angeliski"
35
- git-release-bot-email :
" [email protected] "
20
+ - uses : actions/checkout@v4
21
+ - name : Configure Git User
22
+ run : |
23
+ git config user.email "[email protected] "
24
+ git config user.name "GitHub Actions"
25
+ echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
26
+ - name : Import SSH Key
27
+ uses : shimataro/ssh-key-action@v2
28
+ with :
29
+ key : ${{ secrets.SSH_PRIVATE_KEY }}
30
+ name : id_rsa
31
+ known_hosts : unnecessary_just_github
36
32
37
- maven-args : " -DskipTests -PsonatypeDeploy"
38
- maven-servers : ${{ secrets.MVN_REPO_SERVERS }}
39
- ssh-private-key : ${{ secrets.SSH_PRIVATE_KEY }}
33
+ - name : ' Cache Maven packages'
34
+ uses : actions/cache@v4
35
+ with :
36
+ path : ~/.m2
37
+ key : ' cache'
38
+ restore-keys : ' cache'
40
39
41
- gpg-enabled : true
42
- gpg-key-id : ${{ secrets.GPG_KEY_ID }}
43
- gpg-key : ${{ secrets.GPG_KEY }}
44
- gpg-passphrase : ${{ secrets.GPG_PASSPHRASE }}
40
+ - name : Setup Java JDK
41
+ uses : actions/setup-java@v4
42
+ with :
43
+ distribution : ' zulu'
44
+ java-version : 11
45
45
46
- - name : ' Remove Snapshots Before Caching'
47
- run : find ~/.m2 -name '*SNAPSHOT' | xargs rm -Rf
46
+ - name : ' Build with Maven'
47
+ run : mvn -B install --file pom.xml
48
+
49
+ - name : Verify Whether a Release is Ready
50
+ id : release
51
+ shell : bash
52
+ run : |
53
+ if [ "${{ github.event.inputs.releaseVersion }}" != "" ] && [ "${{ github.event.inputs.developmentVersion }}" != "" ]; then
54
+ echo "auto_release=true" >> $GITHUB_ENV
55
+ else
56
+ echo "auto_release=false" >> $GITHUB_ENV
57
+ fi
58
+ - name : Release With Maven
59
+ run : |
60
+ mvn -B -U \
61
+ -PsonatypeDeploy \
62
+ release:prepare \
63
+ release:perform \
64
+ javadoc:jar \
65
+ source:jar \
66
+ -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} \
67
+ -DreleaseVersion=${{ github.event.inputs.releaseVersion }} \
68
+ -DdevelopmentVersion=${{ github.event.inputs.developmentVersion }} \
69
+ deploy
70
+ env :
71
+ MAVEN_USERNAME : ${{ secrets.OSSRH_USERNAME }}
72
+ MAVEN_PASSWORD : ${{ secrets.OSSRH_TOKEN }}
73
+ AUTO_RELEASE_AFTER_CLOSE : ${{ env.auto_release }}
74
+ - name : Artifact Name
75
+ shell : bash
76
+ run : |
77
+ echo "artifact_name=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> "$GITHUB_ENV"
78
+ - name : Define Jar Name
79
+ shell : bash
80
+ run : |
81
+ echo "{{ env.artifact_name }}"
82
+ ls -al ./target/
83
+ mv ./target/*.*:${{ env.artifact_name }}.jar ./target/${{ env.artifact_name }}.jar
84
+ - name : Upload Artifact
85
+ uses : actions/upload-artifact@v3
86
+ with :
87
+ name : ${{ env.artifact_name }}-${{ env.sha_short }}
88
+ path : ./target/${{ env.artifact_name }}.jar
89
+ - name : Workflow Release Notes
90
+ uses : peter-evans/repository-dispatch@v2
91
+ if : ${{ github.event.inputs.releaseVersion }} != "" && ${{ github.event.inputs.developmentVersion }} != ""
92
+ with :
93
+ event-type : release-notes
94
+ client-payload : ' {"auto_release": "${{ env.auto_release }}", "artifact": "${{ env.artifact_name }}-${{ env.sha_short }}"}'
0 commit comments