From 2f2c15527145b8dca495fa57489c2e3bb29baa48 Mon Sep 17 00:00:00 2001 From: Franco Bellucci Date: Fri, 9 May 2025 18:48:03 +0200 Subject: [PATCH 1/5] Add pom version check --- .github/workflows/build.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 62f5d490..c8084045 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,23 +14,48 @@ jobs: uses: actions/checkout@v2 with: fetch-depth: 0 + + - name: Extract version from pom.xml + id: extract_version + run: | + VERSION=$(xmllint --xpath "/*[local-name()='project']/*[local-name()='version']/text()" pom.xml) + echo "Version in POM: $VERSION" + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Check if version already exists as a GitHub release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION: ${{ steps.extract_version.outputs.version }} + run: | + echo "Checking if version $VERSION exists as a GitHub release..." + + RELEASES=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ + "https://api.github.com/repos/${{ github.repository }}/releases") + + if echo "$RELEASES" | jq -e ".[] | select(.tag_name == \"$VERSION\")" > /dev/null; then + echo "❌ Release with tag '$VERSION' already exists!" + exit 1 + - name: Set up JDK uses: actions/setup-java@v4 with: java-version: 21 distribution: corretto + - name: Cache SonarCloud packages uses: actions/cache@v4 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar + - 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 and analyze env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -44,16 +69,19 @@ jobs: CLOUDINARY_URL: "" MERCADOPAGO_ACCESS_TOKEN: "" run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=open-commercial -Dsonar.projectKey=api:api + - name: Generate changelog if: ${{ github.ref == 'refs/heads/master' }} uses: Bullrich/generate-release-changelog@master id: changelog env: REPO: ${{ github.repository }} + - name: Get release version if: ${{ github.ref == 'refs/heads/master' }} run: | echo "RELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV + - name: Create Release if: ${{ github.ref == 'refs/heads/master' }} uses: actions/create-release@v1 @@ -64,18 +92,22 @@ jobs: release_name: ${{ env.RELEASE_VERSION }} body: | ${{ steps.changelog.outputs.changelog }} + - name: Set up QEMU if: ${{ github.ref == 'refs/heads/master' }} uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx if: ${{ github.ref == 'refs/heads/master' }} uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub if: ${{ github.ref == 'refs/heads/master' }} uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push Docker image if: ${{ github.ref == 'refs/heads/master' }} uses: docker/build-push-action@v3 From e72fc2a7bff5cdd276efe25cf6336e4c71b60367 Mon Sep 17 00:00:00 2001 From: Franco Bellucci Date: Fri, 9 May 2025 18:53:05 +0200 Subject: [PATCH 2/5] Update build.yml --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c8084045..1e3ff693 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,8 +18,7 @@ jobs: - name: Extract version from pom.xml id: extract_version run: | - VERSION=$(xmllint --xpath "/*[local-name()='project']/*[local-name()='version']/text()" pom.xml) - echo "Version in POM: $VERSION" + VERSION=$(grep -m 1 '' pom.xml | sed -E 's/.*(.*)<\/version>.*/\1/') echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Check if version already exists as a GitHub release From 1cd2f464b30a3783a4294daad0c6d0b50df99444 Mon Sep 17 00:00:00 2001 From: Franco Bellucci Date: Fri, 9 May 2025 18:54:53 +0200 Subject: [PATCH 3/5] Update build.yml --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1e3ff693..326e9db4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,6 +34,9 @@ jobs: if echo "$RELEASES" | jq -e ".[] | select(.tag_name == \"$VERSION\")" > /dev/null; then echo "❌ Release with tag '$VERSION' already exists!" exit 1 + else + echo "✅ Version $VERSION has not been released yet." + fi - name: Set up JDK uses: actions/setup-java@v4 From 7465ebf4ca9dd2ea79e2217646898ce17151c094 Mon Sep 17 00:00:00 2001 From: Franco Bellucci Date: Fri, 9 May 2025 18:56:49 +0200 Subject: [PATCH 4/5] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a9b88132..ab8e9a43 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 org.opencommercial api - 1.3.9 + 1.3.10 jar From 3839c668e26f1597bb8cbf6a58ff884e538eab26 Mon Sep 17 00:00:00 2001 From: Franco Bellucci Date: Fri, 9 May 2025 18:57:36 +0200 Subject: [PATCH 5/5] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ab8e9a43..f855a248 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 org.opencommercial api - 1.3.10 + 1.3.11 jar