From db38f77fa3e23233d366058406ad1f90b75470da Mon Sep 17 00:00:00 2001
From: Pat <pat@calyptia.com>
Date: Tue, 19 Dec 2023 10:02:27 +0000
Subject: [PATCH] workflows: handle v4 upload-artifact usage (#8304)

Signed-off-by: Patrick Stephens <pat@calyptia.com>
---
 .github/workflows/call-build-images.yaml          |  2 +-
 .github/workflows/call-build-linux-packages.yaml  |  6 +++---
 .github/workflows/call-build-macos.yaml           |  2 +-
 .github/workflows/call-build-windows.yaml         |  6 +++---
 .../workflows/call-integration-image-build.yaml   | 15 ---------------
 .github/workflows/cron-scorecards-analysis.yaml   |  2 +-
 .github/workflows/cron-trivy.yaml                 |  2 +-
 .github/workflows/pr-fuzz.yaml                    |  2 +-
 8 files changed, 11 insertions(+), 26 deletions(-)

diff --git a/.github/workflows/call-build-images.yaml b/.github/workflows/call-build-images.yaml
index 507dc405873..0d0176c77d5 100644
--- a/.github/workflows/call-build-images.yaml
+++ b/.github/workflows/call-build-images.yaml
@@ -181,7 +181,7 @@ jobs:
         shell: bash
 
       - name: Upload the schema
-        uses: actions/upload-artifact@v3
+        uses: actions/upload-artifact@v4
         with:
           path: ./fluent-bit-schema*.json
           name: fluent-bit-schema-${{ inputs.version }}
diff --git a/.github/workflows/call-build-linux-packages.yaml b/.github/workflows/call-build-linux-packages.yaml
index afe84807333..7a79b382d32 100644
--- a/.github/workflows/call-build-linux-packages.yaml
+++ b/.github/workflows/call-build-linux-packages.yaml
@@ -78,7 +78,7 @@ jobs:
           SOURCE_FILENAME_PREFIX: source-${{ inputs.version }}
 
       - name: Upload the source artifacts
-        uses: actions/upload-artifact@v3
+        uses: actions/upload-artifact@v4
         with:
           name: source-${{ inputs.version }}
           path: source-packages/*
@@ -132,7 +132,7 @@ jobs:
 
       - name: Replace all special characters with dashes
         id: formatted_distro
-        run:
+        run: |
           output=${INPUT//[\/]/-}
           echo "$INPUT --> $output"
           echo "replaced=$output" >> "$GITHUB_OUTPUT"
@@ -151,7 +151,7 @@ jobs:
         working-directory: packaging
 
       - name: Upload the ${{ steps.formatted_distro.outputs.replaced }} artifacts
-        uses: actions/upload-artifact@v3
+        uses: actions/upload-artifact@v4
         with:
           name: packages-${{ inputs.version }}-${{ steps.formatted_distro.outputs.replaced }}
           path: packaging/packages/
diff --git a/.github/workflows/call-build-macos.yaml b/.github/workflows/call-build-macos.yaml
index 4472ad96509..229d9c73ffd 100644
--- a/.github/workflows/call-build-macos.yaml
+++ b/.github/workflows/call-build-macos.yaml
@@ -90,7 +90,7 @@ jobs:
         working-directory: build
 
       - name: Upload build packages
-        uses: actions/upload-artifact@v3
+        uses: actions/upload-artifact@v4
         with:
           name: macos-packages
           path: |
diff --git a/.github/workflows/call-build-windows.yaml b/.github/workflows/call-build-windows.yaml
index 0b5dec60e22..6686b427059 100644
--- a/.github/workflows/call-build-windows.yaml
+++ b/.github/workflows/call-build-windows.yaml
@@ -168,9 +168,9 @@ jobs:
       - name: Upload build packages
         # Skip upload if we skipped build.
         if: ${{ matrix.config.arch != 'amd64_arm64' || needs.call-build-windows-get-meta.outputs.armSupported == 'true' }}
-        uses: actions/upload-artifact@v3
+        uses: actions/upload-artifact@v4
         with:
-          name: windows-packages
+          name: windows-packages-${{ matrix.config.arch }}
           path: |
             build/*-bit-*.exe
             build/*-bit-*.msi
@@ -198,7 +198,7 @@ jobs:
         continue-on-error: true
         uses: actions/download-artifact@v4
         with:
-          name: windows-packages
+          pattern: windows-packages-*
           path: artifacts/
 
       - name: Set up Windows checksums
diff --git a/.github/workflows/call-integration-image-build.yaml b/.github/workflows/call-integration-image-build.yaml
index 1644883c0d4..0dbba48a919 100644
--- a/.github/workflows/call-integration-image-build.yaml
+++ b/.github/workflows/call-integration-image-build.yaml
@@ -74,21 +74,6 @@ jobs:
           push: true
           load: false
 
-      - name: Upload the image just in case as an artefact
-        run: |
-          docker pull $IMAGE
-          docker save --output /tmp/pr-image.tar $IMAGE
-        env:
-          IMAGE: ${{ steps.meta.outputs.tags }}
-        shell: bash
-
-      - name: Upload artifact
-        uses: actions/upload-artifact@v3
-        with:
-          name: pr-${{ github.event.pull_request.number }}-image
-          path: /tmp/pr-image.tar
-          if-no-files-found: error
-
       - name: Extract metadata from Github
         id: meta-debug
         uses: docker/metadata-action@v5
diff --git a/.github/workflows/cron-scorecards-analysis.yaml b/.github/workflows/cron-scorecards-analysis.yaml
index 17263161ff0..5e234f2dcfa 100644
--- a/.github/workflows/cron-scorecards-analysis.yaml
+++ b/.github/workflows/cron-scorecards-analysis.yaml
@@ -45,7 +45,7 @@ jobs:
           publish_results: true
 
       - name: "Upload artifact"
-        uses: actions/upload-artifact@v3
+        uses: actions/upload-artifact@v4
         with:
           name: SARIF file
           path: scorecard-results.sarif
diff --git a/.github/workflows/cron-trivy.yaml b/.github/workflows/cron-trivy.yaml
index a6a4e442df6..92545149176 100644
--- a/.github/workflows/cron-trivy.yaml
+++ b/.github/workflows/cron-trivy.yaml
@@ -80,7 +80,7 @@ jobs:
 
       # In case we need to analyse the uploaded files for some reason.
       - name: Detain results for debug if needed
-        uses: actions/upload-artifact@v3
+        uses: actions/upload-artifact@v4
         with:
           name: trivy-results-${{ matrix.local_tag }}.sarif
           path: trivy-results-${{ matrix.local_tag }}.sarif
diff --git a/.github/workflows/pr-fuzz.yaml b/.github/workflows/pr-fuzz.yaml
index 473a167fdc7..c8c4b5afb7f 100644
--- a/.github/workflows/pr-fuzz.yaml
+++ b/.github/workflows/pr-fuzz.yaml
@@ -26,7 +26,7 @@ jobs:
         language: c
         output-sarif: true
     - name: Upload Crash
-      uses: actions/upload-artifact@v3
+      uses: actions/upload-artifact@v4
       if: failure() && steps.build.outcome == 'success'
       with:
         name: artifacts