CI tests fix + add Publishing CI #1
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 distributions to PyPI | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
tags: | |
- "v*" | |
env: | |
python-version: "3.12" | |
jobs: | |
build-n-publish: | |
name: Build and publish distributions to PyPI | |
if: github.repository == 'pvplabs/pvpltools' | |
runs-on: ubuntu-latest | |
environment: release | |
permissions: | |
# this permission is mandatory for trusted publishing | |
id-token: write | |
steps: | |
# Check out only a limited depth and then pull tags to save time | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 100 | |
- name: Get tags | |
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.python-version }} | |
- name: Install build tools | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade build | |
python -m pip install --upgrade twine | |
- name: Build packages | |
run: python -m build | |
- name: Check metadata verification | |
run: python -m twine check --strict dist/* | |
# only publish distribution to PyPI for tagged commits | |
- name: Publish distribution to PyPI | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: pypa/gh-action-pypi-publish@release/v1 |