Skip to content

Commit 9769584

Browse files
authored
Merge pull request #16388 from romeroalx/fix-upload-builds-pulp
gh actions build-packages: fix pattern for the download-artifacts action and publication issues
2 parents 82ea647 + 1bddbd8 commit 9769584

File tree

2 files changed

+37
-10
lines changed

2 files changed

+37
-10
lines changed

.github/workflows/build-packages.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ jobs:
343343
- name: Download packages
344344
uses: actions/download-artifact@v4
345345
with:
346-
pattern: "${{ inputs.product }}-${{ matrix.os }}-*-${{ matrix.architecture }}"
346+
pattern: "${{ inputs.product }}-${{ matrix.os }}-${{ needs.build.outputs.version }}-${{ matrix.architecture }}"
347347
- name: Normalize package name
348348
id: normalize-name
349349
run: |
@@ -388,6 +388,7 @@ jobs:
388388
upload-src-files:
389389
needs: [prepare, build, provenance-src, provenance-pkgs]
390390
continue-on-error: true
391+
if: ${{ needs.prepare.outputs.publish-packages == 'yes' }}
391392
name: Upload source and other files
392393
runs-on: ubuntu-24.04
393394
strategy:
@@ -413,7 +414,7 @@ jobs:
413414
- name: Download packages
414415
uses: actions/download-artifact@v4
415416
with:
416-
pattern: "${{ inputs.product }}-${{ matrix.os }}-*-${{ matrix.architecture }}"
417+
pattern: "${{ inputs.product }}-${{ matrix.os }}-${{ needs.build.outputs.version }}-${{ matrix.architecture }}"
417418
- name: Normalize package name
418419
id: normalize-name
419420
run: |
@@ -446,6 +447,7 @@ jobs:
446447
needs: [build, provenance-src, provenance-pkgs]
447448
name: Upload provenance files
448449
continue-on-error: true
450+
if: ${{ needs.prepare.outputs.publish-packages == 'yes' }}
449451
runs-on: ubuntu-24.04
450452
steps:
451453
- uses: actions/checkout@v4
@@ -465,7 +467,7 @@ jobs:
465467
- name: Download provenance files
466468
uses: actions/download-artifact@v4
467469
with:
468-
pattern: "${{ inputs.product }}-*.intoto.jsonl"
470+
pattern: "${{ inputs.product }}-${{ needs.build.outputs.version }}-*.intoto.jsonl"
469471
- name: Normalize package name
470472
id: normalize-name
471473
run: |

tasks.py

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,12 +1315,16 @@ def pulp_upload_file_packages_by_folder(c, source):
13151315
for root, dirs, files in os.walk(source):
13161316
for path in files:
13171317
file = os.path.join(root, path).split('/',1)[1]
1318-
# file repositories have been configured with autopublish set to true
1319-
cmd = f'file content upload --repository {repo_name} --file {source}/{file} --relative-path {file}'
1318+
# First upload file as an artifact
1319+
cmd = f"artifact upload --file {source}/{file} --chunk-size 500MB | jq -r '.sha256' | tr -d '\n'"
1320+
artifact_sha256 = run_pulp_cmd(c, cmd)
1321+
# Then create the content of type file
1322+
cmd = f'file content create --repository {repo_name} --relative-path {file} --sha256 {artifact_sha256}'
13201323
run_pulp_cmd(c, cmd)
13211324

13221325
@task
13231326
def pulp_create_rpm_publication(c, product, list_os_rel, list_arch):
1327+
max_push_attempts = 3
13241328
rpm_distros = ["centos", "el"]
13251329
for os_rel in json.loads(list_os_rel):
13261330
if not "el-" in os_rel:
@@ -1329,16 +1333,37 @@ def pulp_create_rpm_publication(c, product, list_os_rel, list_arch):
13291333
for arch in json.loads(list_arch):
13301334
for distro in rpm_distros:
13311335
repo_name = f"repo-{distro}-{release}-{arch}-{product}"
1332-
cmd = f'rpm publication create --repository {repo_name} --checksum-type sha256'
1333-
run_pulp_cmd(c, cmd)
1336+
attempts = 0
1337+
while attempts < max_push_attempts:
1338+
try:
1339+
cmd = f'rpm publication create --repository {repo_name} --checksum-type sha256'
1340+
run_pulp_cmd(c, cmd)
1341+
break
1342+
except UnexpectedExit:
1343+
attempts += 1
1344+
time.sleep(5)
1345+
print(f'Next attempt: {attempts}')
1346+
if attempts == max_push_attempts:
1347+
raise Failure(f'Error creating rpm publication')
13341348

13351349
@task
13361350
def pulp_create_deb_publication(c):
1351+
max_push_attempts = 3
13371352
deb_distros = ["debian", "ubuntu"]
13381353
for distro in deb_distros:
13391354
repo_name = f"repo-{distro}"
1340-
cmd = f'deb publication create --repository {repo_name}'
1341-
run_pulp_cmd(c, cmd)
1355+
attempts = 0
1356+
while attempts < max_push_attempts:
1357+
try:
1358+
cmd = f'deb publication create --repository {repo_name}'
1359+
run_pulp_cmd(c, cmd)
1360+
break
1361+
except UnexpectedExit:
1362+
attempts += 1
1363+
time.sleep(5)
1364+
print(f'Next attempt: {attempts}')
1365+
if attempts == max_push_attempts:
1366+
raise Failure(f'Error creating deb publication')
13421367

13431368
@task
13441369
def pulp_upload_rpm_packages_by_folder(c, source, product):
@@ -1393,7 +1418,7 @@ def pulp_upload_deb_packages_by_folder(c, source, product):
13931418
for root, dirs, files in os.walk(source):
13941419
for path in files:
13951420
file = os.path.join(root, path).split('/',1)[1]
1396-
cmd = f"artifact upload --file {source}/{file} | jq -r '.pulp_href' | tr -d '\n'"
1421+
cmd = f"artifact upload --file {source}/{file} --chunk-size 500MB | jq -r '.pulp_href' | tr -d '\n'"
13971422
artifact_href = run_pulp_cmd(c, cmd)
13981423

13991424
package_data = {

0 commit comments

Comments
 (0)