Skip to content

Commit 2430785

Browse files
Github action: sonar & snapshot on Maven Central
1 parent 86dea47 commit 2430785

File tree

3 files changed

+171
-1
lines changed

3 files changed

+171
-1
lines changed

.github/workflows/snapshot.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Publish SNAPSHOT to Maven Central
2+
3+
on:
4+
push:
5+
branches:
6+
- release/*
7+
8+
jobs:
9+
snapshot:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Set up JDK
19+
uses: actions/setup-java@v4
20+
with:
21+
distribution: 'temurin'
22+
java-version: '21'
23+
server-id: central
24+
server-username: MAVEN_USERNAME
25+
server-password: MAVEN_PASSWORD
26+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
27+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
28+
29+
- name: Run tests
30+
run: mvn clean test
31+
32+
- name: Build and package
33+
run: mvn clean install
34+
35+
- name: Publish SNAPSHOT to Maven Central
36+
run: |
37+
mvn -P release --batch-mode deploy -am -DskipTests
38+
env:
39+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
40+
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
41+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

.github/workflows/sonar.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: SonarQube Analysis
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
sonar:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Set up JDK
18+
uses: actions/setup-java@v4
19+
with:
20+
distribution: 'temurin'
21+
java-version: '21'
22+
23+
- name: Run SonarQube
24+
run: mvn clean verify sonar:sonar -Dsonar.projectKey=ComputerDaddyGuy_JFileTreePrettyPrinter
25+
env:
26+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

pom.xml

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<artifactId>jfiletreeprettyprinter</artifactId>
88
<version>0.0.1-SNAPSHOT</version>
99

10+
<packaging>jar</packaging>
1011
<name>JFileTreePrettyPrinter</name>
1112
<description>A lightweight Java library for printing directory structures in a clean, tree-like format.</description>
1213
<url>https://github.com/ComputerDaddyGuy/JFileTreePrettyPrinter</url>
@@ -50,6 +51,10 @@
5051
<jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
5152
<pitest-maven.version>1.20.2</pitest-maven.version>
5253
<pitest-junit5-plugin.version>1.2.3</pitest-junit5-plugin.version>
54+
<central-publishing-maven-plugin.version>0.8.0</central-publishing-maven-plugin.version>
55+
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
56+
<maven-javadoc-plugin.version>3.11.2</maven-javadoc-plugin.version>
57+
<maven-gpg-plugin.version>3.2.7</maven-gpg-plugin.version>
5358

5459
</properties>
5560

@@ -192,7 +197,105 @@
192197

193198
</plugins>
194199

195-
196200
</build>
197201

202+
<reporting>
203+
<plugins>
204+
<plugin>
205+
<groupId>org.jacoco</groupId>
206+
<artifactId>jacoco-maven-plugin</artifactId>
207+
<version>${jacoco-maven-plugin.version}</version>
208+
<configuration>
209+
<outputDirectory>${project.reporting.outputDirectory}/jacoco-aggregate</outputDirectory>
210+
</configuration>
211+
<reportSets>
212+
<reportSet>
213+
<reports>
214+
<report>report</report>
215+
<report>report-aggregate</report>
216+
</reports>
217+
</reportSet>
218+
</reportSets>
219+
</plugin>
220+
<plugin>
221+
<groupId>org.sonarsource.scanner.maven</groupId>
222+
<artifactId>sonar-maven-plugin</artifactId>
223+
<version>${sonar-maven-plugin.version}</version>
224+
</plugin>
225+
</plugins>
226+
</reporting>
227+
228+
<profiles>
229+
<profile>
230+
<id>release</id>
231+
<build>
232+
<plugins>
233+
<plugin>
234+
<groupId>org.sonatype.central</groupId>
235+
<artifactId>central-publishing-maven-plugin</artifactId>
236+
<version>${central-publishing-maven-plugin.version}</version>
237+
<extensions>true</extensions>
238+
<configuration>
239+
<publishingServerId>central</publishingServerId>
240+
<tokenAuth>true</tokenAuth>
241+
<autoPublish>true</autoPublish>
242+
</configuration>
243+
</plugin>
244+
<plugin>
245+
<groupId>org.apache.maven.plugins</groupId>
246+
<artifactId>maven-source-plugin</artifactId>
247+
<version>${maven-source-plugin.version}</version>
248+
<executions>
249+
<execution>
250+
<id>attach-sources</id>
251+
<phase>verify</phase>
252+
<goals>
253+
<goal>jar-no-fork</goal>
254+
</goals>
255+
</execution>
256+
</executions>
257+
</plugin>
258+
<plugin>
259+
<groupId>org.apache.maven.plugins</groupId>
260+
<artifactId>maven-javadoc-plugin</artifactId>
261+
<version>${maven-javadoc-plugin.version}</version>
262+
<executions>
263+
<execution>
264+
<id>attach-javadoc</id>
265+
<goals>
266+
<goal>jar</goal>
267+
</goals>
268+
</execution>
269+
</executions>
270+
<configuration>
271+
<stylesheet>java</stylesheet>
272+
<doclint>none</doclint>
273+
</configuration>
274+
</plugin>
275+
<plugin>
276+
<groupId>org.apache.maven.plugins</groupId>
277+
<artifactId>maven-gpg-plugin</artifactId>
278+
<version>${maven-gpg-plugin.version}</version>
279+
<executions>
280+
<execution>
281+
<id>sign-artifacts</id>
282+
<phase>verify</phase>
283+
<goals>
284+
<goal>sign</goal>
285+
</goals>
286+
</execution>
287+
</executions>
288+
<configuration>
289+
<gpgArguments>
290+
<arg>--pinentry-mode</arg>
291+
<arg>loopback</arg>
292+
</gpgArguments>
293+
</configuration>
294+
</plugin>
295+
</plugins>
296+
</build>
297+
</profile>
298+
</profiles>
299+
300+
198301
</project>

0 commit comments

Comments
 (0)