1- # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2- # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3-
4- name : Publish Python Package
1+ name : PythonAI
52
63on :
74 push :
5+ branches : [ "main" ]
86 tags :
9- - ' v1.0.0' # e.g., v1.0.0
7+ - ' v1.0.0' # Only publish on version tags like v1.0.0
8+ pull_request :
9+ branches : [ "main" ]
1010
1111jobs :
12- build-and -publish :
12+ build-test -publish :
1313 runs-on : ${{ matrix.os }}
1414 strategy :
1515 matrix :
16- os : [ubuntu-latest, windows-latest]
16+ os : [ubuntu-latest]
17+ python-version : [3.10]
1718
1819 steps :
19- - name : Checkout repository
20- uses : actions/checkout@v3
21-
22- - name : Set up Python
23- uses : actions/setup-python@v4
24- with :
25- python-version : ' 3.10' # or 3.11 if needed
26-
27- - name : Install dependencies
28- run : |
29- python -m pip install --upgrade pip
30- pip install -r requirements.txt
31- pip install build
32-
33- - name : Build package
34- run : python -m build
35-
36- - name : Publish to PyPI
37- uses : pypa/gh-action-pypi-publish@release/v1
38- with :
39- password : ${{ secrets.PYPI_API_TOKEN }}
20+ - name : Checkout repository
21+ uses : actions/checkout@v4
22+
23+ - name : Set up Python ${{ matrix.python-version }}
24+ uses : actions/setup-python@v5
25+ with :
26+ python-version : ${{ matrix.python-version }}
27+
28+ - name : Install dependencies
29+ run : |
30+ python -m pip install --upgrade pip
31+ pip install -r requirements.txt
32+
33+ - name : Run tests with pytest
34+ run : |
35+ pip install pytest
36+ pytest tests/
37+
38+ - name : Build package
39+ run : |
40+ pip install build
41+ python -m build
42+
43+ - name : Publish to PyPI
44+ if : startsWith(github.ref, 'refs/tags/v')
45+ run : |
46+ pip install twine
47+ twine upload dist/* -u __token__ -p ${{ secrets.PYPI_API_TOKEN }}
0 commit comments