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/Dockerfile b/Dockerfile index 65c6338..edc73cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,8 +14,8 @@ RUN mvn clean package -DskipTests FROM eclipse-temurin:21-jre-alpine WORKDIR /home -COPY --from=builder /home/target/jpo-sdw-depositor-1.7.0-SNAPSHOT.jar /home +COPY --from=builder /home/target/jpo-sdw-depositor-1.8.0-SNAPSHOT.jar /home ENTRYPOINT ["java", \ "-jar", \ - "/home/jpo-sdw-depositor-1.7.0-SNAPSHOT.jar"] + "/home/jpo-sdw-depositor-1.8.0-SNAPSHOT.jar"] 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/docs/Release_notes.md b/docs/Release_notes.md index be6c04f..53566b7 100644 --- a/docs/Release_notes.md +++ b/docs/Release_notes.md @@ -1,6 +1,16 @@ jpo-sdw-depositor Release Notes ---------------------------- +Version 1.8.0, released September 2024 +---------------------------------------- +### **Summary** +The changes for the jpo-sdw-depositor 1.8.0 release include a fix for the SDW_SUBSCRIPTION_TOPIC environment variable not getting used instead of the default if provided, as well as the addition of a GitHub action to publish Java artifacts to GitHub's hosted Maven Central. + +Enhancements in this release: +- CDOT PR 24: Fixed SDW_SUBSCRIPTION_TOPIC environment variable not getting used instead of default if provided +- CDOT PR 25: Added a GiHub action to opublish java artifacts to GitHub's hosted Maven Central + + Version 1.7.0, released June 2024 ---------------------------------------- ### **Summary** diff --git a/pom.xml b/pom.xml index 2f3eb89..87c0e2b 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ usdot.jpo.ode jpo-sdw-depositor - 1.7.0-SNAPSHOT + 1.8.0-SNAPSHOT jar jpo-sdw-depositor @@ -30,6 +30,7 @@ reuseReports ${project.basedir}/target/site/jacoco/jacoco.xml java + usdot-jpo-ode @@ -108,6 +109,9 @@ ${loader.path} ${project.build.directory} + + testSubscriptionTopic + @@ -139,4 +143,11 @@ + + + github + GitHub Packages + https://maven.pkg.github.com/${github_organization}/jpo-sdw-depositor + + \ No newline at end of file diff --git a/src/main/java/jpo/sdw/depositor/DepositorProperties.java b/src/main/java/jpo/sdw/depositor/DepositorProperties.java index 7350c55..f657948 100644 --- a/src/main/java/jpo/sdw/depositor/DepositorProperties.java +++ b/src/main/java/jpo/sdw/depositor/DepositorProperties.java @@ -2,8 +2,6 @@ import java.util.regex.Pattern; -import jakarta.annotation.PostConstruct; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -12,6 +10,8 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; +import jakarta.annotation.PostConstruct; + @ConfigurationProperties("sdw") @PropertySource("classpath:application.properties") public class DepositorProperties implements EnvironmentAware { @@ -66,9 +66,15 @@ void initialize() { } if (getSubscriptionTopics() == null || getSubscriptionTopics().length == 0) { - String topics = String.join(",", DEFAULT_SUBSCRIPTION_TOPICS); - logger.info("No Kafka subscription topics specified in configuration, defaulting to {}", topics); - subscriptionTopics = DEFAULT_SUBSCRIPTION_TOPICS; + // get environment variable SDW_SUBSCRIPTION_TOPIC + String topics = System.getenv("SDW_SUBSCRIPTION_TOPIC"); + if (topics == null || topics.isEmpty()) { + topics = String.join(",", DEFAULT_SUBSCRIPTION_TOPICS); + logger.info("No Kafka subscription topics specified in configuration, defaulting to {}", topics); + subscriptionTopics = DEFAULT_SUBSCRIPTION_TOPICS; + } else { + subscriptionTopics = topics.split(","); + } } if (getApiKey() == null || getApiKey().isEmpty()) {