From 40ff50fc4851dda9158c9017ec66927419c913b0 Mon Sep 17 00:00:00 2001 From: Daniel Frick - taafrda7 Date: Wed, 26 Jun 2024 13:50:12 +0200 Subject: [PATCH] publish release and develop changes. Updates logback configuration --- .github/CODEOWNERS | 2 + .github/workflows/publish.yml | 35 +++++++ README.md | 14 +++ build.gradle.kts | 30 +++++- src/main/resources/logback-spring.xml | 129 ++++++++++++-------------- 5 files changed, 137 insertions(+), 73 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/workflows/publish.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..f5b4c9c --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# Only the specified owner can approve changes to workflow files +/.github/workflows/ @swisscom/swisscom-health diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..84d5c05 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,35 @@ +name: Publish release + +on: + push: + branches: + - develop + release: + types: [created] + +jobs: + publish-release: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout latest code + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + + # Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies. + # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md + - name: Setup Gradle + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + + - name: Build and publish with Gradle Wrapper + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./gradlew clean build publishVersion diff --git a/README.md b/README.md index 0f4643a..f3907bb 100644 --- a/README.md +++ b/README.md @@ -57,3 +57,17 @@ client: source-folder: /tmp/source/8000000000000 mode: test ``` + +## Running the Jar +If the provided jar should be run directly, the following command can be used: +```java -jar cdr-client.jar``` +The jar can be found in build/libs. + +Following environment variables need to be present (and correctly configured) so that the application can start successfully: +``` +SPRING_CONFIG_ADDITIONAL_LOCATION={{ cdr_client_dir }}/config/application-customer.yaml" +LOGGING_FILE_NAME={{ cdr_client_dir }}/logs/cdr-client.log" +``` +The LOGGING_FILE_NAME is just so that the log file is not auto created where the jar is run from. + +See [Application Plugin](#application-plugin) regarding the content of the application-customer.yaml diff --git a/build.gradle.kts b/build.gradle.kts index e384aea..19f9ed0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,8 +1,9 @@ import io.gitlab.arturbosch.detekt.Detekt import org.springframework.boot.gradle.tasks.bundling.BootJar +import java.net.URI group = "com.swisscom.health.des.cdr" -version = "2.1.2-SNAPSHOT" +version = "3.0.0-SNAPSHOT" java.sourceCompatibility = JavaVersion.VERSION_17 val jvmVersion: String by project @@ -184,3 +185,30 @@ project.afterEvaluate { } } } + +tasks.register("publishVersion") { + group = "publishing" + description = "Publishes boot jar" + dependsOn(tasks.withType().matching { + it.repository == publishing.repositories["GitHubPackages"] && it.publication == publishing.publications["bootJava"] + }) +} + + +publishing { + publications { + create("bootJava") { + artifact(tasks.named("bootJar")) + } + } + repositories { + maven { + name = "GitHubPackages" + url = URI("https://maven.pkg.github.com/swisscom/cdr-client") + credentials { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } + } + } +} diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index 5ab0818..79abafd 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -1,81 +1,66 @@ - + - - + + - - - - %highlight(%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", UTC}) | %highlight(${LOG_LEVEL_PATTERN:-%5p}) | %highlight(%magenta(${PID:- })) | %highlight(%yellow(%X{traceId:-None})) | %highlight([%15.15t]) | %highlight(%cyan(%-40.40logger{39})) | %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%ex} - - - - - - - + + ${LOGGING_FILE_NAME:-./cdr-client.log} + true - - - ${LOGGING_FILE_NAME:-./cdr-client.log} - true + + ${LOGGING_FILE_NAME:-./cdr-client.log}.%d{yyyy-MM-dd}.%i.log + ${LOGGING_LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-100MB} + ${LOGGING_LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-2} + - - ${LOGGING_FILE_NAME:-./cdr-client.log}.%d{yyyy-MM-dd}.%i.log - ${LOGGING_LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-100MB} - ${LOGGING_LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-2} - - - - %d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", UTC} | ${%level:-%5p} | ${PID:- } | %X{traceId:-None} | [%15.15t] | %-40.40logger{39} | %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%ex} - - - - - - - - timestamp - UTC - - - logger - - - level - - - thread - - - mdc - - - - - - stackTrace - - - 200 - 14000 - true - - - - - exceptionClass - - - - - - - - - + + %d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", UTC} | ${%level:-%5p} | ${PID:- } | %X{traceId:-None} | [%15.15t] | %-40.40logger{39} | %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%ex} + + + + + + + timestamp + UTC + + + logger + + + level + + + thread + + + mdc + + + + + + stackTrace + + + 200 + 14000 + true + + + + + exceptionClass + + + + + + + +