Skip to content

Commit 85a5a80

Browse files
authored
Merge pull request #270 from trail-of-forks/fix-magic-link-summary
2 parents 954318b + d8c8948 commit 85a5a80

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

twine-upload.sh

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,15 @@ The workflow was run with 'attestations: true' input, but the specified \
6969
repository URL does not support PEP 740 attestations. As a result, the \
7070
attestations input is ignored."
7171

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):"
72+
MAGIC_LINK_MESSAGE="A new Trusted Publisher for the currently running \
73+
publishing workflow can be created by accessing the following link(s) while \
74+
logged-in as an owner of the package(s):"
7575

76-
if [[ ! "${INPUT_REPOSITORY_URL}" =~ pypi\.org || ${#PACKAGE_NAMES[@]} -eq 0 ]] ; then
76+
77+
[[ "${INPUT_USER}" == "__token__" && -z "${INPUT_PASSWORD}" ]] \
78+
&& TRUSTED_PUBLISHING=true || TRUSTED_PUBLISHING=false
79+
80+
if [[ "${TRUSTED_PUBLISHING}" == true || ! "${INPUT_REPOSITORY_URL}" =~ pypi\.org || ${#PACKAGE_NAMES[@]} -eq 0 ]] ; then
7781
TRUSTED_PUBLISHING_MAGIC_LINK_NUDGE=""
7882
else
7983
if [[ "${INPUT_REPOSITORY_URL}" =~ test\.pypi\.org ]] ; then
@@ -86,12 +90,14 @@ else
8690
LINK="- ${INDEX_URL}/manage/project/${PACKAGE_NAME}/settings/publishing/?provider=github&owner=${GITHUB_REPOSITORY_OWNER}&repository=${REPOSITORY_NAME}&workflow_filename=${WORKFLOW_FILENAME}"
8791
ALL_LINKS+="$LINK"$'\n'
8892
done
89-
TRUSTED_PUBLISHING_MAGIC_LINK_NUDGE="${MAGIC_LINK_MESSAGE}"$'\n'"${ALL_LINKS}"
90-
echo "${MAGIC_LINK_MESSAGE}" >> $GITHUB_STEP_SUMMARY
91-
fi
9293

93-
[[ "${INPUT_USER}" == "__token__" && -z "${INPUT_PASSWORD}" ]] \
94-
&& TRUSTED_PUBLISHING=true || TRUSTED_PUBLISHING=false
94+
# Construct the summary message without the warning header
95+
MAGIC_LINK_MESSAGE_WITH_LINKS="${MAGIC_LINK_MESSAGE}"$'\n'"${ALL_LINKS}"
96+
echo "${MAGIC_LINK_MESSAGE_WITH_LINKS}" >> $GITHUB_STEP_SUMMARY
97+
98+
# The actual nudge in the log is formatted as a warning
99+
TRUSTED_PUBLISHING_MAGIC_LINK_NUDGE="::warning title=Create a Trusted Publisher::${MAGIC_LINK_MESSAGE_WITH_LINKS}"
100+
fi
95101

96102
if [[ "${INPUT_ATTESTATIONS}" != "false" ]] ; then
97103
# Setting `attestations: true` without Trusted Publishing indicates

0 commit comments

Comments
 (0)