|
118 | 118 |
|
119 | 119 | if "${TRUSTED_PUBLISHING}" ; then |
120 | 120 | # No password supplied by the user implies that we're in the OIDC flow; |
121 | | - # retrieve the OIDC credential and exchange it for a PyPI API token. |
| 121 | + # call twine with an empty password, since twine will detect it's running |
| 122 | + # inside CI/CD, retrieve the OIDC token and exchange it for a PyPI API token. |
122 | 123 | echo "::debug::Authenticating to ${INPUT_REPOSITORY_URL} via Trusted Publishing" |
123 | | - INPUT_PASSWORD="$(python /app/oidc-exchange.py)" |
| 124 | + INPUT_PASSWORD="" |
124 | 125 | elif [[ "${INPUT_USER}" == '__token__' ]]; then |
125 | 126 | echo \ |
126 | 127 | '::debug::Using a user-provided API token for authentication' \ |
|
145 | 146 |
|
146 | 147 | if [[ |
147 | 148 | "$INPUT_USER" == "__token__" && |
148 | | - ! "$INPUT_PASSWORD" =~ ^pypi- |
| 149 | + ! "$INPUT_PASSWORD" =~ ^pypi- && |
| 150 | + "${TRUSTED_PUBLISHING}" == false |
149 | 151 | ]] |
150 | 152 | then |
151 | 153 | if [[ -z "$INPUT_PASSWORD" ]]; then |
@@ -208,7 +210,14 @@ if [[ ${INPUT_PRINT_HASH,,} != "false" || ${INPUT_VERBOSE,,} != "false" ]] ; the |
208 | 210 | python /app/print-hash.py ${INPUT_PACKAGES_DIR%%/} |
209 | 211 | fi |
210 | 212 |
|
211 | | -TWINE_USERNAME="$INPUT_USER" \ |
212 | | -TWINE_PASSWORD="$INPUT_PASSWORD" \ |
213 | | -TWINE_REPOSITORY_URL="$INPUT_REPOSITORY_URL" \ |
214 | | - exec twine upload ${TWINE_EXTRA_ARGS} ${INPUT_PACKAGES_DIR%%/}/* |
| 213 | +# Using Trusted Publishing with twine requires not setting the password env var. |
| 214 | +if "${TRUSTED_PUBLISHING}" ; then |
| 215 | + TWINE_USERNAME="$INPUT_USER" \ |
| 216 | + TWINE_REPOSITORY_URL="$INPUT_REPOSITORY_URL" \ |
| 217 | + exec twine upload ${TWINE_EXTRA_ARGS} ${INPUT_PACKAGES_DIR%%/}/* |
| 218 | +else |
| 219 | + TWINE_USERNAME="$INPUT_USER" \ |
| 220 | + TWINE_PASSWORD="$INPUT_PASSWORD" \ |
| 221 | + TWINE_REPOSITORY_URL="$INPUT_REPOSITORY_URL" \ |
| 222 | + exec twine upload ${TWINE_EXTRA_ARGS} ${INPUT_PACKAGES_DIR%%/}/* |
| 223 | +fi |
0 commit comments