Publish to PyPI #24
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish to PyPI | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: Version (tag) | |
required: true | |
test: | |
description: testpypi | |
required: false | |
default: false | |
type: boolean | |
debug: | |
description: verbose logging | |
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: | |
ref: ${{ github.event.inputs.version }} | |
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_pypi: | |
needs: [ build_artifacts ] | |
runs-on: ubuntu-latest | |
env: | |
url: https://pypi.org/p/spacekit | |
test_url: https://test.pypi.org/legacy/ | |
password: ${{ secrets.PYPI_PASSWORD_SPACEKIT_MAINTAINER }} | |
test_password: ${{ secrets.PYPI_PASSWORD_SPACEKIT_MAINTAINER_TEST }} | |
environment: | |
name: pypi_release | |
url: ${{ (github.event.inputs.test && env.test_url) || env.url }} | |
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/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ (inputs.test && env.test_password) || env.password }} | |
repository-url: ${{ (github.event.inputs.test && env.test_url) || env.url }} | |
verify-metadata: true | |
skip-existing: false | |
verbose: ${{ github.event.inputs.debug }} |