Skip to content

Commit

Permalink
publish workflow: guard against mismatched version tag, permit manual…
Browse files Browse the repository at this point in the history
… invocation for testing
  • Loading branch information
0xabu committed Dec 1, 2021
1 parent a0e6b41 commit 55e3895
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# This workflow will upload a Python Package using Twine when a release is created

# This workflow will build and upload a Python Package using Twine
name: Upload Python Package to PyPI

on:
# Trigger automatically when a release is published
release:
types: [published]

# Also permit manual dispatch
workflow_dispatch:

jobs:
deploy:

Expand All @@ -21,13 +24,16 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Extract version
id: get-version
run: echo "::set-output name=VERSION::$(python setup.py --version)"
- name: Build package
run: python -m build
- name: Check package
run: twine check --strict dist/*
- name: Publish package, only if tagged
if: startsWith(github.ref, 'refs/tags/v')
- name: Publish package, only if correctly tagged
if: github.ref == format('refs/tags/v{0}', steps.get-version.VERSION)
run: twine upload --non-interactive --verbose --disable-progress-bar dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}

0 comments on commit 55e3895

Please sign in to comment.