Skip to content

Commit 530daa9

Browse files
committed
change release mode
1 parent 3e8278d commit 530daa9

File tree

2 files changed

+101
-37
lines changed

2 files changed

+101
-37
lines changed
+89-37
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,99 @@
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
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
3632

37-
maven-args: "-DskipTests -PsonatypeDeploy"
38-
maven-servers: ${{ secrets.MVN_REPO_SERVERS }}
39-
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
33+
- name: Import GPG Key
34+
uses: crazy-max/[email protected]
35+
with:
36+
gpg_private_key: ${{ secrets.GPG_KEY }}
37+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
38+
- name: 'Cache Maven packages'
39+
uses: actions/cache@v4
40+
with:
41+
path: ~/.m2
42+
key: 'cache'
43+
restore-keys: 'cache'
4044

41-
gpg-enabled: true
42-
gpg-key-id: ${{ secrets.GPG_KEY_ID }}
43-
gpg-key: ${{ secrets.GPG_KEY }}
44-
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
45+
- name: Setup Java JDK
46+
uses: actions/setup-java@v4
47+
with:
48+
distribution: 'zulu'
49+
java-version: 11
4550

46-
- name: 'Remove Snapshots Before Caching'
47-
run: find ~/.m2 -name '*SNAPSHOT' | xargs rm -Rf
51+
- name: 'Build with Maven'
52+
run: mvn -B install --file pom.xml
53+
54+
- name: Verify Whether a Release is Ready
55+
id: release
56+
shell: bash
57+
run: |
58+
if [ "${{ github.event.inputs.releaseVersion }}" != "" ] && [ "${{ github.event.inputs.developmentVersion }}" != "" ]; then
59+
echo "auto_release=true" >> $GITHUB_ENV
60+
else
61+
echo "auto_release=false" >> $GITHUB_ENV
62+
fi
63+
- name: Release With Maven
64+
run: |
65+
mvn -B -U \
66+
-PsonatypeDeploy \
67+
release:prepare \
68+
release:perform \
69+
javadoc:jar \
70+
source:jar \
71+
-s settings.xml \
72+
-Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} \
73+
-DreleaseVersion=${{ github.event.inputs.releaseVersion }} \
74+
-DdevelopmentVersion=${{ github.event.inputs.developmentVersion }}
75+
env:
76+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
77+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
78+
AUTO_RELEASE_AFTER_CLOSE: ${{ env.auto_release }}
79+
- name: Artifact Name
80+
shell: bash
81+
run: |
82+
echo "artifact_name=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> "$GITHUB_ENV"
83+
- name: Define Jar Name
84+
shell: bash
85+
run: |
86+
echo "{{ env.artifact_name }}"
87+
ls -al ./target/
88+
mv ./target/*.*:${{ env.artifact_name }}.jar ./target/${{ env.artifact_name }}.jar
89+
- name: Upload Artifact
90+
uses: actions/upload-artifact@v3
91+
with:
92+
name: ${{ env.artifact_name }}-${{ env.sha_short }}
93+
path: ./target/${{ env.artifact_name }}.jar
94+
- name: Workflow Release Notes
95+
uses: peter-evans/repository-dispatch@v2
96+
if: ${{ github.event.inputs.releaseVersion }} != "" && ${{ github.event.inputs.developmentVersion }} != ""
97+
with:
98+
event-type: release-notes
99+
client-payload: '{"auto_release": "${{ env.auto_release }}", "artifact": "${{ env.artifact_name }}-${{ env.sha_short }}"}'

settings.xml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"
3+
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5+
<servers>
6+
<server>
7+
<id>ossrh</id>
8+
<username>${env.MAVEN_USERNAME}</username>
9+
<password>${env.MAVEN_PASSWORD}</password>
10+
</server>
11+
</servers>
12+
</settings>

0 commit comments

Comments
 (0)