From c2f72e87209f74ce24e95ab155515d2a4fea6d81 Mon Sep 17 00:00:00 2001 From: reimer-atb <5737222+reimer-atb@users.noreply.github.com> Date: Wed, 26 Jun 2024 01:32:39 +0200 Subject: [PATCH] test publishing jars to github maven package repository --- .github/workflows/publish-container-image.yml | 62 ------------------- .github/workflows/publish.yml | 38 ++++++++++++ .github/workflows/run-tests.yml | 33 ---------- .github/workflows/test.yml | 33 ++++++++++ context-core/pom.xml | 14 ++--- context-extraction/pom.xml | 2 +- context-monitoring/pom.xml | 2 +- pom.xml | 18 +++++- smartclide-monitoring/pom.xml | 24 ++++++- 9 files changed, 117 insertions(+), 109 deletions(-) delete mode 100644 .github/workflows/publish-container-image.yml create mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/run-tests.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/publish-container-image.yml b/.github/workflows/publish-container-image.yml deleted file mode 100644 index dee16930..00000000 --- a/.github/workflows/publish-container-image.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: publish-container-image - -on: - push: - branches: - - main - release: - types: [released, prereleased] - -jobs: - build: - - runs-on: ubuntu-latest - - env: - CONTAINER_REGISTRY_USERNAME: ${GITHUB_ACTOR} - CONTAINER_REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SMARTCLIDE_CONTEXT_GITLAB_API_TOKEN: ${{ secrets.GITLAB_DEV_SMARTCLIDE_EU_API_TOKEN }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up JDK 11 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: 11 - - - name: Cache Maven Packages - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('./**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - - name: Build necessary modules - run: mvn install -pl context-monitoring -am - - - name: Get short commit SHA - if: ${{ github.event_name == 'push' }} - id: get_short_commit_SHA - run: echo "sha8=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_OUTPUT - - - name: Build Image - if: ${{ github.event_name == 'push' }} - env: - IMAGE_TAG: ${{ steps.get_short_commit_SHA.outputs.sha8}} - run: mvn test jib:build -pl smartclide-monitoring -Djib.to.auth.username="${CONTAINER_REGISTRY_USERNAME}" -Djib.to.auth.password="${CONTAINER_REGISTRY_TOKEN}" -Djib.to.tags="${IMAGE_TAG}" - - # below code triggers only for release events - - - name: Get tag name - if: ${{ github.event_name == 'release' }} - id: get_tag_name - run: echo "TAG_NAME=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT - - - name: Build Image for Release - if: ${{ github.event_name == 'release' }} - env: - IMAGE_TAG: ${{ steps.get_tag_name.outputs.TAG_NAME }} - run: mvn test jib:build -pl smartclide-monitoring -Djib.to.auth.username="${CONTAINER_REGISTRY_USERNAME}" -Djib.to.auth.password="${CONTAINER_REGISTRY_TOKEN}" -Djib.to.tags="${IMAGE_TAG}" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..5ef72f55 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,38 @@ +name: publish + +on: + release: + types: [published] + +jobs: + publish: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 11 + + - name: Cache Maven Packages + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('./**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + - name: Publish Packages + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CONTAINER_REGISTRY_USERNAME: ${GITHUB_ACTOR} + CONTAINER_REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SMARTCLIDE_CONTEXT_GITLAB_API_TOKEN: ${{ secrets.GITLAB_DEV_SMARTCLIDE_EU_API_TOKEN }} + run: mvn --file pom.xml --batch-mode deploy -Djib.to.auth.username="${CONTAINER_REGISTRY_USERNAME}" -Djib.to.auth.password="${CONTAINER_REGISTRY_TOKEN}" \ No newline at end of file diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml deleted file mode 100644 index 266faf47..00000000 --- a/.github/workflows/run-tests.yml +++ /dev/null @@ -1,33 +0,0 @@ -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven - -name: run-tests - -on: - push - -jobs: - test: - - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up JDK 11 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: 11 - - - name: Cache Maven Packages - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('./**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - - name: Run Tests - run: mvn --file pom.xml --batch-mode test - env: - SMARTCLIDE_CONTEXT_GITLAB_API_TOKEN: ${{ secrets.GITLAB_DEV_SMARTCLIDE_EU_API_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..ac8c2efd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,33 @@ +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: run-tests + +on: + push + +jobs: + test: + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 11 + + - name: Cache Maven Packages + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('./**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + - name: Run Tests + env: + SMARTCLIDE_CONTEXT_GITLAB_API_TOKEN: ${{ secrets.GITLAB_DEV_SMARTCLIDE_EU_API_TOKEN }} + run: mvn --file pom.xml --batch-mode test \ No newline at end of file diff --git a/context-core/pom.xml b/context-core/pom.xml index 3ff60d6c..1c06c4bc 100644 --- a/context-core/pom.xml +++ b/context-core/pom.xml @@ -6,7 +6,7 @@ org.eclipse.opensmartclide.context parent - 2.0.0 + 2.0.1-SNAPSHOT context-core @@ -77,7 +77,7 @@ 2.0.7 - + org.apache.cxf cxf-rt-frontend-jaxws @@ -100,23 +100,23 @@ cxf-rt-transports-http-hc ${cxf.version} - + - + org.simpleframework simple-xml 2.7.1 - + - + com.google.code.gson gson 2.11.0 - + org.projectlombok diff --git a/context-extraction/pom.xml b/context-extraction/pom.xml index 8aae933e..d9c54d8e 100644 --- a/context-extraction/pom.xml +++ b/context-extraction/pom.xml @@ -6,7 +6,7 @@ org.eclipse.opensmartclide.context parent - 2.0.0 + 2.0.1-SNAPSHOT context-extraction diff --git a/context-monitoring/pom.xml b/context-monitoring/pom.xml index eeaa096d..ce3ca19e 100644 --- a/context-monitoring/pom.xml +++ b/context-monitoring/pom.xml @@ -6,7 +6,7 @@ org.eclipse.opensmartclide.context parent - 2.0.0 + 2.0.1-SNAPSHOT context-monitoring diff --git a/pom.xml b/pom.xml index 2bd0c81a..404ff764 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.eclipse.opensmartclide.context parent - 2.0.0 + 2.0.1-SNAPSHOT pom @@ -20,6 +20,14 @@ https://www.atb-bremen.de + + + github + GitHub Packages + https://maven.pkg.github.com/eclipse-opensmartclide/smartclide-context + + + UTF-8 3.5.4 @@ -80,7 +88,8 @@ - + + **/*.json @@ -156,6 +165,11 @@ maven-surefire-plugin 3.3.0 + + org.apache.maven.plugins + maven-deploy-plugin + 3.1.2 + diff --git a/smartclide-monitoring/pom.xml b/smartclide-monitoring/pom.xml index 035bd050..52fcdf9e 100644 --- a/smartclide-monitoring/pom.xml +++ b/smartclide-monitoring/pom.xml @@ -6,7 +6,7 @@ org.eclipse.opensmartclide.context parent - 2.0.0 + 2.0.1-SNAPSHOT smartclide-monitoring @@ -23,7 +23,7 @@ org.eclipse.opensmartclide.context context-monitoring - 2.0.0 + 2.0.1-SNAPSHOT @@ -35,16 +35,34 @@ + + org.apache.maven.plugins + maven-deploy-plugin + + + true + + + com.google.cloud.tools jib-maven-plugin ${jib-maven-plugin.version} + + + + deploy + + build + + + eclipse-temurin:11.0.17_8-jre-jammy - ghcr.io/eclipse-opensmartclide/smartclide/${project.artifactId}:latest + ghcr.io/eclipse-opensmartclide/smartclide/${project.artifactId}:${project.version}