Add message, action, and tool #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Python Package | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
tags: | |
- 'v*' # Match tags for production releases | |
- 'test-*' # Match tags for test releases | |
pull_request: | |
branches: | |
- main | |
- develop | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools wheel twine pytest | |
# If you have dependencies specific to your project, install them here | |
pip install -r requirements.txt | |
- name: Run Pytest | |
run: | | |
pytest tests/ | |
build-and-publish: | |
needs: test | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools wheel twine | |
- name: Build package | |
run: | | |
python setup.py sdist bdist_wheel | |
- name: Publish to Test PyPI | |
if: startsWith(github.ref, 'refs/tags/test-') | |
uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
repository_url: https://test.pypi.org/legacy/ | |
- name: Publish to PyPI | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} |