Dagger
Search

pypi-publisher

Generic Dagger functions for publishing Python distributions to PyPI.

Installation

dagger install github.com/elviskahoro/sdk-python-publish-to-pypi@1cdcc45e2e4fe78768d73def9cbe23a54209f618

Entrypoint

Return Type
PypiPublisher !
Example
dagger -m github.com/elviskahoro/sdk-python-publish-to-pypi@1cdcc45e2e4fe78768d73def9cbe23a54209f618 call \
func (m *MyModule) Example() *dagger.PypiPublisher  {
	return dag.
			Pypipublisher()
}
@function
def example() -> dagger.PypiPublisher:
	return (
		dag.pypi_publisher()
	)
@func()
example(): PypiPublisher {
	return dag
		.pypiPublisher()
}

Types

PypiPublisher 🔗

Build Python distributions with uv and upload them to a PyPI index.

build() 🔗

Build a wheel and source distribution and return them as a directory.

The project is supplied explicitly instead of being read from the module’s working directory. This lets the module publish any Python project, locally or from another Dagger pipeline.

Return Type
Directory !
Arguments
NameTypeDefault ValueDescription
sourceDirectory !-

Project directory containing pyproject.toml

pythonVersionString !"3.13"

Python image tag used to build the distribution

Example
dagger -m github.com/elviskahoro/sdk-python-publish-to-pypi@1cdcc45e2e4fe78768d73def9cbe23a54209f618 call \
 build --source DIR_PATH --python-version string
func (m *MyModule) Example(source *dagger.Directory, pythonVersion string) *dagger.Directory  {
	return dag.
			Pypipublisher().
			Build(source, pythonVersion)
}
@function
def example(source: dagger.Directory, pythonversion: str) -> dagger.Directory:
	return (
		dag.pypi_publisher()
		.build(source, pythonversion)
	)
@func()
example(source: Directory, pythonVersion: string): Directory {
	return dag
		.pypiPublisher()
		.build(source, pythonVersion)
}

publish() 🔗

Build the project and upload its wheel and sdist to a PyPI index.

Return Type
String !
Arguments
NameTypeDefault ValueDescription
sourceDirectory !-

Project directory containing pyproject.toml

pypiTokenSecret !-

PyPI API token

repositoryUrlString !"https://upload.pypi.org/legacy/"

Upload endpoint, for example TestPyPI’s legacy endpoint

pythonVersionString !"3.13"

Python image tag used to build the distribution

Example
dagger -m github.com/elviskahoro/sdk-python-publish-to-pypi@1cdcc45e2e4fe78768d73def9cbe23a54209f618 call \
 publish --source DIR_PATH --pypi-token env:MYSECRET --repository-url string --python-version string
func (m *MyModule) Example(ctx context.Context, source *dagger.Directory, pypiToken *dagger.Secret, repositoryUrl string, pythonVersion string) string  {
	return dag.
			Pypipublisher().
			Publish(ctx, source, pypiToken, repositoryUrl, pythonVersion)
}
@function
async def example(source: dagger.Directory, pypitoken: dagger.Secret, repositoryurl: str, pythonversion: str) -> str:
	return await (
		dag.pypi_publisher()
		.publish(source, pypitoken, repositoryurl, pythonversion)
	)
@func()
async example(source: Directory, pypiToken: Secret, repositoryUrl: string, pythonVersion: string): Promise<string> {
	return dag
		.pypiPublisher()
		.publish(source, pypiToken, repositoryUrl, pythonVersion)
}

publishArtifacts() 🔗

Upload already-built artifacts to a PyPI-compatible index.

pypi_token remains a Dagger Secret throughout the call and is not written to the artifact directory or included in command output.

Return Type
String !
Arguments
NameTypeDefault ValueDescription
artifactsDirectory !-

Directory containing only wheel and source-distribution artifacts

pypiTokenSecret !-

PyPI API token

repositoryUrlString !"https://upload.pypi.org/legacy/"

Upload endpoint, for example TestPyPI’s legacy endpoint

Example
dagger -m github.com/elviskahoro/sdk-python-publish-to-pypi@1cdcc45e2e4fe78768d73def9cbe23a54209f618 call \
 publish-artifacts --artifacts DIR_PATH --pypi-token env:MYSECRET --repository-url string
func (m *MyModule) Example(ctx context.Context, artifacts *dagger.Directory, pypiToken *dagger.Secret, repositoryUrl string) string  {
	return dag.
			Pypipublisher().
			Publishartifacts(ctx, artifacts, pypiToken, repositoryUrl)
}
@function
async def example(artifacts: dagger.Directory, pypitoken: dagger.Secret, repositoryurl: str) -> str:
	return await (
		dag.pypi_publisher()
		.publishartifacts(artifacts, pypitoken, repositoryurl)
	)
@func()
async example(artifacts: Directory, pypiToken: Secret, repositoryUrl: string): Promise<string> {
	return dag
		.pypiPublisher()
		.publishArtifacts(artifacts, pypiToken, repositoryUrl)
}