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 2022/12/27 08:40:52 UTC

[logging-log4j-tools] 02/02: Improve `build.yml` workflow for releases

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

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

commit 255b5d9866d12c0d9f8bf66e25b7e64c66c26b81
Author: Volkan Yazıcı <vo...@yazi.ci>
AuthorDate: Tue Dec 27 09:41:35 2022 +0100

    Improve `build.yml` workflow for releases
---
 .github/workflows/build.yml | 46 +++++++++++++++++++++++++++++----------------
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index ba1b257..0682d09 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -129,42 +129,41 @@ jobs:
 
       - name: Export artifact version
         run: |
-          ./mvnw \
+          export PROJECT_VERSION=$(./mvnw \
             --quiet --batch-mode -DforceStdout=true \
             -Dexpression=project.version \
             help:evaluate \
-            | tee /tmp/mvnw-project-version.out
+            | tail -n 1)
+          echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
 
       - name: Check version (SNAPSHOT)
         if: github.ref == 'refs/heads/master'
         run: |
-          export REVISION=$(</tmp/mvnw-project-version.out)
-          [[ "$REVISION" =~ ^[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT$ ]] || {
-            echo "was expecting a snapshot version, found: $REVISION" 1>&2
+          [[ "$PROJECT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT$ ]] || {
+            echo "was expecting a snapshot version, found: \"$PROJECT_VERSION\"" 1>&2
             exit 1
           }
 
       - name: Check version (RELEASE)
         if: startsWith(github.ref, 'refs/heads/release/')
         run: |
-          export REVISION=$(</tmp/mvnw-project-version.out)
-          [[ "${GITHUB_REF/refs\/heads\/release\//}" == "$REVISION" ]] || {
-            echo "git ref \"$GITHUB_REF\" mismatches with the version: \"$REVISION\"" 1>&2
+          [[ "${GITHUB_REF/refs\/heads\/release\//}" == "$PROJECT_VERSION" ]] || {
+            echo "git ref \"$GITHUB_REF\" mismatches with the version: \"$PROJECT_VERSION\"" 1>&2
             exit 1
           }
-          [[ "$REVISION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || {
-            echo "was expecting a release version, found: \"$REVISION\"" 1>&2
+          [[ "$PROJECT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || {
+            echo "was expecting a release version, found: \"$PROJECT_VERSION\"" 1>&2
             exit 1
           }
           export CHANGELOG_VERSION=$(grep "^== " CHANGELOG.adoc | head -n 1 | sed -r 's/^== (.+) \(.+\)$/\1/')
-          [[ "$REVISION" == "$CHANGELOG_VERSION" ]] || {
-            echo "version \"$REVISION\" doesn't match the one in the CHANGELOG: \"$CHANGELOG_VERSION\"" 1>&2
+          [[ "$PROJECT_VERSION" == "$CHANGELOG_VERSION" ]] || {
+            echo "version \"$PROJECT_VERSION\" doesn't match the one in changelog: \"$CHANGELOG_VERSION\"" 1>&2
             exit 1
           }
           export CURRENT_DATE=$(date +%Y-%m-%d)
           export CHANGELOG_DATE=$(grep "^== " CHANGELOG.adoc | head -n 1 | sed -r 's/^== .+ \((.+)\)$/\1/')
           [[ "$CURRENT_DATE" == "$CHANGELOG_DATE" ]] || {
-            echo "current date \"$CURRENT_DATE\" doesn't match the one in the CHANGELOG: \"$CHANGELOG_DATE\"" 1>&2
+            echo "current date \"$CURRENT_DATE\" doesn't match the one in the changelog: \"$CHANGELOG_DATE\"" 1>&2
             exit 1
           }
 
@@ -185,12 +184,27 @@ jobs:
           NEXUS_USER: ${{ secrets.NEXUS_USER }}
           NEXUS_PW: ${{ secrets.NEXUS_PW }}
 
+      - name: Create artifacts (RELEASE)
+        if: startsWith(github.ref, 'refs/heads/release/')
+        run: |
+          git ls-files -z | xargs -0 /tmp/src.zip --
+          gpg --armor --sign --yes --pinentry-mode error /tmp/src.zip
+
+      - name: Upload artifacts (RELEASE)
+        if: startsWith(github.ref, 'refs/heads/release/')
+        uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb   # 3.1.1
+        with:
+          name: Sources
+          path: |
+            /tmp/src.zip
+            /tmp/src.zip.asc
+        if-no-files-found: error
+
       - name: Tag version (RELEASE)
         if: startsWith(github.ref, 'refs/heads/release/')
         run: |
-          export REVISION=$(</tmp/mvnw-project-version.out)
-          export TAG="v$REVISION"
+          export TAG="v$PROJECT_VERSION"
           git config user.name github-actions
           git config user.email github-actions@github.com
-          git tag "$TAG"
+          git tag --sign "$TAG"
           git push origin "$TAG"