Update publish.yml #12
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 Package | |
on: | |
push: | |
branches: | |
- main # Trigger this workflow on pushes to the main branch | |
tags: | |
- 'v*.*.*' # Optionally trigger on tag pushes with version numbers | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
python-version: ['3.9'] | |
runs-on: ${{ matrix.os == 'ubuntu-latest' || matrix.os }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
if: matrix.os != 'ubuntu-latest' | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
if: matrix.os != 'ubuntu-latest' | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install build twine | |
- name: Build package | |
run: | | |
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then | |
docker build -t my-package -f Dockerfile . && docker run my-package | |
else | |
python -m build | |
fi | |
- name: Publish to PyPI | |
env: | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
run: | | |
python -m twine upload dist/* |