Add a GitHub Actions workflow for automatic PyPi publishing whenever creating a new release #10
Workflow file for this run
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 to PyPi | |
on: | |
release: | |
types: [published] | |
pull_request: # for testing... to remove... | |
types: [ opened, synchronize, reopened ] | |
jobs: | |
build-package: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- 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: Upload package artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: package | |
path: dist | |
test-package: | |
needs: build-package | |
strategy: | |
matrix: | |
os: [ ubuntu-latest, macos-latest, windows-latest ] | |
python-version: [ "3.8", "3.9", "3.10", "3.11" ] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set Up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Download package artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: package | |
- name: Install package and dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install "plams-*.whl[chem_tools, results]" | |
pip install pytest | |
- name: Run Unit Tests | |
run: | | |
pytest unit_tests | |
publish-package: | |
runs-on: ubuntu-latest | |
needs: test-package | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Download package artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: package | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_TOKEN }} |