-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (43 loc) · 1.31 KB
/
python-publish.yml
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
on:
release:
types: [published]
jobs:
pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/project/pyvsnr
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install build and twine
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: |
python -m build
- name: Check package with Twine
run: |
twine check dist/*
- name: Determine PyPI repository
run: |
if [[ ${{ github.event.release.prerelease }} == 'true' ]]; then
echo "REPOSITORY_URL=https://test.pypi.org/legacy/" >> $GITHUB_ENV
echo "PYPI_API_TOKEN=${{ secrets.TEST_PYPI_API_TOKEN }}" >> $GITHUB_ENV
else
echo "REPOSITORY_URL=https://upload.pypi.org/legacy/" >> $GITHUB_ENV
echo "PYPI_API_TOKEN=${{ secrets.PYPI_API_TOKEN }}" >> $GITHUB_ENV
fi
- name: Publish package distributions to PyPI
uses: pypa/[email protected]
with:
repository-url: ${{ env.REPOSITORY_URL }}
user: __token__
password: ${{ env.PYPI_API_TOKEN }}