From aaa0a02f4f42ffa44f240fcb39ae82f4dd3d3449 Mon Sep 17 00:00:00 2001 From: fernando Date: Sun, 15 Oct 2023 14:36:07 +0200 Subject: [PATCH 1/8] trying out automated config to release packages of the application --- .github/workflows/maven-packages-publish.yml | 38 ++++++++++++++++++++ settings.xml | 36 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 .github/workflows/maven-packages-publish.yml create mode 100644 settings.xml diff --git a/.github/workflows/maven-packages-publish.yml b/.github/workflows/maven-packages-publish.yml new file mode 100644 index 0000000..d3921bf --- /dev/null +++ b/.github/workflows/maven-packages-publish.yml @@ -0,0 +1,38 @@ +# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created +# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path + +name: Maven Package + +on: + pull_request: + types: [opened, synchronize, reopened] + +#on: +# release: +# types: [created] + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + + - name: Build with Maven + run: mvn -B package --file pom.xml + + - name: Publish to GitHub Packages Apache Maven + run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml + env: + GITHUB_TOKEN: ${{ github.token }} diff --git a/settings.xml b/settings.xml new file mode 100644 index 0000000..d586ab1 --- /dev/null +++ b/settings.xml @@ -0,0 +1,36 @@ + + + + github + + + + + github + + + central + https://repo1.maven.org/maven2 + + + github + https://maven.pkg.github.com/teixeira-fernando/ecommerceapp + + true + + + + + + + + + github + teixeira-fernando + ${github.token} + + + From e2e795b01413bb3ad96014d9946872772f3c1ac9 Mon Sep 17 00:00:00 2001 From: fernando Date: Sun, 15 Oct 2023 14:56:42 +0200 Subject: [PATCH 2/8] trying out automated config to release packages of the application --- .github/workflows/maven-packages-publish.yml | 2 +- Makefile | 6 ++++++ inventory/pom.xml | 8 +++++++- settings.xml | 2 +- shipment/pom.xml | 8 ++++++++ shop/pom.xml | 8 ++++++++ 6 files changed, 31 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven-packages-publish.yml b/.github/workflows/maven-packages-publish.yml index d3921bf..83662b3 100644 --- a/.github/workflows/maven-packages-publish.yml +++ b/.github/workflows/maven-packages-publish.yml @@ -33,6 +33,6 @@ jobs: run: mvn -B package --file pom.xml - name: Publish to GitHub Packages Apache Maven - run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml + run: make publish_all_packages env: GITHUB_TOKEN: ${{ github.token }} diff --git a/Makefile b/Makefile index 0684395..decdec9 100644 --- a/Makefile +++ b/Makefile @@ -14,3 +14,9 @@ run-pact-provider-tests: record_deployment: @"${PACT_CLI}" pact-broker record_deployment --pacticipant ${PACTICIPANT} --version ${GIT_COMMIT} --environment production --broker-base-url=${PACT_BROKER_URL} --broker-token=${PACT_BROKER_TOKEN} + +publish_all_packages: + mvn -f inventory/ deploy -s settings.xml + mvn -f shop/ deploy -s settings.xml + mvn -f shipment/ deploy -s settings.xml + mvn -f base-domain/ deploy -s settings.xml \ No newline at end of file diff --git a/inventory/pom.xml b/inventory/pom.xml index a2184ed..e0acb0a 100644 --- a/inventory/pom.xml +++ b/inventory/pom.xml @@ -226,7 +226,13 @@ - + + + github + my-maven-packages + https://maven.pkg.github.com/teixeira-fernando/ecommerceapp + + Ecommerce Inventory com.ecommerceapp diff --git a/settings.xml b/settings.xml index d586ab1..fc37502 100644 --- a/settings.xml +++ b/settings.xml @@ -30,7 +30,7 @@ github teixeira-fernando - ${github.token} + ${GITHUB_TOKEN} diff --git a/shipment/pom.xml b/shipment/pom.xml index 2dfce01..e6b5319 100644 --- a/shipment/pom.xml +++ b/shipment/pom.xml @@ -17,6 +17,14 @@ jar 0.0.1-SNAPSHOT + + + github + my-maven-packages + https://maven.pkg.github.com/teixeira-fernando/ecommerceapp + + + 11 diff --git a/shop/pom.xml b/shop/pom.xml index 3f6188b..2914ed1 100644 --- a/shop/pom.xml +++ b/shop/pom.xml @@ -304,6 +304,14 @@ shop jar + + + github + my-maven-packages + https://maven.pkg.github.com/teixeira-fernando/ecommerceapp + + + org.springframework.boot spring-boot-starter-parent From 0d12094273cf8f46b868a91bd3a765af9ba55ebd Mon Sep 17 00:00:00 2001 From: fernando Date: Sun, 15 Oct 2023 15:06:57 +0200 Subject: [PATCH 3/8] trying out automated config to release packages of the application --- .github/workflows/maven-packages-publish.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/maven-packages-publish.yml b/.github/workflows/maven-packages-publish.yml index 83662b3..8e68b7f 100644 --- a/.github/workflows/maven-packages-publish.yml +++ b/.github/workflows/maven-packages-publish.yml @@ -33,6 +33,10 @@ jobs: run: mvn -B package --file pom.xml - name: Publish to GitHub Packages Apache Maven - run: make publish_all_packages + run: | + mvn -f inventory/ deploy -s settings.xml + mvn -f shop/ deploy -s settings.xml + mvn -f shipment/ deploy -s settings.xml + mvn -f base-domain/ deploy -s settings.xml env: GITHUB_TOKEN: ${{ github.token }} From a0b5996e5caa434b775492f31c485b992743cf91 Mon Sep 17 00:00:00 2001 From: fernando Date: Sun, 15 Oct 2023 15:19:46 +0200 Subject: [PATCH 4/8] trying out automated config to release packages of the application --- .github/workflows/maven-packages-publish.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/maven-packages-publish.yml b/.github/workflows/maven-packages-publish.yml index 8e68b7f..10d7db1 100644 --- a/.github/workflows/maven-packages-publish.yml +++ b/.github/workflows/maven-packages-publish.yml @@ -29,9 +29,6 @@ jobs: server-id: github # Value of the distributionManagement/repository/id field of the pom.xml settings-path: ${{ github.workspace }} # location for the settings.xml file - - name: Build with Maven - run: mvn -B package --file pom.xml - - name: Publish to GitHub Packages Apache Maven run: | mvn -f inventory/ deploy -s settings.xml @@ -39,4 +36,4 @@ jobs: mvn -f shipment/ deploy -s settings.xml mvn -f base-domain/ deploy -s settings.xml env: - GITHUB_TOKEN: ${{ github.token }} + GITHUB_TOKEN: ${{ github.token }} \ No newline at end of file From 51406cea5905fb02a0688b92b29486e069699e15 Mon Sep 17 00:00:00 2001 From: fernando Date: Sun, 15 Oct 2023 17:07:13 +0200 Subject: [PATCH 5/8] Created Makefile to get rid of duplicated code in pipeline --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index decdec9..eaf1650 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ record_deployment: @"${PACT_CLI}" pact-broker record_deployment --pacticipant ${PACTICIPANT} --version ${GIT_COMMIT} --environment production --broker-base-url=${PACT_BROKER_URL} --broker-token=${PACT_BROKER_TOKEN} publish_all_packages: - mvn -f inventory/ deploy -s settings.xml - mvn -f shop/ deploy -s settings.xml - mvn -f shipment/ deploy -s settings.xml - mvn -f base-domain/ deploy -s settings.xml \ No newline at end of file + mvn -f inventory/ deploy -s settings.xml -Dserver.github.password=${GITHUB_TOKEN} + mvn -f shop/ deploy -s settings.xml -Dserver.github.password=${GITHUB_TOKEN} + mvn -f shipment/ deploy -s settings.xml -Dserver.github.password=${GITHUB_TOKEN} + mvn -f base-domain/ deploy -s settings.xml -Dserver.github.password=${GITHUB_TOKEN} \ No newline at end of file From db0bdf824ee4a5e49781e03c1d5feee1ad86d900 Mon Sep 17 00:00:00 2001 From: fernando Date: Sun, 15 Oct 2023 17:07:48 +0200 Subject: [PATCH 6/8] created settings.xml file to connect with private maven repository --- settings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.xml b/settings.xml index fc37502..2c35ac8 100644 --- a/settings.xml +++ b/settings.xml @@ -30,7 +30,7 @@ github teixeira-fernando - ${GITHUB_TOKEN} + ${server.github.password} From 8bf6e6d021397018eaa312a81319018a8e0d3903 Mon Sep 17 00:00:00 2001 From: fernando Date: Sun, 15 Oct 2023 17:08:16 +0200 Subject: [PATCH 7/8] changes in pom.xml from every module to add config to deploy jar to private repository --- base-domain/pom.xml | 7 +++++-- inventory/pom.xml | 4 ++-- shipment/pom.xml | 4 ++-- shop/pom.xml | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/base-domain/pom.xml b/base-domain/pom.xml index d3e4bcb..630c7dc 100644 --- a/base-domain/pom.xml +++ b/base-domain/pom.xml @@ -10,8 +10,10 @@ base-domain + Module with shared domain classes from Ecommerce project base-domain - 1.0.0 + ${revision} + jar @@ -65,7 +67,7 @@ github - my-maven-packages + teixeira-fernando https://maven.pkg.github.com/teixeira-fernando/ecommerceapp @@ -76,6 +78,7 @@ 11 UTF-8 VERBOSE + 1.0.0-SNAPSHOT \ No newline at end of file diff --git a/inventory/pom.xml b/inventory/pom.xml index e0acb0a..a0ee319 100644 --- a/inventory/pom.xml +++ b/inventory/pom.xml @@ -145,7 +145,7 @@ com.ecommerceapp base-domain - 1.0.0 + 1.0.0-SNAPSHOT spring-boot-starter-actuator @@ -229,7 +229,7 @@ github - my-maven-packages + teixeira-fernando https://maven.pkg.github.com/teixeira-fernando/ecommerceapp diff --git a/shipment/pom.xml b/shipment/pom.xml index e6b5319..e6df597 100644 --- a/shipment/pom.xml +++ b/shipment/pom.xml @@ -20,7 +20,7 @@ github - my-maven-packages + teixeira-fernando https://maven.pkg.github.com/teixeira-fernando/ecommerceapp @@ -178,7 +178,7 @@ com.ecommerceapp base-domain - 1.0.0 + 1.0.0-SNAPSHOT spring-boot-starter-actuator diff --git a/shop/pom.xml b/shop/pom.xml index 2914ed1..55777cb 100644 --- a/shop/pom.xml +++ b/shop/pom.xml @@ -151,7 +151,7 @@ com.ecommerceapp base-domain - 1.0.0 + 1.0.0-SNAPSHOT spring-boot-starter-actuator @@ -307,7 +307,7 @@ github - my-maven-packages + teixeira-fernando https://maven.pkg.github.com/teixeira-fernando/ecommerceapp From 664bcb3484d319fa11eedabd041216532e7b39cc Mon Sep 17 00:00:00 2001 From: fernando Date: Sun, 15 Oct 2023 17:08:51 +0200 Subject: [PATCH 8/8] pipeline config to deploy packages when releasing a new version --- .github/workflows/maven-packages-publish.yml | 28 ++++++-------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/.github/workflows/maven-packages-publish.yml b/.github/workflows/maven-packages-publish.yml index 10d7db1..65cb511 100644 --- a/.github/workflows/maven-packages-publish.yml +++ b/.github/workflows/maven-packages-publish.yml @@ -2,14 +2,9 @@ # For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path name: Maven Package - on: - pull_request: - types: [opened, synchronize, reopened] - -#on: -# release: -# types: [created] + release: + types: [created] jobs: build: @@ -20,20 +15,13 @@ jobs: packages: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK 11 uses: actions/setup-java@v3 with: - java-version: '11' - distribution: 'temurin' - server-id: github # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - + java-version: 11 + distribution: 'adopt' + - name: maven install + run: mvn clean install - name: Publish to GitHub Packages Apache Maven - run: | - mvn -f inventory/ deploy -s settings.xml - mvn -f shop/ deploy -s settings.xml - mvn -f shipment/ deploy -s settings.xml - mvn -f base-domain/ deploy -s settings.xml - env: - GITHUB_TOKEN: ${{ github.token }} \ No newline at end of file + run: GITHUB_TOKEN=${{ github.token }} make publish_all_packages \ No newline at end of file