Skip to content

Commit c2e2940

Browse files
added workflow for testpypi and pypi
1 parent cd20a53 commit c2e2940

1 file changed

Lines changed: 42 additions & 5 deletions

File tree

.github/workflows/test.yml

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
name: Test and Publish
1+
name: Test and Publish Python Distribution
22

33
on:
44
push:
55
branches: [ main ]
66
pull_request:
77
branches: [ main ]
88
release:
9-
types: [published]
10-
workflow_dispatch:
9+
types: [published, released]
1110

1211
jobs:
1312
test:
@@ -38,11 +37,11 @@ jobs:
3837
- name: Run tests
3938
run: pytest peepdb/tests
4039

41-
publish:
40+
publish-testpypi:
4241
needs: test
4342
runs-on: ubuntu-latest
4443
environment: test_environment
45-
if: github.event_name == 'release' && github.event.action == 'published'
44+
if: github.event.release.prerelease == true
4645

4746
steps:
4847
- uses: actions/checkout@v3
@@ -76,4 +75,42 @@ jobs:
7675
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
7776
repository_url: https://test.pypi.org/legacy/
7877
skip_existing: true
78+
verbose: true
79+
80+
publish-pypi:
81+
needs: test
82+
runs-on: ubuntu-latest
83+
environment: production_environment
84+
if: github.event.release.prerelease == false
85+
86+
steps:
87+
- uses: actions/checkout@v3
88+
89+
- name: Clean build directories
90+
run: |
91+
rm -rf build/ dist/ *.egg-info/
92+
93+
- name: Set up Python
94+
uses: actions/setup-python@v4
95+
with:
96+
python-version: '3.x'
97+
98+
- name: Install system dependencies
99+
run: |
100+
sudo apt-get update
101+
sudo apt-get install -y libmariadb-dev
102+
103+
- name: Install dependencies
104+
run: |
105+
python -m pip install --upgrade pip
106+
pip install build
107+
108+
- name: Build package
109+
run: python -m build
110+
111+
- name: Publish package to PyPI
112+
uses: pypa/gh-action-pypi-publish@v1.5.1
113+
with:
114+
user: __token__
115+
password: ${{ secrets.PYPI_API_TOKEN }}
79116
verbose: true

0 commit comments

Comments
 (0)