Skip to content

Publish to PyPI

Publish to PyPI #18

Workflow file for this run

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/upload-artifact@v4
with:
path: dist/*
publish_testpypi:
needs: [ build_artifacts ]
if: ${{ inputs.test == 'true' }}
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- name: Publish package distributions to TEST PyPI
uses: pypa/[email protected]
with:
name: testpypi
user: ${{ secrets.PYPI_USERNAME_SPACEKIT_MAINTAINER }}
password: ${{ secrets.PYPI_PASSWORD_SPACEKIT_MAINTAINER_TEST }}
repository-url: https://test.pypi.org/legacy/
verify-metadata: true
skip-existing: false
verbose: true
publish_pypi:
needs: [ build_artifacts ]
if: ${{ inputs.test == 'false' }}
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- name: Publish package distributions to PyPI
uses: pypa/[email protected]
with:
name: pypi
user: ${{ secrets.PYPI_USERNAME_SPACEKIT_MAINTAINER }}
password: ${{ secrets.PYPI_PASSWORD_SPACEKIT_MAINTAINER }}
repository-url: https://pypi.org/p/spacekit
verify-metadata: true
skip-existing: false
verbose: false