diff --git a/.github/workflows/artifact-publish.yml b/.github/workflows/artifact-publish.yml new file mode 100644 index 0000000..d88af02 --- /dev/null +++ b/.github/workflows/artifact-publish.yml @@ -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 }} \ No newline at end of file diff --git a/README.md b/README.md index 3903eeb..028c53d 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file +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 + + + + github + + + + + github + + + central + https://repo1.maven.org/maven2 + + + github + https://maven.pkg.github.com/usdot-jpo-ode/jpo-sdw-depositor + + + + + + + + github + ${env.PACKAGE_READ_USERNAME} + ${env.PACKAGE_READ_TOKEN} + + + + +``` + +And add the following line to the `dependencies` element in `build.gradle` + +```xml + + + usdot.jpo.ode + jpo-sdw-depositor + 1.0.0 + + +``` + +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. diff --git a/pom.xml b/pom.xml index 83d68ac..c21378f 100644 --- a/pom.xml +++ b/pom.xml @@ -30,6 +30,7 @@ reuseReports ${project.basedir}/target/site/jacoco/jacoco.xml java + usdot-jpo-ode @@ -142,4 +143,11 @@ + + + github + GitHub Packages + https://maven.pkg.github.com/${github_organization}/jpo-sdw-depositor + + \ No newline at end of file