@@ -41,6 +41,11 @@ INPUT_SKIP_EXISTING="$(get-normalized-input 'skip-existing')"
41
41
INPUT_PRINT_HASH=" $( get-normalized-input ' print-hash' ) "
42
42
INPUT_ATTESTATIONS=" $( get-normalized-input ' attestations' ) "
43
43
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
+
44
49
PASSWORD_DEPRECATION_NUDGE=" ::error title=Password-based uploads disabled::\
45
50
As of 2024, PyPI requires all users to enable Two-Factor \
46
51
Authentication. This consequently requires all users to switch \
@@ -64,6 +69,27 @@ The workflow was run with 'attestations: true' input, but the specified \
64
69
repository URL does not support PEP 740 attestations. As a result, the \
65
70
attestations input is ignored."
66
71
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
+
67
93
[[ " ${INPUT_USER} " == " __token__" && -z " ${INPUT_PASSWORD} " ]] \
68
94
&& TRUSTED_PUBLISHING=true || TRUSTED_PUBLISHING=false
69
95
@@ -96,6 +122,7 @@ elif [[ "${INPUT_USER}" == '__token__' ]]; then
96
122
97
123
if [[ " ${INPUT_REPOSITORY_URL} " =~ pypi\. org ]]; then
98
124
echo " ${TRUSTED_PUBLISHING_NUDGE} "
125
+ echo " ${TRUSTED_PUBLISHING_MAGIC_LINK_NUDGE} "
99
126
fi
100
127
else
101
128
echo \
105
132
if [[ " ${INPUT_REPOSITORY_URL} " =~ pypi\. org ]]; then
106
133
echo " ${PASSWORD_DEPRECATION_NUDGE} "
107
134
echo " ${TRUSTED_PUBLISHING_NUDGE} "
135
+ echo " ${TRUSTED_PUBLISHING_MAGIC_LINK_NUDGE} "
108
136
exit 1
109
137
fi
110
138
fi
0 commit comments