I am trying to set up Azure Devops to publish to a PyPI feed with Poetry.
I know about Twine authentication and storing credentials to an Azure Key Vault. But is there any more straightforward method? Something like this:
- script: |source .venv/bin/activatepoetry builddisplayName: Build wheel
- script: |source .venv/bin/activatepoetry publish -u USER -p PASSdisplayName: Publish wheel
Yes. In the Azure DevOps web interface:
- Create a new PyPI feed (Artifacts > New feed > Create).
- Create PyPI credentials (Connect to feed > Python > Generate Python credentials).
- Create secret pipeline variables named
username
and password
and valued with the PyPI credentials (Pipelines > Edit > Variables > New variable > Keep this value secret > OK).
- Update the contents of the
azure-pipelines.yml
CI file with this:
trigger:
- masterpool:vmImage: ubuntu-lateststeps:
- task: UsePythonVersion@0inputs:versionSpec: 3.7displayName: Install Python
- script: |python -m pip install -U pippip install poetrypoetry installdisplayName: Install software
- script: |poetry run python -m unittest discover tests/ -vdisplayName: Test software
- script: |poetry builddisplayName: Package software
- script: |poetry config repositories.azure https://pkgs.dev.azure.com/{your organization}/_packaging/{your feed}/pypi/uploadpoetry config http-basic.azure $(username) $(password)poetry publish -r azureexit 0displayName: Publish software