⚡️ Change trigger of release workflow to push #2
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: Publishing to PyPI | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
testing: | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
python-version: ["3.12"] | |
os: [ubuntu-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install tox | |
run: | | |
python -m pip install --upgrade pip | |
pip install tox | |
- name: Run tests | |
run: | | |
tox | |
deploying: | |
name: Build and deploy package to PyPI | |
runs-on: ubuntu-latest | |
# GitHub repository settings/environments/create "release" environment | |
# set up trusted publishing on https://pypi.org/ @ settings/manage/publishing | |
environment: release | |
permissions: | |
id-token: write | |
needs: testing | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r dev_requirements/requirements-packaging.txt | |
- name: Build wheel and source distributions | |
run: | | |
pdm build | |
- name: Publish to PyPI | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: pypa/gh-action-pypi-publish@release/v1 |