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
on: | |
release: | |
types: [published] | |
name: Upload package to PyPI and GitHub release on release publish | |
jobs: | |
generate: | |
name: Create release-artifacts | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Install build dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade packaging flit | |
- name: Check package version (compare package version with tag) | |
id: check_package_version | |
shell: python | |
run: | | |
import pathlib, tempfile | |
from packaging.version import parse | |
from flit.wheel import WheelBuilder | |
with tempfile.TemporaryFile() as tmp_fp: | |
package_version = WheelBuilder.from_ini_path(pathlib.Path('pyproject.toml'), tmp_fp).metadata.version | |
if parse(package_version) != parse('${{ github.event.release.tag_name }}'): | |
print(f'version mismatch: {package_version} (package) vs ${{ github.event.release.tag_name }} (tag)') | |
exit(1) | |
- name: Build sdist & wheel | |
run: | | |
flit build | |
- name: Update release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "dist/*" | |
# bodyFile: "body.md" | |
generateReleaseNotes: true | |
allowUpdates: true | |
# omitBodyDuringUpdate: true | |
omitDraftDuringUpdate: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish a Python distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
# password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
# repository_url: https://test.pypi.org/legacy/ |