Skip to content

Commit f873d99

Browse files
committed
Build & Distribute via GitHub Packages
This sets up GitHub Actions that build and publish this project as a Maven artifact, using the Maven repository provided by GitHub. ```xml <repository> <id>github</id> <name>GitHub GoodBytes LinkDetector Apache Maven Packages</name> <url>https://maven.pkg.github.com/goodbytes/linkdetector</url> </repository> ``` You can then define this project to be a dependency of your project, like so: ```xml <dependency> <groupId>nl.goodbytes.util</groupId> <artifactId>linkdetector</artifactId> <version>1.0.0</version> <!-- Please remember to check if this is the latest, as this example could be outdated. --> </dependency> ```
1 parent fcfacff commit f873d99

File tree

4 files changed

+95
-2
lines changed

4 files changed

+95
-2
lines changed

.github/workflows/maven-build.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Maven Build & Test
2+
3+
on: [pull_request]
4+
5+
permissions:
6+
checks: write
7+
8+
jobs:
9+
build-java:
10+
name: Build
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
java: [ 8, 11, 17, 21 ]
15+
distribution: [ temurin ] # We could add more here: temurin, adopt, liberica, microsoft, corretto
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Set up JDK ${{ matrix.java }} ${{ matrix.distribution }}
19+
uses: actions/setup-java@v4
20+
with:
21+
java-version: ${{ matrix.java }}
22+
distribution: ${{ matrix.distribution }}
23+
cache: maven
24+
- name: Build with Maven
25+
run: mvn --batch-mode --update-snapshots verify
26+
- name: Publish Test Report
27+
uses: mikepenz/action-junit-report@v5
28+
if: ${{ matrix.java == 8 && (success() || failure()) }} # always run even if the previous step fails
29+
with:
30+
report_paths: '**/target/surefire-reports/TEST-*.xml'
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 Package
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
build:
12+
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 8
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: '8'
24+
distribution: 'temurin'
25+
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
26+
settings-path: ${{ github.workspace }} # Location where the settings.xml file will be generated.
27+
28+
- name: Build with Maven
29+
run: mvn -B package --file pom.xml
30+
31+
- name: Publish to GitHub Packages Apache Maven
32+
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
33+
env:
34+
GITHUB_TOKEN: ${{ github.token }}

pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,12 @@
4141
</dependency>
4242
</dependencies>
4343

44+
<distributionManagement>
45+
<repository>
46+
<id>github</id>
47+
<name>GitHub GoodBytes LinkDetector Apache Maven Packages</name>
48+
<url>https://maven.pkg.github.com/goodbytes/linkdetector</url>
49+
</repository>
50+
</distributionManagement>
51+
4452
</project>

readme.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,29 @@ that effort.
88

99
## Usage
1010

11-
To use the utility, invoke the `parse` method of the `LinkDetector` class, as shown below. This will split up the text
12-
in fragments (returned in a list). For each fragment, a start and end index is provided, and defines if it does or does
11+
The distributable is available through the Maven repository that is provided by GitHub Packages. To set it up, define
12+
the repository in your `pom.xml` file like so:
13+
14+
```xml
15+
<repository>
16+
<id>github</id>
17+
<name>GitHub GoodBytes LinkDetector Apache Maven Packages</name>
18+
<url>https://maven.pkg.github.com/goodbytes/linkdetector</url>
19+
</repository>
20+
```
21+
22+
You can then define this project to be a dependency of your project, like so:
23+
24+
```xml
25+
<dependency>
26+
<groupId>nl.goodbytes.util</groupId>
27+
<artifactId>linkdetector</artifactId>
28+
<version>1.0.0</version> <!-- Please remember to check if this is the latest, as this example could be outdated. -->
29+
</dependency>
30+
```
31+
32+
To use the utility in your code, invoke the `parse` method of the `LinkDetector` class, as shown below. This will split
33+
up the text in fragments (returned in a list). For each fragment, a start and end index is provided, and defines if it does or does
1334
not represent a link.
1435

1536
```java

0 commit comments

Comments
 (0)