Skip to content

Publish to PyPI

Publish to PyPI #10

Workflow file for this run

name: Publish to PyPI
on:
# allows running workflows manually
workflow_dispatch:
release:
types:
- created
jobs:
publish:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python: ["3.7", "3.8", "3.9", "3.10", "3.11"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine build
- name: Build and package
run: |
python -m build --wheel
cd dist
version=$(ls materials-compendium-*.whl | sed -E 's/materials-compendium-(.*?)-py3-none-any.whl/\1/')
mv materials-compendium-$version-py3-none-any.whl materials-compendium-$version-$(python3 -c 'import sys; print(f"py{sys.version_info.major}.{sys.version_info.minor}")')-$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m).whl
cd ..
- name: Publish package to PyPI
if: success()
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload --repository-url https://test.pypi.org/legacy/ dist/*