-
Notifications
You must be signed in to change notification settings - Fork 38
35 lines (34 loc) · 1.09 KB
/
publish_pypi.yml
File metadata and controls
35 lines (34 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
---
name: PyPI
on: push
jobs:
build-n-publish:
name: Build and publish Python distribution to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Build a binary wheel and a source tarball
run: |
python -mpip install build
python -m build
- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_PASSWORD }}
- name: Create a GitHub release
if: startsWith(github.ref, 'refs/tags')
run: |
TAG="${GITHUB_REF#refs/tags/}"
TAG_NO_V="${TAG#v}"
# Mark a/b/rc tags as prereleases.
if echo "${TAG_NO_V}" | grep -Eq '[0-9](\.?)(a|b|rc)[0-9]+$'; then
gh release create --generate-notes --prerelease "${TAG}"
else
gh release create --generate-notes "${TAG}"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}