Skip to content

Commit 3e999a1

Browse files
authored
Add maven release workflow (#815)
* add maven release workflow * use jdk 11 * update workflow * fix * skip tests * use mvnw * update * update * fix passphrase * skip pull request * comment out old release workflow
1 parent 21f9d31 commit 3e999a1

File tree

4 files changed

+114
-52
lines changed

4 files changed

+114
-52
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Make release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
jobs:
8+
build:
9+
name: Build
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0
15+
- name: Set up JDK 11
16+
uses: actions/setup-java@v3
17+
with:
18+
java-version: 11
19+
distribution: 'zulu'
20+
- name: Cache Maven packages
21+
uses: actions/cache@v3
22+
with:
23+
path: ~/.m2
24+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
25+
restore-keys: ${{ runner.os }}-m2
26+
- name: Build
27+
run: ./mvnw clean install -DskipTests=true
28+
#run: ./mvnw clean install
29+
30+
publish-OSSRH:
31+
runs-on: ubuntu-latest
32+
name: Publish to Maven Central
33+
needs: build
34+
permissions:
35+
contents: read
36+
packages: write
37+
steps:
38+
- uses: actions/checkout@v3
39+
with:
40+
fetch-depth: 0
41+
42+
- id: install-secret-key
43+
name: Install gpg secret key
44+
run: |
45+
cat <(echo -e "${{ secrets.GPG_PRIVATE_KEY }}") | gpg --batch --import
46+
gpg --list-secret-keys --keyid-format LONG
47+
48+
- name: Set up Maven Central Repository
49+
uses: actions/setup-java@v3
50+
with:
51+
java-version: 11
52+
distribution: 'zulu'
53+
server-id: central
54+
server-username: MAVEN_USERNAME
55+
server-password: MAVEN_PASSWORD
56+
57+
- name: Publish package
58+
run: ./mvnw -DskipTests=true --batch-mode -P release -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} deploy
59+
env:
60+
MAVEN_USERNAME: ${{ secrets.OSS_USERNAME }}
61+
MAVEN_PASSWORD: ${{ secrets.OSS_PASSWORD }}

.github/workflows/maven.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5555
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
5656
run: ./mvnw -B -ntp -ff org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
57-
- name: Release Snapshot
58-
if: matrix.java_version == '11'
59-
run: ./mvnw -V -B -ntp -ff deploy
57+
# snapshot releases now handled by maven-release.yml
58+
#- name: Release Snapshot
59+
# if: matrix.java_version == '11'
60+
# run: ./mvnw -V -B -ntp -ff deploy

.github/workflows/release.yml

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,36 @@ env:
1313
OSS_PASSWORD: ${{ secrets.OSS_PASSWORD }}
1414
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
1515
jobs:
16-
release:
17-
runs-on: ubuntu-latest
18-
steps:
19-
- uses: actions/checkout@v4
20-
- name: Set up JDK 11
21-
uses: actions/setup-java@v4
22-
with:
23-
distribution: 'zulu'
24-
java-version: 11
25-
cache: 'maven'
26-
# Value of the distributionManagement/repository/id field of the pom.xml
27-
server-id: central
28-
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
29-
server-username: OSS_USERNAME
30-
server-password: OSS_PASSWORD
31-
gpg-passphrase: GPG_PASSPHRASE
32-
- name: Setup Git
33-
run: |
34-
git config --global committer.email "[email protected]"
35-
git config --global committer.name "GitHub Release"
36-
git config --global author.email "${GITHUB_ACTOR}@users.noreply.github.com"
37-
git config --global author.name "${GITHUB_ACTOR}"
38-
- name: Release
39-
run: ./mvnw -V -B -ntp -Prelease -DreleaseVersion=${{ github.event.inputs.releaseVersion }} -DdevelopmentVersion=${{ github.event.inputs.developmentVersion }} release:prepare release:perform
40-
- name: Rollback on failure
41-
if: ${{ failure() }}
42-
run: |
43-
./mvnw -B release:rollback -Prelease -Dgpg.passphrase=${{secrets.GPG_PASSPHRASE}}
44-
echo "You may need to manually delete the GitHub tag, if it was created."
16+
# replaced by maven-release.yml
17+
#release:
18+
# runs-on: ubuntu-latest
19+
# steps:
20+
# - uses: actions/checkout@v4
21+
# - name: Set up JDK 11
22+
# uses: actions/setup-java@v4
23+
# with:
24+
# distribution: 'zulu'
25+
# java-version: 11
26+
# cache: 'maven'
27+
# # Value of the distributionManagement/repository/id field of the pom.xml
28+
# server-id: central
29+
# gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
30+
# server-username: OSS_USERNAME
31+
# server-password: OSS_PASSWORD
32+
# gpg-passphrase: GPG_PASSPHRASE
33+
# - name: Setup Git
34+
# run: |
35+
# git config --global committer.email "[email protected]"
36+
# git config --global committer.name "GitHub Release"
37+
# git config --global author.email "${GITHUB_ACTOR}@users.noreply.github.com"
38+
# git config --global author.name "${GITHUB_ACTOR}"
39+
# - name: Release
40+
# run: ./mvnw -V -B -ntp -Prelease -DreleaseVersion=${{ github.event.inputs.releaseVersion }} -DdevelopmentVersion=${{ github.event.inputs.developmentVersion }} release:prepare release:perform
41+
# - name: Rollback on failure
42+
# if: ${{ failure() }}
43+
# run: |
44+
# ./mvnw -B release:rollback -Prelease -Dgpg.passphrase=${{secrets.GPG_PASSPHRASE}}
45+
# echo "You may need to manually delete the GitHub tag, if it was created."
4546
docker:
4647
needs: release
4748
runs-on: ubuntu-latest

pom.xml

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,27 @@
192192
</profile>
193193
<profile>
194194
<id>release</id>
195+
<distributionManagement>
196+
<repository>
197+
<id>central</id>
198+
<name>Central Repository OSSRH</name>
199+
<url>https://central.sonatype.com/</url>
200+
</repository>
201+
<snapshotRepository>
202+
<id>central</id>
203+
<name>Central Repository OSSRG Snapshots</name>
204+
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
205+
<snapshots>
206+
<enabled>true</enabled>
207+
</snapshots>
208+
</snapshotRepository>
209+
</distributionManagement>
195210
<build>
196211
<plugins>
197212
<plugin>
198213
<groupId>org.apache.maven.plugins</groupId>
199214
<artifactId>maven-gpg-plugin</artifactId>
215+
<version>1.5</version>
200216
<configuration>
201217
<gpgArguments>
202218
<arg>--pinentry-mode</arg>
@@ -216,12 +232,12 @@
216232
<plugin>
217233
<groupId>org.sonatype.central</groupId>
218234
<artifactId>central-publishing-maven-plugin</artifactId>
219-
<version>0.7.0</version>
235+
<version>0.8.0</version>
220236
<extensions>true</extensions>
221237
<configuration>
222-
<publishingServerId>ossrh</publishingServerId>
238+
<publishingServerId>central</publishingServerId>
223239
<autoPublish>true</autoPublish>
224-
<waitUntil>published</waitUntil>
240+
<checksums>required</checksums>
225241
</configuration>
226242
</plugin>
227243
<plugin>
@@ -256,18 +272,6 @@
256272
</execution>
257273
</executions>
258274
</plugin>
259-
<plugin>
260-
<groupId>org.cyclonedx</groupId>
261-
<artifactId>cyclonedx-maven-plugin</artifactId>
262-
<executions>
263-
<execution>
264-
<phase>package</phase>
265-
<goals>
266-
<goal>makeAggregateBom</goal>
267-
</goals>
268-
</execution>
269-
</executions>
270-
</plugin>
271275
</plugins>
272276
</build>
273277
</profile>
@@ -352,11 +356,6 @@
352356
<artifactId>sonar-maven-plugin</artifactId>
353357
<version>5.1.0.4751</version>
354358
</plugin>
355-
<plugin>
356-
<groupId>org.cyclonedx</groupId>
357-
<artifactId>cyclonedx-maven-plugin</artifactId>
358-
<version>2.9.1</version>
359-
</plugin>
360359
</plugins>
361360
</pluginManagement>
362361
<plugins>

0 commit comments

Comments
 (0)