Skip to content

Commit 297bfb3

Browse files
authored
Add files via upload
1 parent 7358e0e commit 297bfb3

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/python-publish.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
on:
2+
release:
3+
types: [published]
4+
5+
jobs:
6+
pypi-publish:
7+
name: Upload release to PyPI
8+
runs-on: ubuntu-latest
9+
environment:
10+
name: release
11+
url: https://pypi.org/project/pyvsnr
12+
permissions:
13+
contents: read
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.x'
21+
22+
- name: Install build and twine
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install build twine
26+
27+
- name: Build package
28+
run: |
29+
python -m build
30+
31+
- name: Check package with Twine
32+
run: |
33+
twine check dist/*
34+
35+
- name: Determine PyPI repository
36+
run: |
37+
if [[ ${{ github.event.release.prerelease }} == 'true' ]]; then
38+
echo "REPOSITORY_URL=https://test.pypi.org/legacy/" >> $GITHUB_ENV
39+
echo "PYPI_API_TOKEN=${{ secrets.TEST_PYPI_API_TOKEN }}" >> $GITHUB_ENV
40+
else
41+
echo "REPOSITORY_URL=https://upload.pypi.org/legacy/" >> $GITHUB_ENV
42+
echo "PYPI_API_TOKEN=${{ secrets.PYPI_API_TOKEN }}" >> $GITHUB_ENV
43+
fi
44+
45+
- name: Publish package distributions to PyPI
46+
uses: pypa/[email protected]
47+
with:
48+
repository-url: ${{ env.REPOSITORY_URL }}
49+
user: __token__
50+
password: ${{ env.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)