mirror of
https://github.com/pypa/gh-action-pypi-publish.git
synced 2024-11-22 08:31:08 -05:00
dfcfeca43e
Previously, the action repository was being cloned from the remote twice, unnecessarily. This patch eliminates this step and uses the copy that was checked out on job start. The generated trampoline action is still copied into the allowlisted working directory so it can be referenced by the relative path starting with `./`. It is now output under `./.github/.tmp/.generated-actions/run-pypi-publish-in-docker-container` which mutates the end-user's workspace slightly but uses a path that is unlikely to clash with somebody else's use. Unfortunately, we cannot use randomized paths because the composite action syntax does not allow accessing variables in `uses:`. Fixes #292.
164 lines
6.1 KiB
YAML
164 lines
6.1 KiB
YAML
---
|
|
name: pypi-publish
|
|
description: Upload Python distribution packages to PyPI
|
|
inputs:
|
|
user:
|
|
description: PyPI user
|
|
required: false
|
|
default: __token__
|
|
password:
|
|
description: Password for your PyPI user or an access token
|
|
required: false
|
|
repository-url: # Canonical alias for `repository_url`
|
|
description: The repository URL to use
|
|
required: false
|
|
repository_url: # DEPRECATED ALIAS; TODO: Remove in v3+
|
|
description: >-
|
|
[DEPRECATED]
|
|
The repository URL to use
|
|
deprecationMessage: >-
|
|
The inputs have been normalized to use kebab-case.
|
|
Use `repository-url` instead.
|
|
required: false
|
|
default: https://upload.pypi.org/legacy/
|
|
packages-dir: # Canonical alias for `packages_dir`
|
|
description: The target directory for distribution
|
|
required: false
|
|
# default: dist # TODO: uncomment once alias removed
|
|
packages_dir: # DEPRECATED ALIAS; TODO: Remove in v3+
|
|
description: >-
|
|
[DEPRECATED]
|
|
The target directory for distribution
|
|
deprecationMessage: >-
|
|
The inputs have been normalized to use kebab-case.
|
|
Use `packages-dir` instead.
|
|
required: false
|
|
default: dist
|
|
verify-metadata: # Canonical alias for `verify_metadata`
|
|
description: Check metadata before uploading
|
|
required: false
|
|
# default: 'true' # TODO: uncomment once alias removed
|
|
verify_metadata: # DEPRECATED ALIAS; TODO: Remove in v3+
|
|
description: >-
|
|
[DEPRECATED]
|
|
Check metadata before uploading
|
|
deprecationMessage: >-
|
|
The inputs have been normalized to use kebab-case.
|
|
Use `verify-metadata` instead.
|
|
required: false
|
|
default: 'true'
|
|
skip-existing: # Canonical alias for `skip_existing`
|
|
description: >-
|
|
Do not fail if a Python package distribution
|
|
exists in the target package index
|
|
required: false
|
|
# default: 'false' # TODO: uncomment once alias removed
|
|
skip_existing: # DEPRECATED ALIAS; TODO: Remove in v3+
|
|
description: >-
|
|
[DEPRECATED]
|
|
Do not fail if a Python package distribution
|
|
exists in the target package index
|
|
deprecationMessage: >-
|
|
The inputs have been normalized to use kebab-case.
|
|
Use `skip-existing` instead.
|
|
required: false
|
|
default: 'false'
|
|
verbose:
|
|
description: Show verbose output.
|
|
required: false
|
|
default: 'false'
|
|
print-hash: # Canonical alias for `print_hash`
|
|
description: Show hash values of files to be uploaded
|
|
required: false
|
|
# default: 'false' # TODO: uncomment once alias removed
|
|
print_hash: # DEPRECATED ALIAS; TODO: Remove in v3+
|
|
description: >-
|
|
[DEPRECATED]
|
|
Show hash values of files to be uploaded
|
|
deprecationMessage: >-
|
|
The inputs have been normalized to use kebab-case.
|
|
Use `print-hash` instead.
|
|
required: false
|
|
default: 'false'
|
|
attestations:
|
|
description: >-
|
|
[EXPERIMENTAL]
|
|
Enable experimental support for PEP 740 attestations.
|
|
Only works with PyPI and TestPyPI via Trusted Publishing.
|
|
required: false
|
|
default: 'true'
|
|
branding:
|
|
color: yellow
|
|
icon: upload-cloud
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Fail-fast in unsupported environments
|
|
if: runner.os != 'Linux'
|
|
run: |
|
|
>&2 echo This action is only able to run under GNU/Linux environments
|
|
exit 1
|
|
shell: bash -eEuo pipefail {0}
|
|
- name: Reset path if needed
|
|
run: |
|
|
# Reset path if needed
|
|
# https://github.com/pypa/gh-action-pypi-publish/issues/112
|
|
if [[ $PATH != *"/usr/bin"* ]]; then
|
|
echo "\$PATH=$PATH. Resetting \$PATH for GitHub Actions."
|
|
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
|
echo "PATH=$PATH" >>"$GITHUB_ENV"
|
|
echo "$PATH" >>"$GITHUB_PATH"
|
|
echo "\$PATH reset. \$PATH=$PATH"
|
|
fi
|
|
shell: bash
|
|
- name: Set repo and ref from which to run Docker container action
|
|
id: set-repo-and-ref
|
|
run: |
|
|
# Set repo and ref from which to run Docker container action
|
|
# to handle cases in which `github.action_` context is not set
|
|
# https://github.com/actions/runner/issues/2473
|
|
REF=${{ env.ACTION_REF || env.PR_REF || github.ref_name }}
|
|
REPO=${{ env.ACTION_REPO || env.PR_REPO || github.repository }}
|
|
REPO_ID=${{ env.PR_REPO_ID || github.repository_id }}
|
|
echo "ref=$REF" >>"$GITHUB_OUTPUT"
|
|
echo "repo=$REPO" >>"$GITHUB_OUTPUT"
|
|
echo "repo-id=$REPO_ID" >>"$GITHUB_OUTPUT"
|
|
shell: bash
|
|
env:
|
|
ACTION_REF: ${{ github.action_ref }}
|
|
ACTION_REPO: ${{ github.action_repository }}
|
|
PR_REF: ${{ github.event.pull_request.head.ref }}
|
|
PR_REPO: ${{ github.event.pull_request.head.repo.full_name }}
|
|
PR_REPO_ID: ${{ github.event.pull_request.base.repo.id }}
|
|
- name: Create Docker container action
|
|
run: |
|
|
# Create Docker container action
|
|
python ${{ github.action_path }}/create-docker-action.py
|
|
env:
|
|
REF: ${{ steps.set-repo-and-ref.outputs.ref }}
|
|
REPO: ${{ steps.set-repo-and-ref.outputs.repo }}
|
|
REPO_ID: ${{ steps.set-repo-and-ref.outputs.repo-id }}
|
|
shell: bash
|
|
- name: Run Docker container
|
|
# The generated trampoline action must exist in the allowlisted
|
|
# runner-defined working directory so it can be referenced by the
|
|
# relative path starting with `./`.
|
|
#
|
|
# This mutates the end-user's workspace slightly but uses a path
|
|
# that is unlikely to clash with somebody else's use.
|
|
#
|
|
# We cannot use randomized paths because the composite action
|
|
# syntax does not allow accessing variables in `uses:`. This
|
|
# means that we end up having to hardcode this path both here and
|
|
# in `create-docker-action.py`.
|
|
uses: ./.github/.tmp/.generated-actions/run-pypi-publish-in-docker-container
|
|
with:
|
|
user: ${{ inputs.user }}
|
|
password: ${{ inputs.password }}
|
|
repository-url: ${{ inputs.repository-url || inputs.repository_url }}
|
|
packages-dir: ${{ inputs.packages-dir || inputs.packages_dir }}
|
|
verify-metadata: ${{ inputs.verify-metadata || inputs.verify_metadata }}
|
|
skip-existing: ${{ inputs.skip-existing || inputs.skip_existing }}
|
|
verbose: ${{ inputs.verbose }}
|
|
print-hash: ${{ inputs.print-hash || inputs.print_hash }}
|
|
attestations: ${{ inputs.attestations }}
|