Skip to content

Commit 0eaa689

Browse files
committed
add github actions configuration for maven publish snapshot
1 parent c0b433d commit 0eaa689

3 files changed

Lines changed: 80 additions & 5 deletions

File tree

.github/workflows/maven-pr.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
2+
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
3+
4+
name: Pull Request Checks
5+
6+
on: [ pull_request ]
7+
8+
jobs:
9+
build:
10+
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Set up JDK 17
19+
uses: actions/setup-java@v4
20+
with:
21+
java-version: '17'
22+
distribution: 'temurin'
23+
- name: Build with Maven
24+
run: mvn -B package --file pom.xml
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
2+
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
3+
4+
name: Maven Snapshot deploy
5+
6+
on:
7+
push:
8+
branches:
9+
- 'main'
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Set up JDK 17
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: '17'
24+
distribution: 'temurin'
25+
- name: Create .m2/settings.xml
26+
uses: s4u/maven-settings-action@v3.1.0
27+
with:
28+
servers: |
29+
[{
30+
"id": "sonatype-central",
31+
"username": "${{ secrets.OSSRH_USERNAME }}",
32+
"password": "${{ secrets.OSSRH_TOKEN }}"
33+
}]
34+
- name: Publish to OSSRH with Apache Maven
35+
run: mvn --batch-mode deploy -P deploy-to-sonatype

pom.xml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2020
<modelVersion>4.0.0</modelVersion>
2121

22-
<parent>
23-
<groupId>org.mycore</groupId>
24-
<artifactId>mycore-parent</artifactId>
25-
<version>51</version>
26-
</parent>
2722
<artifactId>mycore-classifications</artifactId>
2823
<version>1.2-SNAPSHOT</version>
2924
<packaging>jar</packaging>
@@ -46,4 +41,25 @@
4641
<url>https://github.com/MyCoRe-Org/mycore-classifications</url>
4742
<tag>HEAD</tag>
4843
</scm>
44+
<profiles>
45+
<profile>
46+
<id>deploy-to-sonatype</id>
47+
<build>
48+
<plugins>
49+
<plugin>
50+
<groupId>org.sonatype.central</groupId>
51+
<artifactId>central-publishing-maven-plugin</artifactId>
52+
<version>0.7.0</version>
53+
<extensions>true</extensions>
54+
<configuration>
55+
<centralSnapshotsUrl>https://central.sonatype.com/repository/maven-snapshots</centralSnapshotsUrl>
56+
<publishingServerId>sonatype-central</publishingServerId>
57+
<autoPublish>true</autoPublish>
58+
<waitUntil>published</waitUntil>
59+
</configuration>
60+
</plugin>
61+
</plugins>
62+
</build>
63+
</profile>
64+
</profiles>
4965
</project>

0 commit comments

Comments
 (0)