Skip to content

Commit

Permalink
Merge pull request #25 from CDOT-CV/github-actions-artifact-publishing
Browse files Browse the repository at this point in the history
GitHub actions artifact publishing
  • Loading branch information
drewjj authored Aug 1, 2024
2 parents cbeb1e0 + f57453e commit beabe6d
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 1 deletion.
31 changes: 31 additions & 0 deletions .github/workflows/artifact-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish Java Package

on:
push:
tags:
- 'jpo-sdw-depositor-*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'adopt'

- name: Remove snapshot from version
run: mvn versions:set -DremoveSnapshot

- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Publish to GitHub Packages
run: mvn --batch-mode -Dgithub_organization=${{ github.repository_owner }} deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60 changes: 59 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,62 @@ Rather than using a local kafka instance, this project can utilize an instance o
There is a provided docker-compose file (docker-compose-confluent-cloud.yml) that passes the above environment variables into the container that gets created. Further, this file doesn't spin up a local kafka instance since it is not required.

### Note
This has only been tested with Confluent Cloud but technically all SASL authenticated Kafka brokers can be reached using this method.
This has only been tested with Confluent Cloud but technically all SASL authenticated Kafka brokers can be reached using this method.

## GitHub Artifact Usage

To use this library in another application, add the GitHub package URLs to the `repositories` section in `pom.xml` of the consumer application or in your local `~/.m2/settings.xml` file. Here is an example implementation of using the GitHub artifact in a consumer application:

```xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">

<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>

<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/usdot-jpo-ode/jpo-sdw-depositor</url>
</repository>
</repositories>
</profile>
</profiles>

<servers>
<server>
<id>github</id>
<username>${env.PACKAGE_READ_USERNAME}</username>
<password>${env.PACKAGE_READ_TOKEN}</password>
</server>
</servers>

</settings>
```

And add the following line to the `dependencies` element in `build.gradle`

```xml
<dependencies>
<dependency>
<groupId>usdot.jpo.ode</groupId>
<artifactId>jpo-sdw-depositor</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
```

Finally, set the environment variables:

* PACKAGE_READ_USERNAME - User name with read access to the repositories containing the packages.
* PACKAGE_READ_TOKEN - Personal access token with `read:packages` scope.
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
<sonar.language>java</sonar.language>
<github_organization>usdot-jpo-ode</github_organization>
</properties>

<dependencies>
Expand Down Expand Up @@ -142,4 +143,11 @@
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/${github_organization}/jpo-sdw-depositor</url>
</repository>
</distributionManagement>
</project>

0 comments on commit beabe6d

Please sign in to comment.