@@ -41,6 +41,11 @@ INPUT_SKIP_EXISTING="$(get-normalized-input 'skip-existing')"
4141INPUT_PRINT_HASH=" $( get-normalized-input ' print-hash' ) "
4242INPUT_ATTESTATIONS=" $( get-normalized-input ' attestations' ) "
4343
44+ REPOSITORY_NAME=" $( echo ${GITHUB_REPOSITORY} | cut -d' /' -f2) "
45+ WORKFLOW_FILENAME=" $( echo ${GITHUB_WORKFLOW_REF} | cut -d' /' -f5- | cut -d' @' -f1) "
46+ PACKAGE_NAMES=()
47+ while IFS=' ' read -r line; do PACKAGE_NAMES+=(" $line " ); done < <( python /app/print-pkg-names.py " ${INPUT_PACKAGES_DIR%%/ } " )
48+
4449PASSWORD_DEPRECATION_NUDGE=" ::error title=Password-based uploads disabled::\
4550As of 2024, PyPI requires all users to enable Two-Factor \
4651Authentication. This consequently requires all users to switch \
@@ -64,6 +69,27 @@ The workflow was run with 'attestations: true' input, but the specified \
6469repository URL does not support PEP 740 attestations. As a result, the \
6570attestations input is ignored."
6671
72+ MAGIC_LINK_MESSAGE=" ::warning title=Create a Trusted Publisher::\
73+ A new Trusted Publisher for the currently running publishing workflow can be created \
74+ by accessing the following link(s) while logged-in as an owner of the package(s):"
75+
76+ if [[ ! " ${INPUT_REPOSITORY_URL} " =~ pypi\. org || ${# PACKAGE_NAMES[@]} -eq 0 ]] ; then
77+ TRUSTED_PUBLISHING_MAGIC_LINK_NUDGE=" "
78+ else
79+ if [[ " ${INPUT_REPOSITORY_URL} " =~ test\. pypi\. org ]] ; then
80+ INDEX_URL=" https://test.pypi.org"
81+ else
82+ INDEX_URL=" https://pypi.org"
83+ fi
84+ ALL_LINKS=" "
85+ for PACKAGE_NAME in " ${PACKAGE_NAMES[@]} " ; do
86+ LINK=" - ${INDEX_URL} /manage/project/${PACKAGE_NAME} /settings/publishing/?provider=github&owner=${GITHUB_REPOSITORY_OWNER} &repository=${REPOSITORY_NAME} &workflow_filename=${WORKFLOW_FILENAME} "
87+ ALL_LINKS+=" $LINK " $' \n '
88+ done
89+ TRUSTED_PUBLISHING_MAGIC_LINK_NUDGE=" ${MAGIC_LINK_MESSAGE} " $' \n ' " ${ALL_LINKS} "
90+ echo " ${MAGIC_LINK_MESSAGE} " >> $GITHUB_STEP_SUMMARY
91+ fi
92+
6793[[ " ${INPUT_USER} " == " __token__" && -z " ${INPUT_PASSWORD} " ]] \
6894 && TRUSTED_PUBLISHING=true || TRUSTED_PUBLISHING=false
6995
@@ -96,6 +122,7 @@ elif [[ "${INPUT_USER}" == '__token__' ]]; then
96122
97123 if [[ " ${INPUT_REPOSITORY_URL} " =~ pypi\. org ]]; then
98124 echo " ${TRUSTED_PUBLISHING_NUDGE} "
125+ echo " ${TRUSTED_PUBLISHING_MAGIC_LINK_NUDGE} "
99126 fi
100127else
101128 echo \
105132 if [[ " ${INPUT_REPOSITORY_URL} " =~ pypi\. org ]]; then
106133 echo " ${PASSWORD_DEPRECATION_NUDGE} "
107134 echo " ${TRUSTED_PUBLISHING_NUDGE} "
135+ echo " ${TRUSTED_PUBLISHING_MAGIC_LINK_NUDGE} "
108136 exit 1
109137 fi
110138fi
0 commit comments