@@ -334,17 +334,18 @@ jobs:
334334 message : ' ❌ Failed to release `${{ matrix.package.name }}@v${{ steps.check-package-version.outputs.committed-version }}`! <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View logs>'
335335 emoji_reaction : ' x'
336336
337- upload -s3 :
338- name : Upload posthog-js dist to S3
337+ build -s3-artifacts :
338+ name : Build posthog-js dist for S3
339339 needs : [version-bump, publish, notify-approval-needed]
340340 runs-on : ubuntu-latest
341341 # Run as long as the version bump committed — even if some matrix publishes failed,
342342 # posthog-js might have succeeded and we still want the artifacts in S3.
343343 if : always() && needs.version-bump.outputs.commit-hash != ''
344- environment : ' S3 Upload' # OIDC role scoped to this environment — must exist in repo settings with required reviewers
345344 permissions :
346345 contents : read
347- id-token : write
346+ outputs :
347+ is-new-version : ${{ steps.check-version.outputs.is-new-version }}
348+ committed-version : ${{ steps.check-version.outputs.committed-version }}
348349 steps :
349350 - name : Checkout repository
350351 uses : actions/checkout@v6
@@ -362,32 +363,60 @@ jobs:
362363 if : steps.check-version.outputs.is-new-version == 'true'
363364 uses : ./.github/actions/setup
364365
366+ - name : Upload dist artifact
367+ if : steps.check-version.outputs.is-new-version == 'true'
368+ uses : actions/upload-artifact@v4
369+ with :
370+ name : posthog-js-dist
371+ path : packages/browser/dist/*.js
372+ retention-days : 1
373+ if-no-files-found : error
374+
375+ upload-s3 :
376+ name : Upload posthog-js dist to S3
377+ needs : [build-s3-artifacts, version-bump, notify-approval-needed]
378+ runs-on : ubuntu-latest
379+ if : always() && needs.build-s3-artifacts.outputs.is-new-version == 'true'
380+ environment : ' S3 Upload' # For OIDC credential scoping only — no required reviewers (single approval at NPM Release)
381+ permissions :
382+ contents : read
383+ id-token : write
384+ steps :
385+ # Sparse checkout: only the upload script — no pnpm install/build runs here.
386+ - name : Checkout upload script
387+ uses : actions/checkout@v6
388+ with :
389+ ref : ${{ needs.version-bump.outputs.commit-hash }}
390+ sparse-checkout : .github/scripts
391+
392+ - name : Download dist artifact
393+ uses : actions/download-artifact@v4
394+ with :
395+ name : posthog-js-dist
396+ path : packages/browser/dist
397+
365398 # Upload to US (us-east-1)
366399 - name : Configure AWS credentials (US)
367- if : steps.check-version.outputs.is-new-version == 'true'
368400 uses : aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6
369401 with :
370402 role-to-assume : ${{ vars.AWS_S3_UPLOAD_ROLE_ARN_US }}
371403 aws-region : us-east-1
372404
373405 - name : Upload dist and update manifest (US)
374- if : steps.check-version.outputs.is-new-version == 'true'
375406 env :
376- VERSION : ${{ steps.check-version .outputs.committed-version }}
407+ VERSION : ${{ needs.build-s3-artifacts .outputs.committed-version }}
377408 run : .github/scripts/upload-posthog-js-s3.sh posthog-js-prod-us
378409
379410 # Upload to EU (eu-central-1)
380411 - name : Configure AWS credentials (EU)
381- if : steps.check-version.outputs.is-new-version == 'true'
382412 uses : aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6
383413 with :
384414 role-to-assume : ${{ vars.AWS_S3_UPLOAD_ROLE_ARN_EU }}
385415 aws-region : eu-central-1
386416
387417 - name : Upload dist and update manifest (EU)
388- if : steps.check-version.outputs.is-new-version == 'true'
389418 env :
390- VERSION : ${{ steps.check-version .outputs.committed-version }}
419+ VERSION : ${{ needs.build-s3-artifacts .outputs.committed-version }}
391420 run : .github/scripts/upload-posthog-js-s3.sh posthog-js-prod-eu
392421
393422 - name : Notify Slack - S3 Upload Failed
@@ -398,14 +427,14 @@ jobs:
398427 slack_bot_token : ${{ secrets.SLACK_CLIENT_LIBRARIES_BOT_TOKEN }}
399428 slack_channel_id : ${{ vars.SLACK_APPROVALS_CLIENT_LIBRARIES_CHANNEL_ID }}
400429 thread_ts : ${{ needs.notify-approval-needed.outputs.slack_ts }}
401- message : ' ❌ Failed to upload posthog-js v${{ steps.check-version .outputs.committed-version }} dist to S3! <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View logs>'
430+ message : ' ❌ Failed to upload posthog-js v${{ needs.build-s3-artifacts .outputs.committed-version }} dist to S3! <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View logs>'
402431 emoji_reaction : ' x'
403432
404433 notify-released :
405434 name : Notify Slack - Released
406435 needs : [notify-approval-needed, publish, upload-s3]
407436 runs-on : ubuntu-latest
408- if : always() && needs.publish.result == 'success' && needs.notify-approval-needed.outputs.slack_ts != ''
437+ if : always() && needs.publish.result == 'success' && needs.upload-s3.result == 'success' && needs. notify-approval-needed.outputs.slack_ts != ''
409438 steps :
410439 - name : Checkout repository
411440 uses : actions/checkout@v6
0 commit comments