Skip to content

Commit

Permalink
Merge pull request #18 from casperdcl/trusted-pub
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Feb 6, 2024
2 parents 755c420 + c7218e4 commit e3b0f95
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Other features (supported by both) include:

- Supports checking built files
- Supports skipping existing uploads
- Supports OIDC PyPI trusted publishing

## Inputs

Expand All @@ -54,7 +55,11 @@ inputs:
default: __token__
password:
description: PyPI password or API token
required: true
required: false
registry_domain:
description: PyPI trusted publisher URL
required: false
default: https://upload.pypi.org
requirements:
description: Packages to `pip install` before building
default: twine wheel build
Expand Down
13 changes: 12 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ inputs:
default: __token__
password:
description: PyPI password or API token
required: true
required: false
registry_domain:
description: PyPI trusted publisher URL
required: false
default: https://upload.pypi.org
requirements:
description: Packages to `pip install` before building
required: false
Expand Down Expand Up @@ -121,6 +125,12 @@ runs:
TWINE_OPTS="$TWINE_OPTS --skip-existing"
fi
python -m pip install twine
if [[ -z "$TWINE_PASSWORD" ]]; then
# vis https://docs.pypi.org/trusted-publishers/using-a-publisher/#the-manual-way
oidc_token=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=pypi" | jq -r '.value')
export TWINE_PASSWORD=$(curl https://pypi.org/_/oidc/mint-token -d "{\"token\": \"${oidc_token}\"}" | jq -r '.token')
echo "::add-mask::$TWINE_PASSWORD"
fi
python -m twine upload $TWINE_OPTS "${DIST}"/*
fi
pushd "$DIST"
Expand All @@ -138,6 +148,7 @@ runs:
TWINE_REPOSITORY_URL: ${{ inputs.url }}
TWINE_USERNAME: ${{ inputs.user }}
TWINE_PASSWORD: ${{ inputs.password }}
INPUT_REGISTRY_DOMAIN: ${{ inputs.registry_domain }}
branding:
icon: upload-cloud
color: blue

0 comments on commit e3b0f95

Please sign in to comment.