Skip to content

Commit 0756530

Browse files
authored
Upgrade pipeline to publish throught maven central (#7)
1 parent 96acb8f commit 0756530

File tree

3 files changed

+80
-30
lines changed

3 files changed

+80
-30
lines changed

.github/workflows/publish.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
name: Publish package to GitHub Packages
1+
name: Publish package to Maven Central
22
on:
3-
release:
4-
types: [created]
3+
push:
4+
tags:
5+
- 'v*.*.*'
56
jobs:
67
publish:
78
runs-on: ubuntu-latest
@@ -13,12 +14,12 @@ jobs:
1314
with:
1415
java-version: '17'
1516
distribution: 'temurin'
16-
- name: Configure Git to use PAT
17-
run: |
18-
git config --global user.name "GitHub Bot"
19-
git config --global user.email "[email protected]"
20-
git remote set-url origin https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}
21-
- name: Run Maven Release
22-
run: ./mvnw -B release:prepare release:perform
23-
env:
24-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
- name: Deploy to Maven Central
18+
with:
19+
gpg-key-name: ${{ secrets.GPG_KEY_NAME }}
20+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
21+
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
22+
server-id: ossrh
23+
server-username: ${{ secrets.OSS_ACCESS_KEY_ID }}
24+
server-password: ${{ OSS_ACCESS_KEY_SECRET }}
25+
run: ./mvnw -B deploy -Ppublish -Dgpg.keyname=${{ secrets.GPG_KEY_NAME }}

.github/workflows/release.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Release package to GitHub repository
2+
on:
3+
release:
4+
types: [created]
5+
jobs:
6+
publish:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read
10+
packages: write
11+
steps:
12+
- uses: actions/setup-java@v4
13+
with:
14+
java-version: '17'
15+
distribution: 'temurin'
16+
- name: Configure Git to use PAT
17+
run: |
18+
git config --global user.name "GitHub Bot"
19+
git config --global user.email "[email protected]"
20+
git remote set-url origin https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}
21+
- name: Run Maven Release
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
run: ./mvnw -B release:prepare release:perform

pom.xml

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,6 @@
9292
</execution>
9393
</executions>
9494
</plugin>
95-
<plugin>
96-
<groupId>org.apache.maven.plugins</groupId>
97-
<artifactId>maven-release-plugin</artifactId>
98-
<version>3.1.1</version>
99-
<configuration>
100-
<tagNameFormat>@{project.version}</tagNameFormat>
101-
<pushChanges>true</pushChanges>
102-
<scmCommentPrefix>[BOT](release): </scmCommentPrefix>
103-
</configuration>
104-
</plugin>
10595
<plugin>
10696
<groupId>org.apache.maven.plugins</groupId>
10797
<artifactId>maven-source-plugin</artifactId>
@@ -115,7 +105,6 @@
115105
</execution>
116106
</executions>
117107
</plugin>
118-
119108
<plugin>
120109
<groupId>org.apache.maven.plugins</groupId>
121110
<artifactId>maven-javadoc-plugin</artifactId>
@@ -131,13 +120,49 @@
131120
</plugin>
132121
</plugins>
133122
</build>
134-
<distributionManagement>
135-
<repository>
136-
<id>github</id>
137-
<name>GitHub Packages</name>
138-
<url>https://maven.pkg.github.com/gchauvet/mojet</url>
139-
</repository>
140-
</distributionManagement>
123+
<profiles>
124+
<profile>
125+
<id>publish</id>
126+
<build>
127+
<plugins>
128+
<plugin>
129+
<groupId>org.apache.maven.plugins</groupId>
130+
<artifactId>maven-release-plugin</artifactId>
131+
<version>3.1.1</version>
132+
<configuration>
133+
<tagNameFormat>@{project.version}</tagNameFormat>
134+
<pushChanges>true</pushChanges>
135+
<scmCommentPrefix>[BOT](release): </scmCommentPrefix>
136+
</configuration>
137+
</plugin>
138+
<plugin>
139+
<groupId>org.apache.maven.plugins</groupId>
140+
<artifactId>maven-gpg-plugin</artifactId>
141+
<version>3.2.7</version>
142+
<executions>
143+
<execution>
144+
<id>sign-artifacts</id>
145+
<phase>verify</phase>
146+
<goals>
147+
<goal>sign</goal>
148+
</goals>
149+
</execution>
150+
</executions>
151+
</plugin>
152+
</plugins>
153+
</build>
154+
<distributionManagement>
155+
<snapshotRepository>
156+
<id>ossrh</id>
157+
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
158+
</snapshotRepository>
159+
<repository>
160+
<id>ossrh</id>
161+
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
162+
</repository>
163+
</distributionManagement>
164+
</profile>
165+
</profiles>
141166
<properties>
142167
<lombok.version>1.18.38</lombok.version>
143168
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

0 commit comments

Comments
 (0)