Skip to content

Commit 30d8e80

Browse files
committed
change release mode
1 parent 3e8278d commit 30d8e80

File tree

1 file changed

+83
-37
lines changed

1 file changed

+83
-37
lines changed
+83-37
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,93 @@
1-
name: Maven Release
1+
2+
name: Maven Release
23

34
on:
45
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: ""
515

616
jobs:
7-
publish:
17+
build:
818
runs-on: ubuntu-latest
9-
1019
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
3621

37-
maven-args: "-DskipTests -PsonatypeDeploy"
38-
maven-servers: ${{ secrets.MVN_REPO_SERVERS }}
39-
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
22+
- name: 'Cache Maven packages'
23+
uses: actions/cache@v4
24+
with:
25+
path: ~/.m2
26+
key: 'cache'
27+
restore-keys: 'cache'
4028

41-
gpg-enabled: true
42-
gpg-key-id: ${{ secrets.GPG_KEY_ID }}
43-
gpg-key: ${{ secrets.GPG_KEY }}
44-
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
29+
- name: Setup Java JDK
30+
uses: actions/setup-java@v4
31+
with:
32+
distribution: 'zulu'
33+
java-version: 11
4534

46-
- name: 'Remove Snapshots Before Caching'
47-
run: find ~/.m2 -name '*SNAPSHOT' | xargs rm -Rf
35+
- name: 'Build with Maven'
36+
run: mvn -B install --file pom.xml
37+
38+
- name: Configure Git User
39+
run: |
40+
git config user.email "[email protected]"
41+
git config user.name "GitHub Actions"
42+
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
43+
- name: Import SSH Key
44+
uses: shimataro/ssh-key-action@v2
45+
with:
46+
key: ${{ secrets.SSH_PRIVATE_KEY }}
47+
name: id_rsa
48+
- name: Verify Whether a Release is Ready
49+
id: release
50+
shell: bash
51+
run: |
52+
if [ "${{ github.event.inputs.releaseVersion }}" != "" ] && [ "${{ github.event.inputs.developmentVersion }}" != "" ]; then
53+
echo "auto_release=true" >> $GITHUB_ENV
54+
else
55+
echo "auto_release=false" >> $GITHUB_ENV
56+
fi
57+
- name: Release With Maven
58+
run: |
59+
mvn -B -U \
60+
-PsonatypeDeploy \
61+
release:prepare \
62+
release:perform \
63+
javadoc:jar \
64+
source:jar \
65+
-Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} \
66+
-DreleaseVersion=${{ github.event.inputs.releaseVersion }} \
67+
-DdevelopmentVersion=${{ github.event.inputs.developmentVersion }} \
68+
deploy
69+
env:
70+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
71+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
72+
AUTO_RELEASE_AFTER_CLOSE: ${{ env.auto_release }}
73+
- name: Artifact Name
74+
shell: bash
75+
run: |
76+
echo "artifact_name=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> "$GITHUB_ENV"
77+
- name: Define Jar Name
78+
shell: bash
79+
run: |
80+
echo "{{ env.artifact_name }}"
81+
ls -al ./target/
82+
mv ./target/*.*:${{ env.artifact_name }}.jar ./target/${{ env.artifact_name }}.jar
83+
- name: Upload Artifact
84+
uses: actions/upload-artifact@v3
85+
with:
86+
name: ${{ env.artifact_name }}-${{ env.sha_short }}
87+
path: ./target/${{ env.artifact_name }}.jar
88+
- name: Workflow Release Notes
89+
uses: peter-evans/repository-dispatch@v2
90+
if: ${{ github.event.inputs.releaseVersion }} != "" && ${{ github.event.inputs.developmentVersion }} != ""
91+
with:
92+
event-type: release-notes
93+
client-payload: '{"auto_release": "${{ env.auto_release }}", "artifact": "${{ env.artifact_name }}-${{ env.sha_short }}"}'

0 commit comments

Comments
 (0)