11name : Plugin NPM Release
2- run-name : ${{ github.event_name == 'workflow_dispatch' && (inputs.preflight_only && format('Plugin NPM Preflight [{0}] {1}', inputs.npm_dist_tag, inputs.ref) || format('Plugin NPM Release [{0}] {1}', inputs.npm_dist_tag, inputs.ref)) || format('Plugin NPM Release [default] {0}', github.sha) }}
2+ run-name : ${{ github.event_name == 'workflow_dispatch' && (inputs.preflight_only && inputs.trusted_publisher_preflight && format('Plugin NPM Trusted Publisher Preflight [{0}] {1}', inputs.npm_dist_tag, inputs.ref) || inputs.preflight_only && format('Plugin NPM Artifact Preflight [{0}] {1}', inputs.npm_dist_tag, inputs.ref) || format('Plugin NPM Release [{0}] {1}', inputs.npm_dist_tag, inputs.ref)) || format('Plugin NPM Release [default] {0}', github.sha) }}
33
44on :
55 push :
5252 required : true
5353 default : false
5454 type : boolean
55+ trusted_publisher_preflight :
56+ description : During preflight_only, verify npm trusted-publisher OIDC exchange instead of packing artifacts
57+ required : true
58+ default : false
59+ type : boolean
5560 npm_dist_tag :
5661 description : Optional npm dist-tag override
5762 required : true
99104 env :
100105 NPM_DIST_TAG : ${{ github.event_name == 'workflow_dispatch' && inputs.npm_dist_tag || 'default' }}
101106 PREFLIGHT_ONLY : ${{ github.event_name == 'workflow_dispatch' && inputs.preflight_only || false }}
107+ TRUSTED_PUBLISHER_PREFLIGHT : ${{ github.event_name == 'workflow_dispatch' && inputs.trusted_publisher_preflight || false }}
102108 PUBLISH_SCOPE : ${{ github.event_name == 'workflow_dispatch' && inputs.publish_scope || '' }}
103109 RELEASE_PLUGINS : ${{ github.event_name == 'workflow_dispatch' && inputs.plugins || '' }}
104110 RELEASE_PUBLISH_RUN_ID : ${{ github.event_name == 'workflow_dispatch' && inputs.release_publish_run_id || '' }}
@@ -107,6 +113,10 @@ jobs:
107113 WORKFLOW_SHA : ${{ github.workflow_sha }}
108114 run : |
109115 set -euo pipefail
116+ if [[ "${TRUSTED_PUBLISHER_PREFLIGHT}" == "true" && "${PREFLIGHT_ONLY}" != "true" ]]; then
117+ echo "trusted_publisher_preflight requires preflight_only=true." >&2
118+ exit 1
119+ fi
110120 if [[ "${PREFLIGHT_ONLY}" == "true" ]]; then
111121 if [[ "${WORKFLOW_REF}" != "refs/heads/main" ]] || [[ ! "${WORKFLOW_SHA}" =~ ^[0-9a-fA-F]{40}$ ]]; then
112122 echo "Plugin npm preflight must run from a trusted main workflow revision." >&2
@@ -318,14 +328,14 @@ jobs:
318328
319329 preview_plugin_pack :
320330 needs : preview_plugins_npm
321- if : needs.preview_plugins_npm.outputs.has_candidates == 'true' || (github.event_name == 'workflow_dispatch' && inputs.preflight_only && needs.preview_plugins_npm.outputs.has_selection == 'true')
331+ if : ( needs.preview_plugins_npm.outputs.has_candidates == 'true' && !(github.event_name == 'workflow_dispatch' && inputs.preflight_only)) || (github.event_name == 'workflow_dispatch' && inputs.preflight_only && !inputs.trusted_publisher_preflight && needs.preview_plugins_npm.outputs.has_selection == 'true')
322332 runs-on : ubuntu-latest
323333 permissions :
324334 contents : read
325335 strategy :
326336 fail-fast : false
327337 matrix :
328- plugin : ${{ fromJson(github.event_name == 'workflow_dispatch' && inputs.preflight_only && needs.preview_plugins_npm.outputs.all_matrix || needs.preview_plugins_npm.outputs.matrix) }}
338+ plugin : ${{ fromJson(github.event_name == 'workflow_dispatch' && inputs.preflight_only && !inputs.trusted_publisher_preflight && needs.preview_plugins_npm.outputs.all_matrix || needs.preview_plugins_npm.outputs.matrix) }}
329339 steps :
330340 - name : Checkout
331341 uses : actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
@@ -595,15 +605,15 @@ jobs:
595605 verify_plugin_npm_preflight :
596606 name : Preflight plugin npm package (${{ matrix.plugin.packageName }})
597607 needs : [preview_plugins_npm, preview_plugin_pack]
598- if : ${{ github.event_name == 'workflow_dispatch' && ((inputs.preflight_only && needs.preview_plugins_npm.outputs.has_selection == 'true') || (!inputs.preflight_only && needs.preview_plugins_npm.outputs.has_candidates == 'true')) }}
608+ if : ${{ github.event_name == 'workflow_dispatch' && ((inputs.preflight_only && !inputs.trusted_publisher_preflight && needs.preview_plugins_npm.outputs.has_selection == 'true') || (!inputs.preflight_only && needs.preview_plugins_npm.outputs.has_candidates == 'true')) }}
599609 runs-on : ubuntu-latest
600610 permissions :
601611 actions : read
602612 contents : read
603613 strategy :
604614 fail-fast : false
605615 matrix :
606- plugin : ${{ fromJson(inputs.preflight_only && needs.preview_plugins_npm.outputs.all_matrix || needs.preview_plugins_npm.outputs.matrix) }}
616+ plugin : ${{ fromJson(inputs.preflight_only && !inputs.trusted_publisher_preflight && needs.preview_plugins_npm.outputs.all_matrix || needs.preview_plugins_npm.outputs.matrix) }}
607617 steps :
608618 - name : Checkout trusted npm preflight tooling
609619 uses : actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
@@ -1007,6 +1017,50 @@ jobs:
10071017 echo "- Publication: **not attempted**"
10081018 } >> "$GITHUB_STEP_SUMMARY"
10091019
1020+ trusted_publisher_preflight :
1021+ name : Trusted publisher OIDC exchange
1022+ needs : preview_plugins_npm
1023+ if : ${{ github.event_name == 'workflow_dispatch' && inputs.preflight_only && inputs.trusted_publisher_preflight && needs.preview_plugins_npm.outputs.has_selection == 'true' }}
1024+ runs-on : ubuntu-latest
1025+ environment : npm-release
1026+ permissions :
1027+ contents : read
1028+ id-token : write
1029+ steps :
1030+ - name : Checkout trusted OIDC preflight tooling
1031+ uses : actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
1032+ with :
1033+ persist-credentials : false
1034+ ref : ${{ github.workflow_sha }}
1035+ fetch-depth : 1
1036+
1037+ - name : Setup trusted Node
1038+ uses : actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
1039+ with :
1040+ node-version : ${{ env.NODE_VERSION }}
1041+
1042+ - name : Verify npm trusted-publisher exchange
1043+ env :
1044+ PLUGIN_MATRIX : ${{ needs.preview_plugins_npm.outputs.all_matrix }}
1045+ run : |
1046+ set -euo pipefail
1047+ node --input-type=module <<'NODE'
1048+ import { preflightNpmTrustedPublisher } from "./scripts/npm-trusted-publisher-preflight.mjs";
1049+
1050+ let selection;
1051+ try {
1052+ selection = JSON.parse(process.env.PLUGIN_MATRIX);
1053+ } catch {
1054+ throw new Error("Plugin npm selection is not valid JSON.");
1055+ }
1056+ if (!Array.isArray(selection) || selection.length === 0) {
1057+ throw new Error("Plugin npm selection must be a non-empty array.");
1058+ }
1059+ for (const entry of selection) {
1060+ await preflightNpmTrustedPublisher(entry?.packageName);
1061+ }
1062+ NODE
1063+
10101064 publish_plugins_npm :
10111065 needs :
10121066 [
0 commit comments