You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by vy...@apache.org on 2023/10/25 14:54:29 UTC

[logging-parent] 01/02: Auto-derive distribution attachments from the deployed ones

This is an automated email from the ASF dual-hosted git repository.

vy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/logging-parent.git

commit 9c48549a594d2c343c6bfbc90a5b9dfd6f103a5e
Author: Volkan Yazıcı <vo...@yazi.ci>
AuthorDate: Wed Oct 25 16:53:32 2023 +0200

    Auto-derive distribution attachments from the deployed ones
---
 .github/workflows/build.yaml                       |  1 -
 .github/workflows/deploy-release-reusable.yaml     | 42 +++++++++++++++++++---
 .../.10.x.x/auto-derive-dist-attachments.xml       | 10 ++++++
 src/site/_release-notes/_10.x.x.adoc               |  1 +
 4 files changed, 48 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index eab8e28..30b670f 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -73,5 +73,4 @@ jobs:
       contents: write
     with:
       project-id: logging-parent
-      distribution-attachment-count: 0
       site-enabled: true
diff --git a/.github/workflows/deploy-release-reusable.yaml b/.github/workflows/deploy-release-reusable.yaml
index d7f2060..131ce8a 100644
--- a/.github/workflows/deploy-release-reusable.yaml
+++ b/.github/workflows/deploy-release-reusable.yaml
@@ -34,12 +34,11 @@ on:
         type: boolean
       distribution-attachment-filepath-pattern:
         description: The regex pattern matched against the full filepath for determining attachments to be included in the distribution
-        default: |-
-          '^.*/target/log4j-(.+)-'${PROJECT_VERSION}'(-tests)?\\.jar$'
+        default: ""
         type: string
       distribution-attachment-count:
         description: The number of attachments expected to be found
-        required: true
+        default: 0
         type: number
     secrets:
       GPG_SECRET_KEY:
@@ -166,6 +165,39 @@ jobs:
           # `SIGN_KEY` is used by `sign-maven-plugin`
           SIGN_KEY: ${{ secrets.GPG_SECRET_KEY }}
 
+      - name: Stage distribution attachments
+        shell: bash
+        run: |
+
+          # Determine the distribution attachment filepath pattern, if none provided
+          if [[ -z "$DIST_ATTACHMENT_FILEPATH_PATTERN" ]]; then
+
+            # Dump deployed artifacts to a local folder
+            export ALT_DEPLOYMENT_REPO_FILEPATH="target/alt-deployment-repo"
+            mkdir "$ALT_DEPLOYMENT_REPO_FILEPATH"
+            ./mvnw \
+              --show-version --batch-mode --errors --no-transfer-progress \
+              -DaltDeploymentRepository=apache.releases.https::file:"$ALT_DEPLOYMENT_REPO_FILEPATH" \
+              -Dsign.skip \
+              -P deploy
+
+            # This regex needs to work for both Java (`distribution` profile) and `find` (while counting attachments)!
+            # Hence, we don't escape dots, etc. with backslashes, which is problematic to get working in both worlds.
+            export DIST_ATTACHMENT_FILEPATH_PATTERN="^$ALT_DEPLOYMENT_REPO_FILEPATH/log4j-.+-$PROJECT_VERSION"'((-tests)?.jar|-cyclonedx.(xml|json))$'
+            export DIST_ATTACHMENT_COUNT=$(find "$ALT_DEPLOYMENT_REPO_FILEPATH" -type f -regextype posix-extended -regex "$DIST_ATTACHMENT_FILEPATH_PATTERN" | wc -l)
+
+          fi
+
+          # Pass the necessary environment variables
+          cat >> $GITHUB_ENV << EOF
+          DIST_ATTACHMENT_FILEPATH_PATTERN=$DIST_ATTACHMENT_FILEPATH_PATTERN
+          DIST_ATTACHMENT_COUNT=$DIST_ATTACHMENT_COUNT
+          EOF
+
+        env:
+          DIST_ATTACHMENT_FILEPATH_PATTERN: ${{ inputs.distribution-attachment-filepath-pattern }}
+          DIST_ATTACHMENT_COUNT: ${{ inputs.distribution-attachment-count }}
+
       - name: Create the distribution
         shell: bash
         run: |
@@ -175,8 +207,8 @@ jobs:
             --show-version --batch-mode --errors --no-transfer-progress \
             --non-recursive \
             -P distribution \
-            -DattachmentFilepathPattern=${{ inputs.distribution-attachment-filepath-pattern }} \
-            -DattachmentCount=${{ inputs.distribution-attachment-count }}
+            -DattachmentFilepathPattern="$DIST_ATTACHMENT_FILEPATH_PATTERN" \
+            -DattachmentCount="$DIST_ATTACHMENT_COUNT"
 
           # Rename distribution files
           export DIST_FILENAME_PREFIX="apache-${{ inputs.project-id }}"
diff --git a/src/changelog/.10.x.x/auto-derive-dist-attachments.xml b/src/changelog/.10.x.x/auto-derive-dist-attachments.xml
new file mode 100644
index 0000000..f0a1854
--- /dev/null
+++ b/src/changelog/.10.x.x/auto-derive-dist-attachments.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns="http://logging.apache.org/log4j/changelog"
+       xsi:schemaLocation="http://logging.apache.org/log4j/changelog https://logging.apache.org/log4j/changelog-0.1.2.xsd"
+       type="changed">
+  <description format="asciidoc">
+    `deploy-release-reusable.yaml` is improved to automatically derive deployed artifacts as attachments.
+    This renders both `distribution-attachment-filepath-pattern` and `distribution-attachment-count` input arguments redundant for almost all cases.
+  </description>
+</entry>
diff --git a/src/site/_release-notes/_10.x.x.adoc b/src/site/_release-notes/_10.x.x.adoc
index bdbad95..e0205e6 100644
--- a/src/site/_release-notes/_10.x.x.adoc
+++ b/src/site/_release-notes/_10.x.x.adoc
@@ -47,6 +47,7 @@ This minor release contains several small improvements.
 
 ==== Changed
 
+* `deploy-release-reusable.yaml` is improved to automatically derive deployed artifacts as attachments. This renders both `distribution-attachment-filepath-pattern` and `distribution-attachment-count` input arguments redundant for almost all cases.
 * Convert `bnd-maven-plugin` API leakage warnings to errors (https://github.com/apache/logging-log4j2/issues/1895[apache/logging-log4j2#1895])
 * Update `com.google.errorprone:error_prone_core` to version `2.23.0` (https://github.com/apache/logging-parent/pull/49[49])
 * Update `github/codeql-action` to version `2.22.4` (https://github.com/apache/logging-parent/pull/51[51])