pypi-publish #53
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
# A workflow to publish releases to PyPi and TestPyPi. | |
name: pypi-publish | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
run_tests: | |
description: 'Test sdist before upload' | |
type: boolean | |
default: true | |
upload_to_test_pypi: | |
description: 'Upload to Test PyPi' | |
type: boolean | |
default: false | |
upload_to_pypi: | |
description: 'Upload to PyPi' | |
type: boolean | |
default: false | |
permissions: read-all | |
jobs: | |
build: | |
name: Build | |
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
steps: | |
- name: Checkout Concordia | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 | |
- name: Show Python setup | |
run: | | |
python --version | |
pip list | |
- name: Build distribution | |
run: python setup.py sdist bdist_wheel | |
- name: Save artifact | |
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 | |
with: | |
name: dist | |
path: ./dist | |
retention-days: 1 | |
test: | |
name: Test | |
needs: build | |
if: github.event_name == 'release' || inputs.run_tests | |
runs-on: ${{ matrix.os }} | |
env: | |
SYSTEM_VERSION_COMPAT: 0 # See https://github.com/actions/setup-python/issues/279. | |
timeout-minutes: 120 | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
python-version: | |
- '3.11' | |
steps: | |
- name: Fail | |
run: exit 1 | |
publish: | |
name: Publish | |
needs: [build, test] | |
if: always() && needs.build.result == 'success' && needs.test.result != 'failure' | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/gdm-concordia | |
permissions: | |
id-token: write | |
timeout-minutes: 10 | |
steps: | |
- name: Load artifact | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 | |
with: | |
name: dist | |
path: ./dist | |
- name: Publish to TestPyPI | |
if: github.event_name == 'release' || inputs.upload_to_test_pypi | |
uses: pypa/gh-action-pypi-publish@0ab0b79471669eb3a4d647e625009c62f9f3b241 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
verbose: true | |
- name: Publish to PyPI | |
if: github.event_name == 'release' || inputs.upload_to_pypi | |
uses: pypa/gh-action-pypi-publish@0ab0b79471669eb3a4d647e625009c62f9f3b241 | |
with: | |
verbose: true |