Skip to content

Commit

Permalink
fix(ci): fix breaking changes brought by upload/download artifacts ve…
Browse files Browse the repository at this point in the history
…rsion update (#4848)
  • Loading branch information
mushroomempires authored Feb 8, 2024
2 parents f8f239a + 0efae61 commit 9cda4b4
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 17 deletions.
65 changes: 65 additions & 0 deletions .github/actions/merge-artifacts/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: 'Merge Artifacts'
description: 'Merge Artifacts'
inputs:
target_name:
description: 'The name of the result artifact'
required: true
source_paths:
description: 'The path to the files that will be uplaoded'
required: true
source_name_pattern:
description: "Artifact's pattern to be merged"
required: true
github_token:
description: 'The Github Token to use'
required: true

runs:
using: 'composite'
steps:
- name: Download Artifacts
uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4.1.0
with:
pattern: ${{ inputs.source_name_pattern }}*
path: ${{ inputs.target_name }}
merge-multiple: true

- name: Upload the Regrouped Artifact
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0
with:
name: ${{ inputs.target_name }}
path: |
${{ inputs.source_paths }}
retention-days: 1

- name: Delete Artifacts
run: |
artifact_pattern="${{ inputs.source_name_pattern }}"
TOKEN="${{ inputs.github_token }}"
artifact_exists=true
while [ "$artifact_exists" = true ]; do
artifact_exists=false
artifacts_response=$(curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{ github.repository }}/actions/artifacts?per_page=100")
artifacts=$(echo $artifacts_response | jq -c '.artifacts[]')
echo "Those are the artifacts : $artifacts"
while read row; do
artifact_name=$(echo "$row" | jq -r '.name')
if [[ "$artifact_name" =~ ^.*"$artifact_pattern".* ]]; then
artifact_exists=true
echo "Deleting : $artifact_name"
artifact_id=$(echo "$row" | jq -r '.id')
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{ github.repository }}/actions/artifacts/${artifact_id}"
fi
done <<< "$artifacts"
done
echo "End of Deleting"
shell: bash
2 changes: 1 addition & 1 deletion .github/actions/package-nfpm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ runs:
# Update if condition to true to get packages as artifacts
- if: ${{ false }}
name: Upload package artifacts
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: packages-${{ inputs.distrib }}
path: ./*.${{ inputs.package_extension}}
Expand Down
70 changes: 62 additions & 8 deletions .github/workflows/perl-cpan-libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,18 @@ jobs:
cp -r ~/rpmbuild/RPMS/noarch/*.rpm .
shell: bash

- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
- name: Replace '::' with - in the feature path
id: package-name
run: |
name="${{ matrix.name }}"
name_with_dash="${name//::/-}"
echo "Modified Name: $name_with_dash"
echo "name_with_dash=$name_with_dash" >> $GITHUB_OUTPUT
shell: bash

- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: packages-${{ matrix.package_extension }}-${{ matrix.distrib }}
name: packages-${{ matrix.package_extension }}-${{ matrix.distrib }}-${{ steps.package-name.outputs.name_with_dash }}
path: ./*.${{ matrix.package_extension }}
retention-days: 1

Expand Down Expand Up @@ -354,14 +363,59 @@ jobs:
DEB_BUILD_OPTIONS="nocheck nodocs notest" dh-make-perl make --dist ${{ matrix.distrib }} --build --version ${{ steps.package-version.outputs.package_version }}-${{ matrix.distrib }} --cpan ${{ matrix.name }}
shell: bash

- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
- name: Replace '::' with - in the feature path
id: package-name
run: |
name="${{ matrix.name }}"
name_with_dash="${name//::/-}"
echo "Modified Name: $name_with_dash"
echo "name_with_dash=$name_with_dash" >> $GITHUB_OUTPUT
shell: bash

- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: packages-${{ matrix.package_extension }}-${{ matrix.distrib }}
name: packages-${{ matrix.package_extension }}-${{ matrix.distrib }}-${{ steps.package-name.outputs.name_with_dash}}
path: ./*.${{ matrix.package_extension }}
retention-days: 1

sign-rpm:
merge-package-rpm-artifacts:
needs: [package-rpm]
runs-on: ubuntu-22.04
strategy:
matrix:
distrib: [el8, el9]

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Merging Artifacts
uses: ./.github/actions/merge-artifacts
with:
target_name: packages-rpm-${{ matrix.distrib }}
source_paths: packages-rpm-${{ matrix.distrib }}/*.rpm
source_name_pattern: packages-rpm-${{ matrix.distrib }}-
github_token: ${{ secrets.GITHUB_TOKEN }}

merge-package-deb-artifacts:
needs: [package-deb]
runs-on: ubuntu-22.04
strategy:
matrix:
distrib: [bullseye, bookworm, jammy]

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Merging Artifacts
uses: ./.github/actions/merge-artifacts
with:
target_name: packages-deb-${{ matrix.distrib }}
source_paths: packages-deb-${{ matrix.distrib }}/*.deb
source_name_pattern: packages-deb-${{ matrix.distrib }}-
github_token: ${{ secrets.GITHUB_TOKEN }}

sign-rpm:
needs: [merge-package-rpm-artifacts]

runs-on: ubuntu-22.04
strategy:
Expand All @@ -381,7 +435,7 @@ jobs:

- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
- uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
with:
name: packages-rpm-${{ matrix.distrib }}
path: ./
Expand All @@ -398,13 +452,13 @@ jobs:
key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}

download-and-cache-deb:
needs: [package-deb]
needs: [merge-package-deb-artifacts]
runs-on: ubuntu-22.04
strategy:
matrix:
distrib: [bullseye, bookworm, jammy]
steps:
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
- uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
with:
name: packages-deb-${{ matrix.distrib }}
path: ./
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/perl-crypt-argon2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ jobs:
# set condition to true if artifacts are needed
- if: ${{ false }}
name: Upload package artifacts
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: packages-${{ matrix.distrib }}-${{ matrix.arch }}
path: ./*.${{ matrix.package_extension}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/perl-json-path.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
# set condition to true if artifacts are needed
- if: ${{ false }}
name: Upload package artifacts
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: packages-${{ matrix.distrib }}
path: ./*.${{ matrix.package_extension}}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/perl-keepass-reader.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
path: ./*.rpm
key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}

- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: packages-${{ matrix.distrib }}
path: ./*.rpm
Expand Down Expand Up @@ -149,7 +149,7 @@ jobs:
path: ./*.deb
key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}

- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: packages-${{ matrix.distrib }}
path: ./*.deb
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/perl-libssh-session.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ jobs:
# set condition to true if artifacts are needed
- if: ${{ false }}
name: Upload package artifacts
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: packages-${{ matrix.distrib }}-${{ matrix.arch }}
path: ./*.${{ matrix.package_extension}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/perl-net-curl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ jobs:
# set condition to true if artifacts are needed
- if: ${{ false }}
name: Upload package artifacts
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: packages-${{ matrix.distrib }}-${{ matrix.arch }}
path: ./*.${{ matrix.package_extension }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/perl-openwsman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ jobs:
# set condition to true if artifacts are needed
- if: ${{ false }}
name: Upload package artifacts
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: packages-${{ matrix.distrib }}-${{ matrix.arch }}
path: ./*.${{ matrix.package_extension}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/plink.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
path: ./*.rpm
key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}

- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: packages-${{ matrix.distrib }}
path: ./*.rpm
Expand Down

0 comments on commit 9cda4b4

Please sign in to comment.