Skip to content

Commit f0b0b59

Browse files
authored
[AI-6754] Only sign and upload ddev packages in tags (DataDog#23414)
* only sign and upload ddev packages in PRs and master * Add back schedule * Add should-sign-and-upload step * Address feedback
1 parent 428fab2 commit f0b0b59

1 file changed

Lines changed: 34 additions & 10 deletions

File tree

.github/workflows/build-ddev.yml

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,27 @@ jobs:
5252
fi
5353
echo "base_tags=team:agent-integrations,service:ddev,context:$context" >> $GITHUB_OUTPUT
5454
55+
should-sign-and-upload:
56+
name: Determine signing conditions
57+
runs-on: ubuntu-latest
58+
defaults:
59+
run:
60+
# Override workflow-level working-directory since this job does not checkout code
61+
working-directory: .
62+
outputs:
63+
result: ${{ steps.check.outputs.result }}
64+
steps:
65+
- id: check
66+
env:
67+
EVENT_NAME: ${{ github.event_name }}
68+
REF: ${{ github.ref }}
69+
run: |
70+
result=false
71+
if [[ "$EVENT_NAME" == "schedule" || ( "$EVENT_NAME" == "push" && "$REF" == refs/tags/* ) ]]; then
72+
result=true
73+
fi
74+
echo "result=$result" >> $GITHUB_OUTPUT
75+
5576
python-artifacts:
5677
name: Build wheel and source distribution
5778
runs-on: ubuntu-latest
@@ -315,9 +336,10 @@ jobs:
315336

316337
windows-packaging:
317338
name: Build Windows installers
318-
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
339+
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event.pull_request.head.repo.full_name == github.repository
319340
needs:
320341
- define-tags
342+
- should-sign-and-upload
321343
- binaries
322344
runs-on: windows-2022
323345
permissions:
@@ -429,6 +451,7 @@ jobs:
429451
mv build/*/release/*/*.{exe,msi} installers
430452
431453
- name: Upload installers
454+
if: needs.should-sign-and-upload.outputs.result == 'true'
432455
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
433456
with:
434457
name: installers-${{ runner.os }}
@@ -437,9 +460,10 @@ jobs:
437460

438461
macos-packaging:
439462
name: Build macOS installer and sign/notarize artifacts
440-
if: github.event_name == 'push'
463+
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event.pull_request.head.repo.full_name == github.repository
441464
needs:
442465
- define-tags
466+
- should-sign-and-upload
443467
- binaries
444468
runs-on: macos-14-large
445469
permissions:
@@ -483,6 +507,7 @@ jobs:
483507
tar --strip-components=1 -xzf - -C /usr/local/bin "$ARCHIVE_NAME/rcodesign"
484508
485509
- name: Write credentials
510+
if: needs.should-sign-and-upload.outputs.result == 'true'
486511
env:
487512
APPLE_DEVELOPER_ID_APPLICATION_CERTIFICATE: "${{ secrets.APPLE_DEVELOPER_ID_APPLICATION_CERTIFICATE }}"
488513
APPLE_DEVELOPER_ID_APPLICATION_PRIVATE_KEY: "${{ secrets.APPLE_DEVELOPER_ID_APPLICATION_PRIVATE_KEY }}"
@@ -560,13 +585,12 @@ jobs:
560585
- name: Extract staged standalone binaries
561586
run: ${{ steps.script-extract.outputs.script }}
562587

563-
# Signing and notarization steps are skipped for Dependabot PRs (no access to Apple secrets)
564588
- name: Sign standalone binaries
565-
if: github.event_name != 'pull_request' || github.event.pull_request.user.login != 'dependabot[bot]'
589+
if: needs.should-sign-and-upload.outputs.result == 'true'
566590
run: ${{ steps.script-sign.outputs.script }}
567591

568592
- name: Notarize standalone binaries
569-
if: github.event_name != 'pull_request' || github.event.pull_request.user.login != 'dependabot[bot]'
593+
if: needs.should-sign-and-upload.outputs.result == 'true'
570594
run: ${{ steps.script-notarize.outputs.script }}
571595

572596
- name: Archive standalone binaries
@@ -599,11 +623,11 @@ jobs:
599623
run: ${{ steps.script-extract.outputs.script }}
600624

601625
- name: Sign managed binaries
602-
if: github.event_name != 'pull_request' || github.event.pull_request.user.login != 'dependabot[bot]'
626+
if: needs.should-sign-and-upload.outputs.result == 'true'
603627
run: ${{ steps.script-sign.outputs.script }}
604628

605629
- name: Notarize managed binaries
606-
if: github.event_name != 'pull_request' || github.event.pull_request.user.login != 'dependabot[bot]'
630+
if: needs.should-sign-and-upload.outputs.result == 'true'
607631
run: ${{ steps.script-notarize.outputs.script }}
608632

609633
# bin/<APP_NAME>-<VERSION>-<TARGET> -> targets/<TARGET>/<APP_NAME>
@@ -646,7 +670,7 @@ jobs:
646670
echo "path=$pkg_file" >> "$GITHUB_OUTPUT"
647671
648672
- name: Sign PKG
649-
if: github.event_name != 'pull_request' || github.event.pull_request.user.login != 'dependabot[bot]'
673+
if: needs.should-sign-and-upload.outputs.result == 'true'
650674
run: >-
651675
rcodesign sign -vv
652676
--pem-source /tmp/certificate-installer.pem
@@ -655,15 +679,15 @@ jobs:
655679
"signed/${{ steps.pkg.outputs.path }}"
656680
657681
- name: Notarize PKG
658-
if: github.event_name != 'pull_request' || github.event.pull_request.user.login != 'dependabot[bot]'
682+
if: needs.should-sign-and-upload.outputs.result == 'true'
659683
run: >-
660684
rcodesign notary-submit
661685
--api-key-path /tmp/app-store-connect.json
662686
--staple
663687
"signed/${{ steps.pkg.outputs.path }}"
664688
665689
- name: Upload installer
666-
if: github.event_name != 'pull_request' || github.event.pull_request.user.login != 'dependabot[bot]'
690+
if: needs.should-sign-and-upload.outputs.result == 'true'
667691
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
668692
with:
669693
name: installers-${{ runner.os }}

0 commit comments

Comments
 (0)