Skip to content

Commit

Permalink
Add GitHub workflow to upload package to PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
RoTranDo authored Dec 16, 2022
1 parent 77704d7 commit 13dc371
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/publish_release_packages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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/

0 comments on commit 13dc371

Please sign in to comment.