Skip to content

Publish to PyPI

Publish to PyPI #17

name: Publish to PyPI
on:
workflow_dispatch:
inputs:
test:
description: publish to test pypi
required: false
default: false
type: boolean
# Change to this once workflow has been tested
# on:
# release:
# types: [released]
jobs:
build_artifacts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.11'
- name: Install build tools
shell: 'bash'
run: python -m pip install build
- name: Build sdist
shell: 'bash'
run: python -m build --sdist --wheel .
- uses: actions/[email protected]
with:
path: dist/*
publish_pypi:
needs: [ build_artifacts ]
runs-on: ubuntu-latest
env:
name: pypi
url: https://pypi.org/project/spacekit
user: ${{ secrets.PYPI_USERNAME_SPACEKIT_MAINTAINER }}
password: ${{ secrets.PYPI_PASSWORD_SPACEKIT_MAINTAINER }}
test_password: ${{ secrets.PYPI_PASSWORD_SPACEKIT_MAINTAINER_TEST }}
test_url: https://test.pypi.org/legacy/
verify_metadata: true
skip_existing: false
verbose: true
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
# retrieve your distributions here
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist
- name: Publish package distributions to PyPI
uses: pypa/[email protected]
with:
user: ${{ env.user }}
password: ${{ (inputs.test == 'true' && env.test_password) || env.password }}
repository-url: ${{ (inputs.test == 'true' && env.test_url) || env.url }}
verify-metadata: ${{ env.verify_metadata }}
skip-existing: ${{ env.skip_existing }}
verbose: ${{ env.verbose }}